Skip to content

Commit

Permalink
fix import() to work with no-cycle
Browse files Browse the repository at this point in the history
  • Loading branch information
vikr01 committed Oct 22, 2018
1 parent 19f7442 commit e942dff
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
6 changes: 1 addition & 5 deletions src/rules/no-cycle.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,10 @@ module.exports = {
function checkSourceValue(sourceNode, importer) {
const imported = Exports.get(sourceNode.value, context)

if (sourceNode.parent && sourceNode.parent.importKind === 'type') {
if (importer.importKind === 'type') {
return // no Flow import resolution
}

if (sourceNode._babelType === 'Literal') {
return // no Flow import resolution, workaround for ESLint < 5.x
}

if (imported == null) {
return // no-unresolved territory
}
Expand Down
25 changes: 15 additions & 10 deletions tests/src/rules/no-cycle.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,21 @@ ruleTester.run('no-cycle', rule, {
code: 'import { bar } from "./depth-three-indirect"',
errors: [error(`Dependency cycle via ./depth-two:1=>./depth-one:1`)],
}),
// test({
// code: 'import("./depth-three-star")',
// errors: [error(`Dependency cycle via ./depth-two:1=>./depth-one:1`)],
// parser: 'babel-eslint',
// }),
// test({
// code: 'import("./depth-three-indirect")',
// errors: [error(`Dependency cycle via ./depth-two:1=>./depth-one:1`)],
// parser: 'babel-eslint',
// }),
test({
code: 'import { bar } from "./depth-three-indirect"',
errors: [error(`Dependency cycle via ./depth-two:1=>./depth-one:1`)],
parser: 'babel-eslint'
}),
test({
code: 'import("./depth-three-star")',
errors: [error(`Dependency cycle via ./depth-two:1=>./depth-one:1`)],
parser: 'babel-eslint',
}),
test({
code: 'import("./depth-three-indirect")',
errors: [error(`Dependency cycle via ./depth-two:1=>./depth-one:1`)],
parser: 'babel-eslint',
}),
],
})
// })

0 comments on commit e942dff

Please sign in to comment.