diff --git a/config/typescript.js b/config/typescript.js index 52ca9f5b35..ed03fb3f6c 100644 --- a/config/typescript.js +++ b/config/typescript.js @@ -2,7 +2,10 @@ * Adds `.jsx`, `.ts` and `.tsx` as an extension, and enables JSX/TSX parsing. */ -const allExtensions = ['.ts', '.tsx', '.d.ts', '.js', '.jsx']; +// 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 allExtensions = ['.ts', '.tsx', '.js', '.jsx']; module.exports = { @@ -24,6 +27,5 @@ module.exports = { // TypeScript compilation already ensures that named imports exist in the referenced module 'import/named': 'off', - 'import/no-unresolved': 'off', }, }; diff --git a/src/rules/no-unresolved.js b/src/rules/no-unresolved.js index d7212560c4..408b6ff5e6 100644 --- a/src/rules/no-unresolved.js +++ b/src/rules/no-unresolved.js @@ -27,6 +27,11 @@ module.exports = { const options = context.options[0] || {}; function checkSourceValue(source) { + // ignore type-only imports + if (source.parent && source.parent.importKind === 'type') { + return; + } + const caseSensitive = !CASE_SENSITIVE_FS && options.caseSensitive !== false; const caseSensitiveStrict = !CASE_SENSITIVE_FS && options.caseSensitiveStrict;