Object Spread - Parsing error: Unexpected token ..
See original GitHub issueGiven this code:
module.exports = foo;
function foo(defaultsObject, defaultsArray) {
const bar = [1,2,3, ...defaultsArray];
return {bar, ...defaultsObject};
}
which compiles with babel-core version 5.8.25 with no special flags/arguments/options
And this eslint config:
{
"env": {
"es6": true
}
}
I get this error:
/Users/kentcdodds/Desktop/eslint-spread-object/test.js 4:24 error Parsing error: Unexpected token …
With eslint version 1.6.0.
Let me know if you need more information. Thanks!
Issue Analytics
- State:
- Created 8 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
ESLint doesn't support spread operator in objects · Issue #10307
ESLint does support object rest/spread, but you have to opt in via configuration. You can either set your ecmaVersion to 2018 (in parserOptions) ......
Read more >How to enable `eslint` to parse spread operator?
eslint failed to parse spread operator and I got this error 11:18 error Parsing error: Unexpected token .. . The code for above...
Read more >eslint parsing error: unexpected token typescript
Unexpected token errors in ESLint parsing occur due to incompatibility between your development environment and ESLint's current parsing capabilities with the ...
Read more >rest-spread-spacing - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >babel and eslint ERROR object-rest-spread(...) - One More Tech
ERROR in ./src/app.js. Module Error (from ./node_modules/eslint-loader/index.js):. D:\fe-dev\demo-1\src\app.js. 41:7 error Parsing error: Unexpected token .
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
For anyone stumbling on this, I prefer this method (think it’s fairly newer):
Then add
"parser": "babel-eslint"
toeslintConfig
in package.json.We should have experimental support for this even though it’s ES2016, try enabling
experimentalObjectRestSpread
inecmaFeatures
.