How do you fix ESLint Parsing error: Unexpected token error
I get this eslint related error: Parsing error: Unexpected token
Here is my eslint config:
{
"extends": "airbnb",
"rules": {
/* JSX */
"react/prop-types": [1, {
"ignore": ["className", "children", "location", "params", "location*"]
}],
"no-param-reassign": [0, {
"props": false
}],
"prefer-rest-params": 1,
"arrow-body-style": 0,
"prefer-template": 0,
"react/prefer-stateless-function": 1,
"react/jsx-no-bind": [0, {
"ignoreRefs": false,
"allowArrowFunctions": false,
"allowBind": true
}],
}
}
What is the problem ?Unexpected token errors in ESLint parsing occur due to incompatibility between your development environment and ESLint's current parsing capabilities with the ongoing changes with JavaScripts ES6~7. Adding the "parserOptions" property to your .eslintrc is no longer enough for particular situations, such as using static contextTypes = { ... } /* react */ in ES6 classes as ESLint is currently unable to parse it on its own. This particular situation will throw an error of: error Parsing error: Unexpected token = The solution is to have ESLint parsed by a compatible parser, i.e @babel/eslint-parser or babel-eslint for babel version below v7. just add: "parser": "@babel/eslint-parser" to your .eslintrc file and run npm install @babel/eslint-parser --save-dev or yarn add -D @babel/eslint-parser. If you use pnpm, you can instead run pnpm add -D @babel/eslint-parser. Please note that as the new Context API starting from React ^16.3 has some important changes, please refer to the official guide.
Get this solution programmatically \u2014 free, no authentication.
curl https://depscope.dev/api/error/ab909d86252c8b99faaa63c42f3b9fd37bb1ce0d0e8aab8ca7cbdeed749f8f73