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

JSX spread operator not supported? #44

Closed
rocketraman opened this issue Mar 30, 2015 · 6 comments
Closed

JSX spread operator not supported? #44

rocketraman opened this issue Mar 30, 2015 · 6 comments

Comments

@rocketraman
Copy link

eslint 0.18.0 with eslint-react-plugin 2.0.1 returns Unexpected token .. with a JSX spread operator:

spread.js:

let { aprop, ...other } = this.props

.eslintrc:

{
  "env": {
    "browser": true,
    "node": true,
    "es6": true
  },
  "ecmaFeatures": {
    "modules": true,
    "jsx": true,
    "destructuring": true,
    "spread": true,
    "arrowFunctions": true,
    "blockBindings": true
  },
  "plugins": [
    "react"
  ],
  "rules": { // 0=off, 1=warning, 2=error
    // Strict mode
    "strict": [2, "global"],

    // React (eslint-plugin-react)
    "react/jsx-no-undef": 1,
    "react/jsx-uses-react": 1,
    "react/jsx-uses-vars": 1,
    "react/no-did-mount-set-state": 1,
    "react/no-did-update-set-state": 1,
    "react/no-unknown-property": 1,
    "react/prop-types": 1,
    "react/react-in-jsx-scope": 1,
    "react/self-closing-comp": 1,
    "react/wrap-multilines": 1,
  }
}
$ eslint spread.js

spread.js
  1:14  error  Unexpected token ..
$ eslint --version
v0.18.0
$ grep "version" node_modules/eslint-plugin-react/package.json
  "version": "2.0.1",
@yannickcr
Copy link
Member

The error comes from ESLint and not the plugin.

Seems it's parser Espree does not support the spread operator in destructuring assignment.

@rocketraman
Copy link
Author

Seems it's parser Espree does not support the spread operator in destructuring assignment.

Espree is supposed to support both the destructuring and spread operators. I will raise an issue there. Thanks.

@rocketraman
Copy link
Author

FYI: eslint/espree#116

@rocketraman
Copy link
Author

Based on the comments in eslint/espree#116, it doesn't look like espree will be supporting this until the notation is standardized. However babel-eslint does handle this case without issue.

@yannickcr
Copy link
Member

Ok, I try to support the babel-eslint parser (since a lot of React developers are using it) but for now I only run the tests with the default parser Espree. I need to improve this.

Also, since #46 this is fixed, you should be able to fully use the spread operator while destructuring props.

@rocketraman
Copy link
Author

👍

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