Skip to content
Draft
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
7 changes: 5 additions & 2 deletions src/ExportMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -533,9 +533,12 @@ ExportMap.parse = function (path, content, context) {
case 'TSTypeAliasDeclaration':
case 'TSInterfaceDeclaration':
case 'TSAbstractClassDeclaration':
case 'TSModuleDeclaration':
m.namespace.set(n.declaration.id.name, captureDoc(source, docStyleParsers, n));
case 'TSModuleDeclaration': {
const meta = captureDoc(docStyleParsers, n);
meta.exportKind = n.exportKind;
m.namespace.set(n.declaration.id.name, meta);
break;
}
case 'VariableDeclaration':
n.declaration.declarations.forEach((d) =>
recursivePatternCapture(d.id,
Expand Down
9 changes: 8 additions & 1 deletion src/rules/named.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,14 @@ module.exports = {
`${im[key].name} not found via ${deepPath}`);
} else {
context.report(im[key],
im[key].name + ' not found in \'' + node.source.value + '\'');
`${im[key].name} not found in '${node.source.value}'`);
}
} else if (node.importKind === 'value') {
const meta = deepLookup.path[deepLookup.path.length - 1].namespace.get(im[key].name);
const wrongType = meta && meta.exportKind !== undefined && meta.exportKind !== 'value';
if (wrongType) {
context.report(im[key],
`${im[key].name} not found in '${node.source.value}'`);
}
}
});
Expand Down
16 changes: 16 additions & 0 deletions tests/src/rules/named.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,22 @@ ruleTester.run('named', rule, {
parser: require.resolve('babel-eslint'),
errors: ["MyMissingClass not found in './flowtypes'"],
}),
test({
code: 'import { MyType } from "./flowtypes"',
parser: require.resolve('babel-eslint'),
errors: [{
message: "MyType not found in './flowtypes'",
type: 'Identifier',
}],
}),
test({
code: 'import type { MissingType } from "./flowtypes"',
parser: require.resolve('babel-eslint'),
errors: [{
message: "MissingType not found in './flowtypes'",
type: 'Identifier',
}],
}),

// jsnext
test({
Expand Down