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

Fixed flow types imports #1106

Merged
merged 3 commits into from
Jun 30, 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
3 changes: 3 additions & 0 deletions src/rules/named.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ module.exports = {
node.specifiers.forEach(function (im) {
if (im.type !== type) return

// ignore type imports
if(im.importKind === 'type') return
Copy link
Member

Choose a reason for hiding this comment

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

space after if?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added


const deepLookup = imports.hasDeep(im[key].name)

if (!deepLookup.found) {
Expand Down
3 changes: 3 additions & 0 deletions tests/files/flowtypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ export type MyType = {
export interface MyInterface {}

export class MyClass {}

export opaque type MyOpaqueType: string = string;

8 changes: 8 additions & 0 deletions tests/src/rules/named.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@ ruleTester.run('named', rule, {
code: 'import type { MissingType } from "./flowtypes"',
parser: 'babel-eslint',
}),
test({
code: 'import type { MyOpaqueType } from "./flowtypes"',
parser: 'babel-eslint',
}),
test({
code: 'import { type MyOpaqueType, MyClass } from "./flowtypes"',
parser: 'babel-eslint',
}),

// TypeScript
test({
Expand Down