james emanon
james emanon

Reputation: 11807

eslint erroring on es6 when .js files, fine for .jsx files

error: Parsing error: Unexpected token ..

My lint gulp task is giving me issues on '.js' files, while '.jsx' are doing fine on ES6 syntax.

Notably, the "..." operator - for spread/rest etc.

Is there a way to get this to work? Here is part of my config. (I tried adding ".js: true", didn't help)

{  
    "parser":"espree",
    "ecmaFeatures":{  
        "modules":true,
        "jsx":true
    },

Upvotes: 0

Views: 142

Answers (1)

btmills
btmills

Reputation: 4542

You probably want to enable the experimentalObjectRestSpread parser option:

{
    "ecmaFeatures": {
        "experimentalObjectRestSpread": true,
        "jsx": true,
        "modules": true
    }
}

Since Espree is already the default parser, you don't need to specify it unless you want to for clarity's sake.

Upvotes: 1

Related Questions