-
-
Notifications
You must be signed in to change notification settings - Fork 495
Description
I'm using @typescript-eslint in a TS project with type checking enabled (https://typescript-eslint.io/linting/configs#recommended-requiring-type-checking).
This allows eslint to understand typescript types and make suggestions.
Sadly Vue SFC files are interpreted with type any, they are not correctly loaded.
I found an option for @typescript-eslint/parser to specify a TS program in the options: (https://typescript-eslint.io/architecture/parser/#program). So it should be possible to pass the Volar proxy into @typescript-eslint/parser. This should allow eslint to also run type linting for Vue SFCs.
But sadly I didn't get it to work.
How can I get a TS
programwhich uses Volar and pass it to @typescript-eslint/parser?
This is my eslint config override for '*.vue' files:
...
overrides: [
{
files: ['*.vue'],
extends: [
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'plugin:@typescript-eslint/strict',
],
parser: 'vue-eslint-parser',
parserOptions: {
parser: '@typescript-eslint/parser',
parserOptions: {
extraFileExtensions: ['.vue'],
tsconfigRootDir: __dirname,
project: ['./tsconfig.app.json'],
program: vueTsc.createProgramProxy({
rootNames: ['./src/main.ts'],
options: compilerOptions,
host: ts.createCompilerHost(compilerOptions),
}),
},
}
}
]
...I also tried to add the typescript-vue-plugin as a typescript plugin, to get SFCs to work with eslint type checking, but it also didn't work...