Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: TypeError: Cannot read property 'get' of undefined #1844

Open
pahan35 opened this issue Jul 2, 2020 · 5 comments
Open

bug: TypeError: Cannot read property 'get' of undefined #1844

pahan35 opened this issue Jul 2, 2020 · 5 comments

Comments

@pahan35
Copy link

pahan35 commented Jul 2, 2020

Originally discovered at https://youtrack.jetbrains.com/issue/WEB-45210

How to reproduce?

  1. Take the repo https://github.com/pahan35/web-ui-boilerplate
  2. 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
image

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

Recorded example

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

@ljharb
Copy link
Member

ljharb commented Jul 3, 2020

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.

@pahan35
Copy link
Author

pahan35 commented Jul 3, 2020

There is also a problem with Visual Studio Code

Recorded example

However, it's less critical since it doesn't lead to problems with other rules.

@pahan35
Copy link
Author

pahan35 commented Jul 4, 2020

Originally reported problem with creating a new file also is easily reproducible in VS Code

Recorded example

The only difference here, that others lint warnings work here, but import/no-unused-modules produces false-positive warning

@ljharb
Copy link
Member

ljharb commented Jul 4, 2020

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.

@Brageanth
Copy link

Same here on neovim, could you solve it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants