Hi -- so the no-undefined-types rule is directly accessing private member __options on the scope manager, which is causing breakage with the latest version of the @typescript-eslint/parser package. I brought this up as a bug over on their repo, and they (I think correctly) kicked the ball down the court since the member shouldn't be accessed externally anyways. Reference to the issue I opened there: https://github.com/typescript-eslint/typescript-eslint/issues/2460
I would expect it to lint and not crash.
```$ eslint main.ts --ext .ts
Oops! Something went wrong! :(
ESLint: 7.8.0
TypeError: Cannot read property 'nodejsScope' of undefined
Occurred while linting /Users/daviduzumeri/Documents/GitHub/ts-eslint-jsdoc-repro/main.ts:5
at _default.iterateAllJsdocs (/Users/daviduzumeri/Documents/GitHub/ts-eslint-jsdoc-repro/node_modules/eslint-plugin-jsdoc/dist/rules/noUndefinedTypes.js:130:26)
at iterate (/Users/daviduzumeri/Documents/GitHub/ts-eslint-jsdoc-repro/node_modules/eslint-plugin-jsdoc/dist/iterateJsdoc.js:539:3)
at /Users/daviduzumeri/Documents/GitHub/ts-eslint-jsdoc-repro/node_modules/eslint-plugin-jsdoc/dist/iterateJsdoc.js:578:7
at Array.forEach (
at callIterator (/Users/daviduzumeri/Documents/GitHub/ts-eslint-jsdoc-repro/node_modules/eslint-plugin-jsdoc/dist/iterateJsdoc.js:573:16)
at *:not(Program) (/Users/daviduzumeri/Documents/GitHub/ts-eslint-jsdoc-repro/node_modules/eslint-plugin-jsdoc/dist/iterateJsdoc.js:626:11)
at /Users/daviduzumeri/Documents/GitHub/ts-eslint-jsdoc-repro/node_modules/eslint/lib/linter/safe-emitter.js:45:58
at Array.forEach (
at Object.emit (/Users/daviduzumeri/Documents/GitHub/ts-eslint-jsdoc-repro/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
at NodeEventGenerator.applySelector (/Users/daviduzumeri/Documents/GitHub/ts-eslint-jsdoc-repro/node_modules/eslint/lib/linter/node-event-generator.js:254:26)
error Command failed with exit code 2.
```
Simply using eslint-plugin-jsdoc and @typescript-eslint/parser in tandem causes the issue. I've created a repo that reproduces the issue easily here: https://github.com/daviduzumeri/ts-eslint-jsdoc-repro
eslint-plugin-jsdoc version: 30.3.0@typescript-eslint/parser version: 4.0.1:tada: This issue has been resolved in version 30.3.1 :tada:
The release is available on:
Your semantic-release bot :package::rocket:
Thank you for the excellent report.
For some reason, I could not replicate this within eslint-plugin-jsdoc itself (against @typescript-eslint/parser 4.0.1).
However, even if this weren't causing an issue for others, it is of course better to avoid reliance on pseudo-private variables, so I've changed the method of detecting modules which should I think address your issue.
(FWIW, the previous approach, while perhaps inaccurate in some edge scenarios in relying on a property that derives from globalReturn, nevertheless effectively helped find the Node environment (which uses globalReturn). But the current way should be superior anyways.)
@gajus I've tested this with eslint-plugin-jsdoc#30.6.2 and @typescript-eslint/parser#4.0.1 and I get the same problem described in this issue.
If you are testing in a linting IDE (like Atom), did you restart the IDE after installing those versions?
If it is still recurring, please provide your exact error... I really don't see how that could be possible though if your linting tool is using a fresh copy of those versions.
Most helpful comment
:tada: This issue has been resolved in version 30.3.1 :tada:
The release is available on:
Your semantic-release bot :package::rocket: