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

no-unused-state with GDSFP and airbnb plugin causes "Cannot read properties of undefined (reading 'variables')" #3240

Closed
mattparlane opened this issue Mar 11, 2022 · 6 comments · Fixed by #3258

Comments

@mattparlane
Copy link

I have come across this error after a recent upgrade, and it looks like it may be related to 9b227aa. This only happens with the airbnb plugin enabled, which my company is using. If you comment that line out from the .eslintrc.js file, it works fine.

Apologies if this is not the appropriate place for this, I can take it to Airbnb if it's a better fit.

Minimal .eslintrc.js:

module.exports = {
  parser: '@babel/eslint-parser',
  extends: 'airbnb',
  parserOptions: {
    requireConfigFile: false,
  },
};

Minimal test.js:

class Thing extends Component {
  static getDerivedStateFromProps = (nextProps, prevState) => {
  };
};
# ./node_modules/eslint/bin/eslint.js test.js
Oops! Something went wrong! :(

ESLint: 7.32.0

TypeError: Cannot read properties of undefined (reading 'variables')
Occurred while linting /root/test.js:2
    at PropertyDefinition, ClassProperty (/root/node_modules/eslint-plugin-react/lib/rules/no-unused-state.js:373:20)
    at /app/frontend/node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (/app/frontend/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (/app/frontend/node_modules/eslint/lib/linter/node-event-generator.js:293:26)
    at NodeEventGenerator.applySelectors (/app/frontend/node_modules/eslint/lib/linter/node-event-generator.js:322:22)
    at NodeEventGenerator.enterNode (/app/frontend/node_modules/eslint/lib/linter/node-event-generator.js:336:14)
    at CodePathAnalyzer.enterNode (/app/frontend/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js:711:23)
    at /app/frontend/node_modules/eslint/lib/linter/linter.js:960:32
    at Array.forEach (<anonymous>)
@ljharb
Copy link
Member

ljharb commented Mar 11, 2022

Duplicate of #3236, fixed in the next release.

@ljharb ljharb closed this as completed Mar 11, 2022
@mattparlane
Copy link
Author

Thanks! Sorry, I must have missed the other issue.

@ljharb
Copy link
Member

ljharb commented Mar 11, 2022

No worries; I’ll try to cut a release tomorrow.

@WillyLiaoWH
Copy link
Contributor

Still encountered the issue in 7.29.4
The error in #3236 is about node.value.params is undefined. And this issue is caused by scope is undefined in the line below. (reading variables)
https://github.com/yannickcr/eslint-plugin-react/blob/5bc571db4743527d368167738f359dc6168f9b02/lib/rules/no-unused-state.js#L374

WillyLiaoWH added a commit to WillyLiaoWH/eslint-plugin-react that referenced this issue Mar 28, 2022
WillyLiaoWH added a commit to WillyLiaoWH/eslint-plugin-react that referenced this issue Mar 28, 2022
ljharb added a commit to WillyLiaoWH/eslint-plugin-react that referenced this issue Apr 3, 2022
Fixes jsx-eslint#3240.

Co-authored-by: Willy Liao <[email protected]>
Co-authored-by: Jordan Harband <[email protected]>
@cbedwinotalvaro
Copy link

Hello Team, I see that the commit that fix this issue is merged but the last release was on Mar 13. Do we plan to have a new release son? Still encountered the issue in 7.29.4

@ljharb
Copy link
Member

ljharb commented Apr 12, 2022

@cbedwinotalvaro the commit that fixed this issue is in v7.29.4. 4876d54, however, was only merged 2 weeks ago and has not yet been released.

There's no timeline for the next release (as always). I hope I'll have time soon.

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

Successfully merging a pull request may close this issue.

4 participants