Skip to content

Commit ffe346e

Browse files
[fix] import-js#1049: Add support for to no-extraneous-dependencies
1 parent 112a0bf commit ffe346e

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

Diff for: CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
44
This change log adheres to standards from [Keep a CHANGELOG](http://keepachangelog.com).
55

66
## [Unreleased]
7+
- [`no-extraneous-dependencies`]: Check `export from` ([#1049])
78

89
### Added
910
- [`group-exports`]: make aggregate module exports valid ([#1472], thanks [@atikenny])

Diff for: src/rules/no-extraneous-dependencies.js

+6
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,12 @@ module.exports = {
205205
ImportDeclaration: function (node) {
206206
reportIfMissing(context, deps, depsOptions, node, node.source.value)
207207
},
208+
ExportNamedDeclaration: function (node) {
209+
reportIfMissing(context, deps, depsOptions, node, node.source.value)
210+
},
211+
ExportAllDeclaration: function (node) {
212+
reportIfMissing(context, deps, depsOptions, node, node.source.value)
213+
},
208214
CallExpression: function handleRequires(node) {
209215
if (isStaticRequire(node)) {
210216
reportIfMissing(context, deps, depsOptions, node, node.arguments[0].value)

Diff for: tests/src/rules/no-extraneous-dependencies.js

+16
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ ruleTester.run('no-extraneous-dependencies', rule, {
122122
code: 'import foo from "@generated/foo"',
123123
options: [{packageDir: packageDirBundledDepsRaceCondition}],
124124
}),
125+
test({ code: 'export { foo } from "lodash.cond"' }),
126+
test({ code: 'export * from "lodash.cond"' }),
125127
],
126128
invalid: [
127129
test({
@@ -319,5 +321,19 @@ ruleTester.run('no-extraneous-dependencies', rule, {
319321
options: [{packageDir: packageDirBundledDepsRaceCondition}],
320322
errors: ["'@generated/bar' should be listed in the project's dependencies. Run 'npm i -S @generated/bar' to add it"],
321323
}),
324+
test({
325+
code: 'export { foo } from "not-a-dependency";',
326+
errors: [{
327+
ruleId: 'no-extraneous-dependencies',
328+
message: '\'not-a-dependency\' should be listed in the project\'s dependencies. Run \'npm i -S not-a-dependency\' to add it',
329+
}],
330+
}),
331+
test({
332+
code: 'export * from "not-a-dependency";',
333+
errors: [{
334+
ruleId: 'no-extraneous-dependencies',
335+
message: '\'not-a-dependency\' should be listed in the project\'s dependencies. Run \'npm i -S not-a-dependency\' to add it',
336+
}],
337+
}),
322338
],
323339
})

0 commit comments

Comments
 (0)