From 0453fe65b5f1cfb6b564019f5523bf87b9af86d1 Mon Sep 17 00:00:00 2001 From: Brett Zamir Date: Tue, 28 Mar 2023 08:28:57 -0700 Subject: [PATCH] chore: avoid reporting of flat config rules when single rule requested --- test/rules/index.js | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/test/rules/index.js b/test/rules/index.js index e0d620f3b..9419e48da 100644 --- a/test/rules/index.js +++ b/test/rules/index.js @@ -121,23 +121,25 @@ const main = async () => { ruleTester.run(ruleName, rule, assertions); } - // Catch syntax errors - let flatRuleNames; - try { - flatRuleNames = (await import('./assertions/flatConfig.js')).default; - } catch (error) { - // eslint-disable-next-line no-console -- Reporting back to tester - console.error(error); - return; - } + if (!process.env.npm_config_rule) { + // Catch syntax errors + let flatRuleNames; + try { + flatRuleNames = (await import('./assertions/flatConfig.js')).default; + } catch (error) { + // eslint-disable-next-line no-console -- Reporting back to tester + console.error(error); + return; + } - const fakeRuleTester = new FlatRuleTester(); - for (const [ - ruleName, - assertions, - ] of Object.entries(flatRuleNames)) { - const rule = config.rules[ruleName]; - fakeRuleTester.run(ruleName, rule, assertions); + const fakeRuleTester = new FlatRuleTester(); + for (const [ + ruleName, + assertions, + ] of Object.entries(flatRuleNames)) { + const rule = config.rules[ruleName]; + fakeRuleTester.run(ruleName, rule, assertions); + } } };