Skip to content

Commit

Permalink
Fixed flow types imports
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniele Zanni committed May 18, 2018
1 parent ebafcbf commit 513a488
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
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

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

0 comments on commit 513a488

Please sign in to comment.