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
JavaScript Can't Find Element by Id
Reactjs Setstate() with a Dynamic Key Name
Executing JavaScript from Python
Need to Cancel Click/Mouseup Events When Double-Click Event Detected
Firebase -> Date Order Reverse
Access Denied to Jquery Script on Ie
Function to Convert Timestamp to Human Date in JavaScript
How to Find a Number in a String Using JavaScript
Typescript Recursive Function Composition
Capture Value Out of Query String with Regex
How to Get Class Object's Name as a String in JavaScript
Array.Length Is Zero, But the Array Has Elements in It
Are Dashes Allowed in JavaScript Property Names
Add Event Handler to HTML Element Using JavaScript