Reputation: 1777
I am getting a weird eslint error when using the spread operator a certain way. I am using it all over my application, but this one line is throwing an error
//this is ok
const sortById = arr => [...arr].sort((a, b) => (parseInt(a.EMPLOYEE_ID) < parseInt(b.EMPLOYEE_ID) ? -1 : 1));
//this is ok
const addStoreType = arr => arr.map(obj => ({ ...obj, STORE_TYPE: typeOfStore(parseInt(obj.DEPARTMENT_NBR))}));
//throws error
const reduceData = arr => arr.map(({ SEQUENCE, TEST_DATE, ADJUSTED_HIRE_DATE, ...rest }) => rest);
This is my eslint config
{
"extends": ["plugin:prettier/recommended"],
"parserOptions": {
"ecmaVersion": 7,
"sourceType": "module"
},
"rules": {
"prettier/prettier": ["error", {
"singleQuote": true
}]
}
}
Upvotes: 0
Views: 1171
Reputation: 665090
"ecmaVersion": 7,
The spread syntax for object literals is part of the language since ES8. It is separate from the spread syntax for array literals and function calls, which was added in ES6.
Upvotes: 2