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.

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
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}
);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With