Closed
Description
Thank you very much for this useful plugin. It appears, that the latest patch version (38.1.1) introduced a bug.
I'll do my best to describe it below. A minimal example as well as demo-repository is attached.
Expected behavior
ESLint (jsdoc plugin) reports issues, if any.
Actual behavior
ESLint (jsdoc plugin) crashes with an internal error TypeError: Cannot read properties of undefined (reading 'type')
.
If I use @return {Object | String}
, it crashes. @return {object | String}
works.
Full stack:
❯ npm run lint
> [email protected] lint
> eslint index.js
Oops! Something went wrong! :(
ESLint: 8.12.0
TypeError: Cannot read properties of undefined (reading 'type')
Occurred while linting /path/to/eslint-issue/index.js:8
Rule: "jsdoc/check-types"
at checkNativeTypes (/path/to/eslint-issue/node_modules/eslint-plugin-jsdoc/dist/rules/checkTypes.js:173:158)
at getInvalidTypes (/path/to/eslint-issue/node_modules/eslint-plugin-jsdoc/dist/rules/checkTypes.js:231:19)
at /path/to/eslint-issue/node_modules/eslint-plugin-jsdoc/dist/rules/checkTypes.js:261:7
at _traverse (/path/to/eslint-issue/node_modules/jsdoc-type-pratt-parser/dist/index.js:2334:59)
at _traverse (/path/to/eslint-issue/node_modules/jsdoc-type-pratt-parser/dist/index.js:2341:25)
at traverse (/path/to/eslint-issue/node_modules/jsdoc-type-pratt-parser/dist/index.js:2358:9)
at _default.iterateAllJsdocs (/path/to/eslint-issue/node_modules/eslint-plugin-jsdoc/dist/rules/checkTypes.js:251:32)
at iterate (/path/to/eslint-issue/node_modules/eslint-plugin-jsdoc/dist/iterateJsdoc.js:830:3)
at callIterator (/path/to/eslint-issue/node_modules/eslint-plugin-jsdoc/dist/iterateJsdoc.js:914:7)
at *:not(Program) (/path/to/eslint-issue/node_modules/eslint-plugin-jsdoc/dist/iterateJsdoc.js:973:11)
Everything worked in 38.1.0, but 38.1.1 crashes. Seems to be related to #860
For an example, see below.
ESLint Config
{
"root": true,
"plugins": ["jsdoc"],
"extends": ["plugin:jsdoc/recommended"]
}
ESLint sample
'use strict';
/**
*
* @param {Object} param
* @return {Object | String}
*/
function abc(param) {
if (param.a)
return {};
return 'abc';
}
Furthermore, I have created a minimal example here: https://github.com/bugwelle/eslint-issue
Environment
- Node version: v16.14.1
- ESLint version v8.12.0
eslint-plugin-jsdoc
version: 38.1.1