diff --git a/CHANGELOG.md b/CHANGELOG.md index e6995d173..ba7f30845 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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]) @@ -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 @@ -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 diff --git a/src/rules/no-extraneous-dependencies.js b/src/rules/no-extraneous-dependencies.js index 003e7a044..ced0f44b6 100644 --- a/src/rules/no-extraneous-dependencies.js +++ b/src/rules/no-extraneous-dependencies.js @@ -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) diff --git a/tests/src/rules/no-extraneous-dependencies.js b/tests/src/rules/no-extraneous-dependencies.js index b50f9923b..d29f23857 100644 --- a/tests/src/rules/no-extraneous-dependencies.js +++ b/tests/src/rules/no-extraneous-dependencies.js @@ -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({ @@ -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', + }], + }), ], })