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] #1049: Add support for export-from to no-extraneous-dependencies #1550

Merged
merged 1 commit into from Dec 6, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Expand Up @@ -4,6 +4,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
This change log adheres to standards from [Keep a CHANGELOG](http://keepachangelog.com).

## [Unreleased]
- [`no-extraneous-dependencies`]: Check `export from` ([#1049], thanks [@marcusdarmstrong])

### Added
- [`internal-regex`]: regex pattern for marking packages "internal" ([#1491], thanks [@Librazy])
Expand Down Expand Up @@ -691,6 +692,7 @@ for info on changes for earlier releases.
[#1093]: https://github.com/benmosher/eslint-plugin-import/pull/1093
[#1085]: https://github.com/benmosher/eslint-plugin-import/pull/1085
[#1068]: https://github.com/benmosher/eslint-plugin-import/pull/1068
[#1049]: https://github.com/benmosher/eslint-plugin-import/pull/1049
[#1046]: https://github.com/benmosher/eslint-plugin-import/pull/1046
[#944]: https://github.com/benmosher/eslint-plugin-import/pull/944
[#912]: https://github.com/benmosher/eslint-plugin-import/pull/912
Expand Down Expand Up @@ -1022,3 +1024,4 @@ for info on changes for earlier releases.
[@brettz9]: https://github.com/brettz9
[@Taranys]: https://github.com/Taranys
[@maxmalov]: https://github.com/maxmalov
[@marcusdarmstrong]: https://github.com/marcusdarmstrong
6 changes: 6 additions & 0 deletions src/rules/no-extraneous-dependencies.js
Expand Up @@ -205,6 +205,12 @@ module.exports = {
ImportDeclaration: function (node) {
reportIfMissing(context, deps, depsOptions, node, node.source.value)
},
ExportNamedDeclaration: function (node) {
reportIfMissing(context, deps, depsOptions, node, node.source.value)
},
ExportAllDeclaration: function (node) {
reportIfMissing(context, deps, depsOptions, node, node.source.value)
},
CallExpression: function handleRequires(node) {
if (isStaticRequire(node)) {
reportIfMissing(context, deps, depsOptions, node, node.arguments[0].value)
Expand Down
16 changes: 16 additions & 0 deletions tests/src/rules/no-extraneous-dependencies.js
Expand Up @@ -122,6 +122,8 @@ ruleTester.run('no-extraneous-dependencies', rule, {
code: 'import foo from "@generated/foo"',
options: [{packageDir: packageDirBundledDepsRaceCondition}],
}),
test({ code: 'export { foo } from "lodash.cond"' }),
test({ code: 'export * from "lodash.cond"' }),
],
invalid: [
test({
Expand Down Expand Up @@ -319,5 +321,19 @@ ruleTester.run('no-extraneous-dependencies', rule, {
options: [{packageDir: packageDirBundledDepsRaceCondition}],
errors: ["'@generated/bar' should be listed in the project's dependencies. Run 'npm i -S @generated/bar' to add it"],
}),
test({
code: 'export { foo } from "not-a-dependency";',
errors: [{
ruleId: 'no-extraneous-dependencies',
message: '\'not-a-dependency\' should be listed in the project\'s dependencies. Run \'npm i -S not-a-dependency\' to add it',
}],
}),
test({
code: 'export * from "not-a-dependency";',
errors: [{
ruleId: 'no-extraneous-dependencies',
message: '\'not-a-dependency\' should be listed in the project\'s dependencies. Run \'npm i -S not-a-dependency\' to add it',
}],
}),
],
})