Skip to content

Commit

Permalink
Merge pull request #1342 from rfermann/1339
Browse files Browse the repository at this point in the history
[fix] `no-unused-modules`: make `import { name as otherName }` work
  • Loading branch information
ljharb committed Apr 24, 2019
2 parents 174afbb + fbe5c30 commit c17dd73
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/ExportMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ ExportMap.parse = function (path, content, context) {
importedSpecifiers.add(specifier.type)
}
if (specifier.type === 'ImportSpecifier') {
importedSpecifiers.add(specifier.local.name)
importedSpecifiers.add(specifier.imported.name)
}
})
}
Expand Down
4 changes: 3 additions & 1 deletion tests/files/no-unused-modules/file-h.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ function h2() {
return 3
}

export { h1, h2 }
const h3 = true

export { h1, h2, h3 }
1 change: 1 addition & 0 deletions tests/files/no-unused-modules/file-p.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import { h3 as h0 } from './file-h'
2 changes: 1 addition & 1 deletion tests/src/rules/no-unused-modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ ruleTester.run('no-unused-modules', rule, {
filename: testFilePath('./no-unused-modules/file-g.js'),
errors: [error(`exported declaration 'g' not used within other modules`)]}),
test({ options: unusedExportsOptions,
code: 'const h1 = 3; function h2() { return 3 }; export { h1, h2 }',
code: 'const h1 = 3; function h2() { return 3 }; const h3 = true; export { h1, h2, h3 }',
filename: testFilePath('./no-unused-modules/file-h.js'),
errors: [error(`exported declaration 'h1' not used within other modules`)]}),
test({ options: unusedExportsOptions,
Expand Down

0 comments on commit c17dd73

Please sign in to comment.