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

Destructuring in fn arguments warns for prop-types in 4.0.0-rc.0 #443

Closed
lukekarrys opened this issue Feb 14, 2016 · 2 comments
Closed

Destructuring in fn arguments warns for prop-types in 4.0.0-rc.0 #443

lukekarrys opened this issue Feb 14, 2016 · 2 comments

Comments

@lukekarrys
Copy link
Contributor

Here's a minimal example:

const React = require('react');

module.exports = React.createClass({
  method1() {
    // Destructuring warns for
    // 'length' is missing in props validation  react/prop-types
    ['one', 'two', 'three'].forEach(({length}) => {
      console.log(length)
    })
  },

  method2() {
    // This doesnt warn
    ['one', 'two', 'three'].forEach((item) => {
      console.log(item.length)
    })
  }
})

Tested with and without babel-eslint. Here's my eslintrc without babel-eslint:

{
  "parserOptions": {
    "ecmaVersion": 6
  },

  "env": {
    "es6": true
  },

  "plugins": [
    "react"
  ],

  "extends": "plugin:react/recommended"
}

Also heres a gist with all the code: https://gist.github.com/lukekarrys/d3fa81ff63ea0cf1cf3a

@lukekarrys lukekarrys mentioned this issue Feb 14, 2016
7 tasks
@lukekarrys
Copy link
Contributor Author

Looked at this for a little bit, but the best I could do was a failing test. Wasn't sure if this was worth opening a PR since its pretty simple but the failing test is in my fork: https://github.com/lukekarrys/eslint-plugin-react/commit/ca21391849ef99bb70db54e28df6c0fb783ce269

@yannickcr
Copy link
Member

Thanks, I'll have a look.

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

No branches or pull requests

2 participants