Skip to content

Commit

Permalink
fix: if no matching files found, skip setting the corresponding config
Browse files Browse the repository at this point in the history
ESLint config's schema requires the `files` key to be a non-empty array

Fixes neanes/neanes#1030 (review)
  • Loading branch information
haoqunjiang committed Oct 15, 2024
1 parent 76c7a96 commit d414c99
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ export default function createConfig({
files: ['**/*.js', '**/*.jsx'],
...tseslint.configs.disableTypeChecked,
},
{
]

if (otherVueFiles.length > 0) {
projectServiceConfigs.push({
name: 'vue-typescript/skip-type-checking-for-vue-files-without-ts',
files: otherVueFiles,
...tseslint.configs.disableTypeChecked,
Expand All @@ -63,9 +66,9 @@ export default function createConfig({
// https://github.com/typescript-eslint/typescript-eslint/issues/4755#issuecomment-1080961338
'@typescript-eslint/consistent-type-imports': 'off',
'@typescript-eslint/prefer-optional-chain': 'off',
}
},
]
},
})
}

const mayHaveJsxInSfc = supportedScriptLangs.jsx || supportedScriptLangs.tsx
const needsTypeAwareLinting = configNamesToExtend.some(
Expand All @@ -87,18 +90,20 @@ export default function createConfig({
},
})

projectServiceConfigs.push({
name: 'vue-typescript/default-project-service-for-vue-files',
files: vueFilesWithScriptTs,
languageOptions: {
parser: vueParser,
parserOptions: {
projectService: true,
parser: tseslint.parser,
extraFileExtensions,
if (vueFilesWithScriptTs.length > 0) {
projectServiceConfigs.push({
name: 'vue-typescript/default-project-service-for-vue-files',
files: vueFilesWithScriptTs,
languageOptions: {
parser: vueParser,
parserOptions: {
projectService: true,
parser: tseslint.parser,
extraFileExtensions,
},
},
},
})
})
}

// Vue's own typing inevitably contains some `any`s, so some of the `no-unsafe-*` rules can't be used.
projectServiceConfigs.push({
Expand Down

0 comments on commit d414c99

Please sign in to comment.