Skip to content

Bug: [consistent-type-assertions] error when type check is disabled for vue files #8153

@kuoruan

Description

@kuoruan

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have searched for related issues and found none that matched my issue.
  • I have read the FAQ and my problem is not listed.

Playground Link

https://codesandbox.io/p/devbox/delicate-platform-64cd72

Repro Code

error reported when vue files have no `<script lang="ts">` block defined.

npm run lint

ESLint Config

module.exports = {
  root: true,
  extends: [
    "eslint:recommended",
    "plugin:@typescript-eslint/recommended-type-checked",
    "plugin:@typescript-eslint/stylistic-type-checked",
  ],
  parserOptions: {
    project: ["./tsconfig.json", "./tsconfig.node.json"],
  },
  overrides: [
    {
      files: ["*.vue"],
      extends: [
        "plugin:@typescript-eslint/disable-type-checked",
        "plugin:vue/vue3-recommended",
      ],
    },
  ],
};

tsconfig

{
  "compilerOptions": {
    "target": "ESNext",
    "useDefineForClassFields": true,
    "module": "ESNext",
    "moduleResolution": "Node",
    "strict": true,
    "jsx": "preserve",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "esModuleInterop": true,
    "lib": ["ESNext", "DOM"],
    "skipLibCheck": true,
    "noEmit": true
  },
  "include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
}

Expected Result

No error report

Actual Result

Error: Error while loading rule '@typescript-eslint/consistent-type-assertions': 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.
Occurred while linting /workspaces/workspace/src/App.vue
    at getParserServices (/workspaces/workspace/node_modules/@typescript-eslint/utils/dist/eslint-utils/getParserServices.js:21:15)
    at create (/workspaces/workspace/node_modules/@typescript-eslint/eslint-plugin/dist/rules/consistent-type-assertions.js:90:61)
    at Object.create (/workspaces/workspace/node_modules/@typescript-eslint/utils/dist/eslint-utils/RuleCreator.js:38:20)
    at createRuleListeners (/workspaces/workspace/node_modules/eslint/lib/linter/linter.js:895:21)
    at /workspaces/workspace/node_modules/eslint/lib/linter/linter.js:1066:110
    at Array.forEach (<anonymous>)
    at runRules (/workspaces/workspace/node_modules/eslint/lib/linter/linter.js:1003:34)
    at Linter._verifyWithoutProcessors (/workspaces/workspace/node_modules/eslint/lib/linter/linter.js:1355:31)
    at /workspaces/workspace/node_modules/eslint/lib/linter/linter.js:1913:29
    at Array.map (<anonymous>)

Additional Info

#7723

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfix: user errorissue was fixed by correcting the configuration / correcting the codepackage: eslint-pluginIssues related to @typescript-eslint/eslint-pluginvueissues relating to vue support

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions