eslint-plugin-import
eslint-plugin-import copied to clipboard
bug: TypeError: Cannot read property 'get' of undefined
Originally discovered at https://youtrack.jetbrains.com/issue/WEB-45210
How to reproduce?
- Take the repo https://github.com/pahan35/web-ui-boilerplate
- Add new component into
/src/Components/with any code with exports. I used the next one with extra space before braces
import React from 'react'
export default function NewComponent () {
return 'I am new component'
}
What is the expected result
I expect to see the warning from eslint about extra space, etc

What happened instead?
Eslint fails completely for the whole file with error
TypeError: Cannot read property 'get' of undefined
Occurred while linting /Users/p35/PycharmProjects/report-from-prs-web-ui/src/NewComponent.js:3
at checkUsage (/Users/p35/PycharmProjects/report-from-prs-web-ui/node_modules/eslint-plugin-import/lib/rules/no-unused-modules.js:517:33)
at ExportDefaultDeclaration (/Users/p35/PycharmProjects/report-from-prs-web-ui/node_modules/eslint-plugin-import/lib/rules/no-unused-modules.js:895:9)
at /Users/p35/PycharmProjects/report-from-prs-web-ui/node_modules/eslint/lib/linter/safe-emitter.js:45:58
at Array.forEach (<anonymous>)
at Object.emit (/Users/p35/PycharmProjects/report-from-prs-web-ui/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
at NodeEventGenerator.applySelector (/Users/p35/PycharmProjects/report-from-prs-web-ui/node_modules/eslint/lib/linter/node-event-generator.js:254:26)
at NodeEventGenerator.applySelectors (/Users/p35/PycharmProjects/report-from-prs-web-ui/node_modules/eslint/lib/linter/node-event-generator.js:283:22)
at NodeEventGenerator.enterNode (/Users/p35/PycharmProjects/report-from-prs-web-ui/node_modules/eslint/lib/linter/node-event-generator.js:297:14)
at CodePathAnalyzer.enterNode (/Users/p35/PycharmProjects/report-from-prs-web-ui/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js:635:23)
at /Users/p35/PycharmProjects/report-from-prs-web-ui/node_modules/eslint/lib/linter/linter.js:949:32
Process finished with exit code -1
This bug is really critical for me. However, dev from JetBrain's side said that there is something wrong from the plugin side. Please fix it from your side or give advice on how to fix it
I can't reproduce this.
That JetBrains thread points out that there is, in fact, a difference between proper/supported eslint usage - invoking it via the CLI once per process - and keeping alive a dev server.
This plugin maintains some internal caching; specifically, it builds up a module graph of your entire codebase so it can lint across files. This works fine with other IDEs/editors, so that suggests it's an issue with JetBrains' implementation, specifically.
There is also a problem with Visual Studio Code
However, it's less critical since it doesn't lead to problems with other rules.
Originally reported problem with creating a new file also is easily reproducible in VS Code
The only difference here, that others lint warnings work here, but import/no-unused-modules produces false-positive warning
There’s really nothing an eslint plugin can do with something that’s running eslint improperly :-/ there’d need to be some kind of feature in eslint itself to handle caching mechanisms.
Same here on neovim, could you solve it?