Skip to content

Commit

Permalink
[Fix] no-extraneous-dependencies: Add support for export from
Browse files Browse the repository at this point in the history
Fixes #1049.
  • Loading branch information
marcusdarmstrong authored and ljharb committed Dec 2, 2019
1 parent 21bf8c6 commit 99b3fbf
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
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',
}],
}),
],
})

0 comments on commit 99b3fbf

Please sign in to comment.