error ESLint Parsing error: Unexpected token:. react js cofiguration settings

Опубликовано: 04 Октябрь 2024
на канале: Tech Nursery
72
0

If ESLint isn’t configured to handle the specific syntax or language you're using (e.g., TypeScript, JSX, or modern ES6+ features), it will throw this error.


JS
--


npm install --save-dev @babel/eslint-parser


Update your .eslintrc or package.json ESLint configuration

{
"parser": "@babel/eslint-parser",
"parserOptions": {
"ecmaVersion": 2021, // Or the latest ECMAScript version you're using
"sourceType": "module" // For ES6 modules
}
}



Typescript
----------

npm install --save-dev @typescript-eslint/parser

Update your .eslintrc
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2021,
"sourceType": "module"
}
}