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-prop-types crash when destructuring prevState #825

Closed
daltones opened this issue Sep 13, 2016 · 3 comments
Closed

no-unused-prop-types crash when destructuring prevState #825

daltones opened this issue Sep 13, 2016 · 3 comments
Labels

Comments

@daltones
Copy link
Contributor

If I use destructuring on the second argument of componentDidUpdate, like this:

import React from 'react';

export default class Test extends React.Component {
  componentDidUpdate(prevProps, {state1, state2}) {
  }
}

It gets this error:

Error: Cannot read property 'length' of undefined
TypeError: Cannot read property 'length' of undefined
    at markPropTypesAsUsed ([...]/eslint-plugin-react/lib/rules/no-unused-prop-types.js:622:41)
    at [...]/eslint-plugin-react/lib/rules/no-unused-prop-types.js:893:15
    at Array.forEach (native)
    at EventEmitter.ObjectPattern ([...]/eslint-plugin-react/lib/rules/no-unused-prop-types.js:891:27)
    at emitOne (events.js:95:20)
    at EventEmitter.emit (events.js:182:7)
    at NodeEventGenerator.enterNode ([...]/eslint/lib/util/node-event-generator.js:40:22)
    at CodePathAnalyzer.enterNode ([...]/eslint/lib/code-path-analysis/code-path-analyzer.js:608:23)
    at CommentEventGenerator.enterNode ([...]/eslint/lib/util/comment-event-generator.js:97:23)
    at Controller.enter ([...]/eslint/lib/eslint.js:918:36)
    at Controller.__execute ([...]/estraverse/estraverse.js:397:31)
    at Controller.traverse ([...]/estraverse/estraverse.js:501:28)
    at Controller.Traverser.controller.traverse ([...]/eslint/lib/util/traverser.js:36:33)
    at EventEmitter.module.exports.api.verify ([...]/eslint/lib/eslint.js:915:23)
    at processText ([...]/eslint/lib/cli-engine.js:262:31)
    at CLIEngine.executeOnText ([...]/eslint/lib/cli-engine.js:749:26)

eslint: v3.5.0
eslint-plugin-react: v6.2.1

@milesj
Copy link

milesj commented Sep 13, 2016

Also having this problem.

Cannot read property 'length' of undefined
TypeError: Cannot read property 'length' of undefined
    at markPropTypesAsUsed ([path]/node_modules/eslint-plugin-react/lib/rules/no-unused-prop-types.js:622:41)
    at [path]/node_modules/eslint-plugin-react/lib/rules/no-unused-prop-types.js:893:15
    at Array.forEach (native)
    at EventEmitter.ObjectPattern ([path]/node_modules/eslint-plugin-react/lib/rules/no-unused-prop-types.js:891:27)
    at emitOne (events.js:82:20)
    at EventEmitter.emit (events.js:169:7)
    at NodeEventGenerator.enterNode ([path]/node_modules/eslint/lib/util/node-event-generator.js:40:22)
    at CodePathAnalyzer.enterNode ([path]/node_modules/eslint/lib/code-path-analysis/code-path-analyzer.js:608:23)
    at CommentEventGenerator.enterNode ([path]/node_modules/eslint/lib/util/comment-event-generator.js:97:23)
    at Controller.enter ([path]/node_modules/eslint/lib/eslint.js:918:36)

It fails on this destructuring:

constructor(props, { store }) {
    super(props);
}
"eslint": "^3.5.0",
"eslint-config-airbnb": "^11.1.0",
"eslint-import-resolver-webpack": "^0.6.0",
"eslint-plugin-import": "^1.15.0",
"eslint-plugin-jsx-a11y": "^2.2.2",
"eslint-plugin-react": "^6.2.1",

@EvHaus
Copy link
Collaborator

EvHaus commented Sep 13, 2016

I will look into this today.

EvHaus pushed a commit to EvHaus/eslint-plugin-react that referenced this issue Sep 13, 2016
EvHaus pushed a commit to EvHaus/eslint-plugin-react that referenced this issue Sep 13, 2016
@ljharb ljharb added the bug label Sep 14, 2016
@daltones
Copy link
Contributor Author

Thanks!

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

No branches or pull requests

4 participants