Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: make no-cycle ignore Flow imports (fixes #1098) #1126

Merged
merged 3 commits into from
Aug 2, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/rules/no-cycle.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ module.exports = {
function checkSourceValue(sourceNode, importer) {
const imported = Exports.get(sourceNode.value, context)

if (sourceNode.parent.importKind === 'type') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sourceNode.parent seems undefined at times - many tests are failing

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops. Was running tests with --grep option. Fixed.

return // no Flow import resolution
}

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