Eslint Parsing Error: Unexpected Token

ESLint: Parsing error: Unexpected token :

You need to configure eslint to support typescript as eslint doesn't support it out of the box.
First, you need to install @typescript-eslint/parser and then @typescript-eslint/eslint-plugin.
Once you have installed these, simply update your config as follows-

module.exports = {
'env': {
'browser': true,
'es2021': true,
node: true
},
'extends': [
'eslint:recommended',
'plugin:vue/vue3-essential'
],
'parserOptions': {
'ecmaVersion': 12,
'sourceType': 'module',
parser: '@typescript-eslint/parser'
},
'plugins': [
'vue',
'@typescript-eslint'
],
'rules': {
'vue/multi-word-component-names': 'off',
'vue/object-curly-spacing': [2, 'always'],
'vue/html-closing-bracket-spacing': [2, {
'selfClosingTag': 'always'
}],
'vue/max-attributes-per-line': [2, {
'singleline': {
'max': 1
},
'multiline': {
'max': 1
}
}],
'semi': [2, 'never']
}
}

Parsing Error: unexpected token function on Async Function with a recent Node version

Good morning,
Do you use eslint ?
if yes ->

{
"parserOptions": {
"ecmaVersion": 2017 @see https://eslint.org/docs/latest/user-guide/configuring/language-options
}

eslint parsing error: Unexpected token { in JSX

Eslint on its own is not good enough. First install babel-eslint:

npm install --save-dev babel-eslint

Or with yarn:

yarn add -D babel-eslint

Then add to your .eslintrc file:

"parser": "babel-eslint"

You might want to install eslint-plugin-babel as well, but I believe this is not needed

ESLint - Parse error: Unexpected token semicolon

I think the simplest fix may be to extend the default ESLint rules for TypeScript. Add this block to your .eslintrc:

"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended"
]

How can I fix ESLint Parsing Error for unexpected token /?

I'm not sure what caused the problem, but this solved it for me. I changed the .eslintrc.json to the following:

{
//"env": {
// "browser": true,
// "commonjs": true,
// "es6": true
//},
"extends": [
"standard",
"standard-react"
]
}

I left in my original rules as well.


This problem seems to have multiple different causes, so check out the other answers as well.



Related Topics



Leave a reply



Submit