Skip to content

Commit

Permalink
[Tests]: no-cycle: conditionally execute test for dynamic import de…
Browse files Browse the repository at this point in the history
…tection on eslint > 3
  • Loading branch information
GerkinDev committed Mar 7, 2022
1 parent 76eb7d3 commit ffb82c8
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions 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';
Expand All @@ -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'];

Expand Down Expand Up @@ -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`,
Expand Down

0 comments on commit ffb82c8

Please sign in to comment.