Skip to content

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

@mattparlane

Description

@mattparlane

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>)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions