diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f6591aa52..b4d257403c 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]) ### Added - [`group-exports`]: make aggregate module exports valid ([#1472], thanks [@atikenny]) diff --git a/src/rules/no-extraneous-dependencies.js b/src/rules/no-extraneous-dependencies.js index 1351029cc8..e08b5a3109 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 b50f9923b5..d29f23857f 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', + }], + }), ], })