Skip to content

Commit f7498bd

Browse files
ktranDevtools-frontend LUCI CQ
authored andcommitted
[uikit] Allow named imports for ui kit
This updates the es-modules-import to allow for named imports when it comes to the ui kit. Bug: 464124289 Change-Id: Ie62913cd573dfad85855a24d96eb461f626c1de6 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/7204216 Commit-Queue: Simon Zünd <[email protected]> Commit-Queue: Kim-Anh Tran <[email protected]> Auto-Submit: Kim-Anh Tran <[email protected]> Reviewed-by: Simon Zünd <[email protected]>
1 parent 368d4cc commit f7498bd

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

scripts/eslint_rules/lib/es-modules-import.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,13 @@ export default createRule<[], MessageIds>({
343343
return;
344344
}
345345

346+
const currentFileDirectory = path.dirname(filename);
347+
const resolvedAbsoluteImportPath = path.resolve(currentFileDirectory, importPath);
348+
// We explicitly allow destructuring imports from 'front_end/ui/kit/kit.js'.
349+
if (resolvedAbsoluteImportPath.endsWith(path.join('front_end', 'ui', 'kit', 'kit.js'))) {
350+
return;
351+
}
352+
346353
if (importPathForErrorMessage.endsWith('platform/platform.js') &&
347354
nodeSpecifiersSpecialImportsOnly(node.specifiers)) {
348355
/* We allow direct importing of the ls and assertNotNull utility as it's so frequently used. */

scripts/eslint_rules/tests/es-modules-import.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,11 @@ new RuleTester().run('es-modules-import', rule, {
158158
code: 'import { type Exporting } from \'../namespace/Exporting.js\';',
159159
filename: 'front_end/common/Importing.js',
160160
},
161+
// Allow ui kit module named imports
162+
{
163+
code: 'import { Icon } from \'../ui/kit/kit.js\';',
164+
filename: 'front_end/common/Importing.js',
165+
},
161166
],
162167

163168
invalid: [

0 commit comments

Comments
 (0)