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: Error while loading rule 'react/prefer-stateless-function': Cannot read property 'version' of null Occurred while linting #15646

Closed
1 task
tipleavalentin opened this issue Feb 25, 2022 · 5 comments
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly repro:needed
Projects

Comments

@tipleavalentin
Copy link

Environment

Node version: 16.14.0
npm version: 8.5.2
Local ESLint version: 8.9.0
Global ESLint version: -
Operating System: Windows 11 2H2...527

What parser are you using?

@babel/eslint-parser

What did you do?

console.log('this should get a warning');

What did you expect to happen?

I am expecting eslint to work, throwing warnings and errors where it should.

What actually happened?

Eslint load fails.

Participation

  • I am willing to submit a pull request for this issue.

Additional comments

Error details:
[Info - 16:29:28] ESLint server is starting
[Info - 16:29:28] ESLint server running in node v14.16.0
[Info - 16:29:28] ESLint server is running.
[Info - 16:29:30] ESLint library loaded from: \node_modules\eslint\lib\api.js
[Info - 16:29:31] Error while loading rule 'react/prefer-stateless-function': Cannot read property 'version' of null Occurred while linting AnyJSFile.js

@tipleavalentin tipleavalentin added bug ESLint is working incorrectly repro:needed labels Feb 25, 2022
@eslint-github-bot eslint-github-bot bot added this to Needs Triage in Triage Feb 25, 2022
@tipleavalentin
Copy link
Author

If I remove the rule 'react/prefer-stateless-function' then it moves to "react/no-unused-state" and so on...

@mdjermanovic mdjermanovic moved this from Needs Triage to Triaging in Triage Feb 25, 2022
@mdjermanovic
Copy link
Member

Hi @tipleavalentin, thanks for the issue!

[Info - 16:29:31] Error while loading rule 'react/prefer-stateless-function': Cannot read property 'version' of null Occurred while linting AnyJSFile.js

Can you please run ESLint from the command line and share the output (with the full error stack trace)?

@tipleavalentin
Copy link
Author

Hi @tipleavalentin, thanks for the issue!

[Info - 16:29:31] Error while loading rule 'react/prefer-stateless-function': Cannot read property 'version' of null Occurred while linting AnyJSFile.js

Can you please run ESLint from the command line and share the output (with the full error stack trace)?

Hi!

here it is:
$ npx eslint src_site/pages/HomePage.js

Oops! Something went wrong! :(

ESLint: 8.8.0

TypeError: Error while loading rule 'react/prefer-stateless-function': Cannot read properties of null (reading 'version')
Occurred while linting D:\project\src_site\pages\HomePage.js
at getReactVersionFromContext (D:\project\node_modules\eslint-plugin-react\lib\util\version.js:92:81)
at testReactVersion (D:\project\node_modules\eslint-plugin-react\lib\util\version.js:138:28)
at usedPropTypesInstructions (D:\project\node_modules\eslint-plugin-react\lib\util\usedPropTypes.js:285:36)
at Function.componentRule (D:\project\node_modules\eslint-plugin-react\lib\util\Components.js:1018:37)
at createRuleListeners (D:\project\node_modules\eslint\lib\linter\linter.js:915:21)
at D:\project\node_modules\eslint\lib\linter\linter.js:1097:31
at Array.forEach ()
at runRules (D:\project\node_modules\eslint\lib\linter\linter.js:1034:34)
at Linter._verifyWithoutProcessors (D:\project\node_modules\eslint\lib\linter\linter.js:1382:31)
at Linter._verifyWithConfigArray (D:\project\node_modules\eslint\lib\linter\linter.js:1722:21)

@tipleavalentin
Copy link
Author

So it seems to be an issue on eslint-plugin-react, I'll add the issue there. :)

@tipleavalentin
Copy link
Author

Triage automation moved this from Triaging to Complete Feb 25, 2022
@eslint-github-bot eslint-github-bot bot locked and limited conversation to collaborators Aug 25, 2022
@eslint-github-bot eslint-github-bot bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Aug 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly repro:needed
Projects
Archived in project
Triage
Complete
Development

No branches or pull requests

2 participants