Bug: You have used a rule which requires parserServices to be generated. You must therefore provide… – vuejs/vue-eslint-parser

I tried adding an ESLint rule:

"@typescript-eslint/no-unsafe-return": "error"

When I now run npm run lint, I get:

eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --ignore-path .gitignore

Oops! Something went wrong! :(

ESLint: 8.23.1

Error: Error while loading rule '@typescript-eslint/no-unsafe-return': You have used a rule which requires parserServices to be generated. You must therefore provide a value for the "parserOptions.project" property for @typescript-eslint/parser.

Even when I add the parserOptions.project that points to my tsconfig.json, I still get that error:

module.exports = {
    "root": true,
    "extends": [
        "plugin:vue/vue3-essential",
        "eslint:recommended",
        "@vue/eslint-config-typescript"
    ],
    "parserOptions": {
        "ecmaVersion": "latest",
        "project": "./tsconfig.json"
    },
    "plugins": ["only-warn"],
    "rules": {
        "vue/multi-word-component-names": "off",
        "curly": ["warn", "all"],
        "semi": ["warn", "always"],
        "@typescript-eslint/no-unsafe-return": "error"
    }
};

It seems to be a vue-specific problem as I am pulling in the eslint parser through vue-eslint-parser.

tsconfig.json looks like this:

{
    "extends": "@vue/tsconfig/tsconfig.web.json",
    "include": [
        "env.d.ts",
        "src/**/*",
        "src/**/*.vue"
    ],
    "exclude": [
        "src/**/__tests__/*"
    ],
    "compilerOptions": {
        "allowJs": true,
        "outDir": "dist",
        "noImplicitAny": true,
        "jsx": "preserve",
        "composite": true,
        "baseUrl": ".",
        "paths": {
            "@/*": [
                "./src/*"
            ]
        }
    },
    "references": [
        {
            "path": "./tsconfig.config.json"
        },
        {
            "path": "./tsconfig.app.json"
        },
        {
            "path": "./tsconfig.vitest.json"
        }
    ]
}

Read more here: Source link