Have you properly set up ESLint for TypeScript?
The error message indicates that it is looking for JavaScript, and TypeScript features like types are not recognized in JS.
To resolve this, make sure to include @typescript-eslint
in your eslint configuration file.
For instance, in .eslintrc.json
(or .eslintrc
, or in YAML format), use a structure similar to the following:
{
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint"
],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"@vue/typescript/recommended"
]
}
Additionally, ensure that you have installed the necessary libraries by running the following command:
yarn add -D eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin @vue/typescript/recommended
(@typescript-eslint/parser
serves as the parser, @typescript-eslint/eslint-plugin
includes standard linting rules for TS, @vue/typescript/recommended
offers Vue-specific rules, and of course, eslint
is the core ESLint library.)