question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Object Spread - Parsing error: Unexpected token ..

See original GitHub issue

Given 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:closed
  • Created 8 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

11reactions
markshustcommented, Jun 30, 2016

For anyone stumbling on this, I prefer this method (think it’s fairly newer):

npm install --save-dev babel-eslint

Then add "parser": "babel-eslint" to eslintConfig in package.json.

11reactions
btmillscommented, Oct 5, 2015

We should have experimental support for this even though it’s ES2016, try enabling experimentalObjectRestSpread in ecmaFeatures.

Read more comments on GitHub >

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

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found