Skip to content

Commit e553c2f

Browse files
committed
Also check in dev dependencies
1 parent 672af53 commit e553c2f

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

lib/rules/require-dependency.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,20 @@ module.exports.meta = {
1212

1313
module.exports.create = context =>
1414
getImport(context, ({ node, value, path }) => {
15-
const { dependencies, name: currentPackage } = packages.find(
16-
({ location }) => isSubPath(location, context.getFilename()),
15+
const {
16+
dependencies,
17+
devDependencies,
18+
name: currentPackage,
19+
} = packages.find(({ location }) =>
20+
isSubPath(location, context.getFilename()),
1721
);
1822

1923
packages.forEach(({ name, location }) => {
2024
if (
2125
name !== currentPackage &&
2226
(isSubPath(name, value) || isSubPath(location, path)) &&
23-
!Object.keys(dependencies).includes(name)
27+
!Object.keys(dependencies).includes(name) &&
28+
!Object.keys(devDependencies).includes(name)
2429
) {
2530
context.report({
2631
node,

lib/utils.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,14 @@ const isSubPath = (parent, path) => {
99
};
1010

1111
const packages = getPackages(process.cwd()).map(
12-
({ package: { name, dependencies = {} }, location }) => ({
12+
({
13+
package: { name, dependencies = {}, devDependencies = {} },
14+
location,
15+
}) => ({
1316
name,
1417
location,
1518
dependencies,
19+
devDependencies,
1620
}),
1721
);
1822

0 commit comments

Comments
 (0)