ESLint doesn't support spread operator in objects
See original GitHub issueTell us about your environment
- ESLint Version: v4.19.1
- Node Version: v9.10.0
- npm Version: v5.6.0
What parser (default, Babel-ESLint, etc.) are you using? Regular ESLint
Please show your full configuration:
Configuration
{
"env": {
"browser": true,
"commonjs": true,
"es6": true,
"node": true
},
"extends": "eslint:recommended",
"parserOptions": {
"sourceType": "module"
},
"rules": {
"indent": [
"error",
"tab"
],
"linebreak-style": [
"error",
"unix"
],
"quotes": [
"error",
"single"
],
"semi": [
"error",
"always"
]
}
}
What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.
passport.use(new Discord.Strategy({ passReqToCallback: true, ...config.discord }, (req, accessToken, refreshToken, profile, done) => {
r.table('users').insert(profile, { conflict: 'replace' }).run((error) => {
if (error) return done(error, null);
done(null, profile);
});
}));
eslint .
What did you expect to happen? I expected ESLint not to throw an error, as JavaScript allows using the spread operator inside of an object.
What actually happened? Please include the actual, raw output from ESLint. ESLint threw an error at me.
/Users/jacobgunther/Documents/equinoxbot.xyz/src/auth.js
12:63 error Parsing error: Unexpected token ..
Just to let you know, this is what the spread operator is used for:
const object = {
a: 1,
b: 2,
c: 3
};
console.log({ d: 4, ...object }); // { a: 1, b: 2, c: 3, d: 4}
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
rest-spread-spacing - ESLint - Pluggable JavaScript Linter
This rule aims to enforce consistent spacing between rest and spread operators and their expressions. The rule also supports object rest and spread ......
Read more >ESLint equivalents in Elm
disallow using Object.assign with an object literal as the first argument and prefer the use of object spread instead. Elm doesn't support ...
Read more >Airbnb JavaScript Style Guide()
3.8 Prefer the object spread operator over Object.assign to shallow-copy objects. ... 6.5 Do not unnecessarily escape characters in strings. eslint: ...
Read more >Why using object spread with reduce probably a bad idea
Not going too deep into the implementation details of how it works, but when you use the spread operator like the above example, ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi @PassTheMayo, thanks for the issue.
ESLint does support object rest/spread, but you have to opt in via configuration. You can either set your ecmaVersion to 2018 (in parserOptions), or set ecmaFeatures.experimentalObjectRestSpread to true (also in parserOptions, note the need to create an ecmaFeatures object).
Here https://eslint.org/docs/user-guide/configuring it’s specified the following:
Setting ecmaVersion to 9 or 2018 with ESLint 5.0.1 doesn’t help:
provides:
like 9 or 2018 versions are not recognized. What can be the reason?
UPD: Had to add env.eslint like so:
and it helped.