From 098ef95bfee6cb41324eaa3006e9e7f83d8e014a Mon Sep 17 00:00:00 2001 From: Gabriel Dugny Date: Tue, 27 May 2025 08:29:28 +0200 Subject: [PATCH] fix: slow eslint Signed-off-by: Gabriel Dugny --- .changeset/fluffy-bobcats-tell.md | 5 +++++ packages/eslint-plugin/rules/no-undeclared-imports.js | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 .changeset/fluffy-bobcats-tell.md diff --git a/.changeset/fluffy-bobcats-tell.md b/.changeset/fluffy-bobcats-tell.md new file mode 100644 index 0000000000..41ed20a7ae --- /dev/null +++ b/.changeset/fluffy-bobcats-tell.md @@ -0,0 +1,5 @@ +--- +'@backstage/eslint-plugin': patch +--- + +Fix custom rules package scanning performance. diff --git a/packages/eslint-plugin/rules/no-undeclared-imports.js b/packages/eslint-plugin/rules/no-undeclared-imports.js index b770ded365..17331d2fce 100644 --- a/packages/eslint-plugin/rules/no-undeclared-imports.js +++ b/packages/eslint-plugin/rules/no-undeclared-imports.js @@ -319,6 +319,7 @@ module.exports = { if (importsToAdd.length > 0) { addMissingImports(importsToAdd, packages, localPkg); + packages.clearCache(); // This switches all import directives back to the original import. for (const added of importsToAdd) { context.report({ @@ -336,6 +337,7 @@ module.exports = { removeInlineImports(importsToInline, localPkg); addForwardedInlineImports(importsToInline, localPkg); + packages.clearCache(); for (const inlined of importsToInline) { context.report({ node: inlined.node, @@ -350,8 +352,6 @@ module.exports = { } importsToInline.length = 0; } - - packages.clearCache(); }, ...visitImports(context, (node, imp) => { // We leave checking of type imports to the repo-tools check,