@@ -15,7 +15,37 @@ export default function createConfig({
1515 extends : configNamesToExtend = [ 'recommended' ] ,
1616 supportedScriptLangs = { ts : true , tsx : false , js : false , jsx : false } ,
1717} : ConfigOptions = { } ) : ConfigArray {
18- const mayHaveJsx = supportedScriptLangs . jsx || supportedScriptLangs . tsx
18+ const mayHaveJsxInSfc = supportedScriptLangs . jsx || supportedScriptLangs . tsx
19+ const needsTypeAwareLinting = configNamesToExtend . some ( name =>
20+ name . endsWith ( '-type-checked' ) ,
21+ )
22+
23+ // Type-aware linting is in conflict with JSX syntax in `.vue` files
24+ // [!NOTE TO MYSELF] There's room for improvement here.
25+ // We could disable type-aware linting *only* for `.vue` files with JSX syntax.
26+ // Then the following error can be changed to a warning.
27+ if ( needsTypeAwareLinting && mayHaveJsxInSfc ) {
28+ throw new Error (
29+ 'Type-aware linting is not supported in Vue SFCs with JSX syntax. ' +
30+ 'Please disable type-aware linting or set `supportedScriptLangs.jsx` ' +
31+ 'and `supportedScriptLangs.tsx` to `false`.' ,
32+ )
33+ }
34+
35+ const noProjectServiceForVue = mayHaveJsxInSfc
36+ const projectServiceConfigs : ConfigArray = [ ]
37+
38+ if ( noProjectServiceForVue ) {
39+ projectServiceConfigs . push ( {
40+ name : 'vue-typescript/project-service-for-vue' ,
41+ files : [ '*.vue' , '**/*.vue' ] ,
42+ languageOptions : {
43+ parserOptions : {
44+ projectService : false ,
45+ } ,
46+ } ,
47+ } )
48+ }
1949
2050 return tseslint . config (
2151 ...configNamesToExtend
@@ -42,21 +72,19 @@ export default function createConfig({
4272 parser : {
4373 // Fallback to espree for js/jsx scripts, as well as SFCs without scripts
4474 // for better performance.
45- 'js' : 'espree' ,
46- ' jsx' : 'espree' ,
75+ js : 'espree' ,
76+ jsx : 'espree' ,
4777
48- 'ts' : tseslintParser ,
49- ' tsx' : tseslintParser ,
78+ ts : tseslintParser ,
79+ tsx : tseslintParser ,
5080
5181 // Leave the template parser unspecified,
5282 // so that it could be determined by `<script lang="...">`
5383 } ,
5484 ecmaFeatures : {
55- jsx : mayHaveJsx ,
85+ jsx : mayHaveJsxInSfc ,
5686 } ,
5787 extraFileExtensions : [ 'vue' ] ,
58- // type-aware linting is in conflict with jsx syntax in `.vue` files
59- projectService : ! mayHaveJsx ,
6088 } ,
6189 } ,
6290 rules : {
@@ -73,5 +101,7 @@ export default function createConfig({
73101 ] ,
74102 } ,
75103 } ,
104+
105+ ...projectServiceConfigs ,
76106 )
77107}
0 commit comments