I have the following test code
const sth = {
one: 'one',
two: 'two',
three: {
foo: 'foo',
bar: 'bar',
}
};
const state = {
...sth
};
When I run jshint I get the following output
jshint --config .jshintrc test.js
test.js: line 12, col 3, Expected '}' to match '{' from line 11 and instead saw '...'.
test.js: line 12, col 6, Missing semicolon.
test.js: line 12, col 9, Missing semicolon.
test.js: line 12, col 6, Unrecoverable syntax error. (92% scanned).
4 errors
But this is perfectly valid es6 code.
My .jshintrc looks like the following:
{
"curly": false,
"expr": true,
"maxlen": 200,
"esversion": 6
}
Is there a magic setting that I am missing to make this pass?
You are using Object Rest/Spread Properties which is not in ES6 and not even a standard, yet. Currently it is at stage 3.
JSHint does not support Object Rest/Spread Properties, yet. You could replace JSHint with ESLint which has experimental support using experimentalObjectRestSpread
.
Or, of course, you could just ignore these lines as sabareesh suggests. Personally, however, I would advise against it. It pollutes the code base and also disables subsequent linting. I would suggest using ESLint instead as it usually has better support for newer features and seems to be more popular anyway.