Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

experimentalObjectRestSpread not working in ESLint

I'm trying to get ESLint to let me use object rest/spread. Despite my best efforts I keep getting this error:

[js] Property assignment expected.

when I hover over the elipses (...) with the red squiggly.

alt

My .eslinstrc.json looks like this:

{
    "extends": "airbnb",
    "plugins": [
        "react"
    ],
    "parserOptions": {
        "ecmaFeatures": {
            "experimentalObjectRestSpread": true
        }
    },
    "rules": {
        "no-console": 0
    }
}

I know for sure that the prefs are getting read, as the no-console rule, react plugin, and airbnb style guide is working as expected.

To enable object rest/spread, experimentalObjectRestSpread is the key here (haha), and it seems to be working for other people. However it refuses to work for me. I'm at a loss \o/

Update: I'm using Visual Studio Code v1.2.1

like image 884
Titus Avatar asked Jun 16 '16 05:06

Titus


1 Answers

Am I right assuming you are using vscode? I think the error comes from vscode itself. Otherwise the error message would start with [eslint] instead of [js].

It looks like vscode currently doesn't support object spread operators (see: Issue on Github).

You could disable JavaScript validation with the setting { "javascript.validate.enable": false }.

Another alternative would be Object.assign:

const foo = {
  a: 1
};
const bar = 'bar';
const res = Object.assign(
    {},
    foo,
    {bar}
);
like image 130
hmoritz Avatar answered Nov 20 '22 08:11

hmoritz