vuejs/eslint-config-typescript

How to prevent @vue/typescript/default-project-service-for-ts-files from being spawned in my ESLint config?

Opened this issue · 1 comments

I am using @vue/eslint-plugin-typescript in the recommended way, here is my config:

export default defineConfigWithVueTs([
// other config objects here
{
    name: "Vue",
    files: ["**/*.vue"],
    extends: [eslintPluginVue.configs["flat/vue2-recommended"], vueTsConfigs.base],
    languageOptions: {
      parser: vueParser,
    },
    rules: {
      "vue/html-indent": [2, 2],
      "vue/max-attributes-per-line": 0,
      "func-call-spacing": 0,
      "vue/singleline-html-element-content-newline": 0,
      "vue/block-lang": 0,

      "@typescript-eslint/consistent-type-imports": [
        2,
        {
          prefer: "type-imports",
          fixStyle: "inline-type-imports",
          disallowTypeAnnotations: false,
        },
      ],
      quotes: [1, "single", { avoidEscape: true }],
    },
  },
]);

However, this is undesirably enabling type-aware linting for my project. This induces too much performance penalty, and I'd like for it to simply be turned off for all files. I determined that extending flat/vue2-recommended and vueTsConfigs.base is the direct culprit that causes typechecking to be enabled.

I can verify the origin of the project service that is being configued by using @eslint/config-inspector:

Image

The last two config blocks applying to a given .ts file are the above.

I could simply add a block to the very end of my config that overrides the project service back to being disabled, but I'd rather understand why it's becoming enabled in the first place, and whether there is a way for this behaviour to be corrected?

thanks :)

// Although some rules don't require type information in theory,
// in practice, when used in vue files, they still throw errors claiming that type information is needed.
// (If I understand correctly, they are the rules that have called `getParserServices` in its implementation.)
// https://github.com/typescript-eslint/typescript-eslint/issues/4755#issuecomment-1080961338
// '@typescript-eslint/consistent-type-assertions' was originally in the list but it has been fixed in
// https://github.com/typescript-eslint/typescript-eslint/pull/9921
export const additionalRulesRequiringParserServices = [
'@typescript-eslint/consistent-type-imports',
'@typescript-eslint/prefer-optional-chain',
]

Actually, it's caused by @typescript-eslint/consistent-type-imports for the reasons stated in the code comments above.
I'm not sure if we need to add this caveat to README…

If this slowdown is intolerable to you, please consider:

  1. Use verbatimModuleSyntax in tsconfig.json to let TypeScript enforce this rule instead.
  2. Use Oxlint or Biome alongside ESLint. They both support this rule and don't require type-aware linting.