From ffb82c899fb1ce8d648b6a61fa88f1c1a496d0ec Mon Sep 17 00:00:00 2001 From: GerkinDev Date: Mon, 7 Mar 2022 10:10:56 +0100 Subject: [PATCH] [Tests]: `no-cycle`: conditionally execute test for dynamic import detection on eslint > 3 --- tests/src/rules/no-cycle.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/src/rules/no-cycle.js b/tests/src/rules/no-cycle.js index d351f75420..22df52bc74 100644 --- a/tests/src/rules/no-cycle.js +++ b/tests/src/rules/no-cycle.js @@ -1,4 +1,4 @@ -import { parsers, test as _test, testFilePath } from '../utils'; +import { parsers, test as _test, testFilePath, testVersion as _testVersion } from '../utils'; import { RuleTester } from 'eslint'; import flatMap from 'array.prototype.flatmap'; @@ -11,6 +11,9 @@ const error = message => ({ message }); const test = def => _test(Object.assign(def, { filename: testFilePath('./cycles/depth-zero.js'), })); +const testVersion = (specifier, t) => _testVersion(specifier, () => Object.assign(t(), { + filename: testFilePath('./cycles/depth-zero.js'), +})); const testDialects = ['es6']; @@ -214,11 +217,11 @@ ruleTester.run('no-cycle', rule, { errors: [error(`Dependency cycle detected.`)], parser: parsers.BABEL_OLD, }), - test({ + testVersion('> 3', () => ({ // Dynamic import is not properly caracterized with eslint < 4 code: `import { foo } from "./${testDialect}/depth-one-dynamic"; // #2265 6`, errors: [error(`Dependency cycle detected.`)], parser: parsers.BABEL_OLD, - }), + })), ].concat(parsers.TS_NEW ? [ test({ code: `function bar(){ return import("./${testDialect}/depth-one"); } // #2265 7`,