Skip to content

Commit

Permalink
Merge pull request #1126 from gajus/issue-1098
Browse files Browse the repository at this point in the history
feat: make no-cycle ignore Flow imports (fixes #1098)
  • Loading branch information
ljharb committed Aug 2, 2018
2 parents 5480240 + 3feb54c commit 0336ef9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/rules/no-cycle.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ module.exports = {
function checkSourceValue(sourceNode, importer) {
const imported = Exports.get(sourceNode.value, context)

if (sourceNode.parent && sourceNode.parent.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
4 changes: 4 additions & 0 deletions tests/src/rules/no-cycle.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ ruleTester.run('no-cycle', rule, {
code: 'import { foo } from "./depth-two"',
options: [{ maxDepth: 1 }],
}),
test({
code: 'import type { FooType } from "./depth-one"',
parser: 'babel-eslint',
}),
],
invalid: [
test({
Expand Down

0 comments on commit 0336ef9

Please sign in to comment.