diff --git a/packages/eslint-plugin/src/rules/no-restricted-imports.ts b/packages/eslint-plugin/src/rules/no-restricted-imports.ts index ff2f8d77b4e..fd724c5fc8b 100644 --- a/packages/eslint-plugin/src/rules/no-restricted-imports.ts +++ b/packages/eslint-plugin/src/rules/no-restricted-imports.ts @@ -146,7 +146,13 @@ export default createRule({ typeof restrictedPattern === 'object' && restrictedPattern.allowTypeImports ) { - allowedImportTypeMatchers.push(ignore().add(restrictedPattern.group)); + // Following how ignore is configured in the base rule + allowedImportTypeMatchers.push( + ignore({ + allowRelativePaths: true, + ignoreCase: !restrictedPattern.caseSensitive, + }).add(restrictedPattern.group), + ); } } function isAllowedTypeImportPattern(importSource: string): boolean { diff --git a/packages/eslint-plugin/tests/rules/no-restricted-imports.test.ts b/packages/eslint-plugin/tests/rules/no-restricted-imports.test.ts index 8e4ea58c55a..1758365e37d 100644 --- a/packages/eslint-plugin/tests/rules/no-restricted-imports.test.ts +++ b/packages/eslint-plugin/tests/rules/no-restricted-imports.test.ts @@ -217,6 +217,20 @@ ruleTester.run('no-restricted-imports', rule, { code: "export * from 'foo';", options: ['import1'], }, + { + code: "import type { MyType } from './types';", + options: [ + { + patterns: [ + { + group: ['fail'], + message: "Please do not load from 'fail'.", + allowTypeImports: true, + }, + ], + }, + ], + }, ], invalid: [ { diff --git a/packages/eslint-plugin/typings/eslint-rules.d.ts b/packages/eslint-plugin/typings/eslint-rules.d.ts index 5f6e1412f33..d53ef43a747 100644 --- a/packages/eslint-plugin/typings/eslint-rules.d.ts +++ b/packages/eslint-plugin/typings/eslint-rules.d.ts @@ -905,6 +905,7 @@ declare module 'eslint/lib/rules/no-restricted-imports' { | { group: string[]; message?: string; + caseSensitive?: boolean; // extended allowTypeImports?: boolean; }[];