ESLint throws some errors:
error Parsing error: The keyword 'import' is reserved
or, when using JSX:
error Parsing error: Unexpected token <
Per default, ESLint defaults to ES5 and doesn’t understand the keywords import
or const
.
You have to configure ESLint to use the correct parser options.
Here’s an example that worked for me with React and Prettier. I specified the parser and also the parser-options.
.eslintrc
:
{
"parser": "babel-eslint",
"parserOptions": {
"sourceType": "module",
"ecmaFeatures": {
"jsx": true,
"modules": true
}
},
"plugins": ["prettier"],
"extends": ["prettier"],
"rules": {
"prettier/prettier": "error"
}
}