Parsing error on ESLint
While writing code for review-waiting-list-bot, I came across the following Parsing error
on eslint
.
$ eslint .
/Users/ohbarye/.ghq/github.com/ohbarye/review-waiting-list-bot/src/App.js
19:21 error Parsing error: Unexpected token ..
✖ 1 problem (1 error, 0 warnings)
error Command failed with exit code 1.
The cause seemed due to code using not standardized specifications like below. Yeah, Object Rest/Spread Properties is obviously still at stage 3 (as of 2018-04-30).
const { authors, ...conditions } = { authors: [], owner: '', repo: '' }
Besides, eslint officially says that the default eslint parser SHOULD behave so.
ref: https://github.com/eslint/eslint/issues/6693
babel-eslint
When we'd like to use stage n specification, we need to use babel-eslint.
First, let's add it as a devDependency.
yarn add -D babel-eslint
Then, specify a parser in .eslintrc.json
.
# .eslintrc.json
{
"parser": "babel-eslint",
...
}
Now I could meet the sparkle again. ✨
$ eslint .
✨ Done in 1.45s.
Environment
- yarn v1.6.0
- Node v8.3.0
- eslint v4.4.1
- babel-eslint v8.2.3
Top comments (0)