diff --git a/packages/eslint-plugin/src/rules/no-restricted-imports.ts b/packages/eslint-plugin/src/rules/no-restricted-imports.ts index fd724c5fc8b5..13afc7a895d0 100644 --- a/packages/eslint-plugin/src/rules/no-restricted-imports.ts +++ b/packages/eslint-plugin/src/rules/no-restricted-imports.ts @@ -157,10 +157,8 @@ export default createRule({ } function isAllowedTypeImportPattern(importSource: string): boolean { return ( - allowedImportTypeMatchers.length > 0 && - allowedImportTypeMatchers.every(matcher => { - return matcher.ignores(importSource); - }) + // As long as there's one matching pattern that allows type import + allowedImportTypeMatchers.some(matcher => matcher.ignores(importSource)) ); } 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 1758365e37dc..64f9c91fe7ca 100644 --- a/packages/eslint-plugin/tests/rules/no-restricted-imports.test.ts +++ b/packages/eslint-plugin/tests/rules/no-restricted-imports.test.ts @@ -231,6 +231,28 @@ ruleTester.run('no-restricted-imports', rule, { }, ], }, + { + code: ` +import type { foo } from 'import1/private/bar'; +import type { foo } from 'import2/private/bar'; + `, + options: [ + { + patterns: [ + { + group: ['import1/private/*'], + message: 'usage of import1 private modules not allowed.', + allowTypeImports: true, + }, + { + group: ['import2/private/*'], + message: 'usage of import2 private modules not allowed.', + allowTypeImports: true, + }, + ], + }, + ], + }, ], invalid: [ { pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy