From b251b76a8ddffb99ec038f348c74d97b1777257c Mon Sep 17 00:00:00 2001 From: Mhammed Emrabet Date: Tue, 19 May 2026 17:26:49 +0200 Subject: [PATCH] fix(no-import-all-from-library): allow named imports from forbidden libraries --- eslint-plugin/lib/rules/no-import-all-from-library.js | 8 +++++++- .../tests/lib/rules/no-import-all-from-library.test.js | 6 ++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/eslint-plugin/lib/rules/no-import-all-from-library.js b/eslint-plugin/lib/rules/no-import-all-from-library.js index 3073e0e..af966c1 100644 --- a/eslint-plugin/lib/rules/no-import-all-from-library.js +++ b/eslint-plugin/lib/rules/no-import-all-from-library.js @@ -84,7 +84,13 @@ module.exports = { ImportDeclaration(node) { const currentLibrary = node.source.value; - const forbiddenByName = notAllowedLibraries.includes(currentLibrary); + const forbiddenByName = + notAllowedLibraries.includes(currentLibrary) && + node.specifiers.some( + (specifier) => + specifier.type === "ImportDefaultSpecifier" || + specifier.type === "ImportNamespaceSpecifier", + ); const forbiddenByNamespace = importByNamespaceNotAllowedLibraries.includes(currentLibrary) && node.specifiers.some( diff --git a/eslint-plugin/tests/lib/rules/no-import-all-from-library.test.js b/eslint-plugin/tests/lib/rules/no-import-all-from-library.test.js index e04fc92..f1a44e2 100644 --- a/eslint-plugin/tests/lib/rules/no-import-all-from-library.test.js +++ b/eslint-plugin/tests/lib/rules/no-import-all-from-library.test.js @@ -54,6 +54,12 @@ const tests = { ` import map from 'underscore/modules/map.js'; `, + ` + import { memoize, omitBy, isNil } from 'lodash'; + `, + ` + import { isEmpty } from 'underscore'; + `, ], invalid: [