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

Fix flow interface imports giving false-negative with named rule #881

Merged
merged 1 commit into from
Jun 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
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: 2 additions & 1 deletion src/ExportMap.js
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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