diff --git a/config/typescript.js b/config/typescript.js index ff7d0795c..197b070e1 100644 --- a/config/typescript.js +++ b/config/typescript.js @@ -7,10 +7,16 @@ // Omit `.d.ts` because 1) TypeScript compilation already confirms that // types are resolved, and 2) it would mask an unresolved // `.ts`/`.tsx`/`.js`/`.jsx` implementation. -const typeScriptExtensions = ['.ts', '.cts', '.mts', '.tsx']; +const typeScriptKeys = ['ts', 'cts', 'mts', 'tsx']; +const typeScriptExtensions = typeScriptKeys.map((key) => `.${key}`); +const typeScriptFiles = typeScriptExtensions.map((ext) => `**/*${ext}`); const allExtensions = [...typeScriptExtensions, '.js', '.jsx']; +const typeScriptRules = Object.fromEntries( + typeScriptKeys.map((key) => [key, 'never']), +); + module.exports = { settings: { 'import/extensions': allExtensions, @@ -31,4 +37,16 @@ module.exports = { // TypeScript compilation already ensures that named imports exist in the referenced module 'import/named': 'off', }, + overrides: [ + { + files: typeScriptFiles, + rules: { + 'import/extensions': [ + 'error', + 'ignorePackages', + typeScriptRules, + ], + }, + }, + ], };