Skip to content

Commit

Permalink
Fix flow interface imports giving false-negative with named rule
Browse files Browse the repository at this point in the history
This fixes #708 without ignoring all type imports.
  • Loading branch information
futpib committed Jun 23, 2017
1 parent 8101d39 commit 9a06426
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/ExportMap.js
Expand Up @@ -155,7 +155,7 @@ export default class ExportMap {
const d = dep()
// CJS / ignored dependencies won't exist (#717)
if (d == null) return

d.forEach((v, n) =>
n !== 'default' && callback.call(thisArg, v, n, this))
})
Expand Down Expand Up @@ -406,6 +406,7 @@ ExportMap.parse = function (path, content, context) {
case 'FunctionDeclaration':
case 'ClassDeclaration':
case 'TypeAlias': // flowtype with babel-eslint parser
case 'InterfaceDeclaration':
m.namespace.set(n.declaration.id.name, captureDoc(docStyleParsers, n))
break
case 'VariableDeclaration':
Expand Down
4 changes: 4 additions & 0 deletions tests/files/flowtypes.js
Expand Up @@ -6,3 +6,7 @@ export type MyType = {
firstName: string,
lastName: string
};

export interface MyInterface {}

export class MyClass {}
8 changes: 8 additions & 0 deletions tests/src/rules/named.js
Expand Up @@ -72,6 +72,14 @@ ruleTester.run('named', rule, {
code: 'import type { MyType } from "./flowtypes"',
'parser': 'babel-eslint',
}),
test({
code: 'import type { MyInterface } from "./flowtypes"',
'parser': 'babel-eslint',
}),
test({
code: 'import type { MyClass } from "./flowtypes"',
'parser': 'babel-eslint',
}),

// jsnext
test({
Expand Down

0 comments on commit 9a06426

Please sign in to comment.