Skip to content

Commit

Permalink
Merge pull request #881 from futpib/named-flow-import-interface
Browse files Browse the repository at this point in the history
Fix flow interface imports giving false-negative with `named` rule
  • Loading branch information
ljharb committed Jun 28, 2017
2 parents 56e60e4 + 9a06426 commit 4d561e3
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 4d561e3

Please sign in to comment.