Skip to content

Commit 015cbb9

Browse files
committed
Optimize current workspace checks
1 parent 7d89b50 commit 015cbb9

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

lib/rules/no-cross-imports.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ module.exports.create = (context) => {
106106
workspaces,
107107
context.getFilename(),
108108
({ node, value, path, currentWorkspace }) => {
109+
if (isSubPath(currentWorkspace.location, path)) return;
110+
109111
forbidden
110112
.filter(
111113
filterSharedPackagesInCurrentScope(
@@ -117,7 +119,6 @@ module.exports.create = (context) => {
117119
.forEach(({ package: { name }, location }) => {
118120
if (
119121
name !== currentWorkspace.package.name &&
120-
!isSubPath(currentWorkspace.location, path) &&
121122
(isWorkspacePath(name, value) || isSubPath(location, path))
122123
) {
123124
context.report({

lib/rules/no-relative-imports.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,13 @@ module.exports.create = (context) => {
2323
workspaces,
2424
context.getFilename(),
2525
({ node, path, start, end, currentWorkspace }) => {
26+
if (isSubPath(currentWorkspace.location, path)) return;
27+
2628
workspaces.forEach(({ package: { name }, location }) => {
2729
if (
2830
name !== path &&
2931
name !== currentWorkspace.package.name &&
30-
isSubPath(location, path) &&
31-
!isSubPath(currentWorkspace.location, path)
32+
isSubPath(location, path)
3233
) {
3334
context.report({
3435
node,

lib/rules/require-dependency.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ module.exports.create = (context) => {
2828
workspaces,
2929
context.getFilename(),
3030
({ node, value, path, currentWorkspace }) => {
31+
if (isSubPath(currentWorkspace.location, path)) return;
32+
3133
workspaces.forEach(({ package: { name }, location }) => {
3234
const {
3335
dependencies = {},
@@ -38,7 +40,6 @@ module.exports.create = (context) => {
3840

3941
if (
4042
name !== currentWorkspace.package.name &&
41-
!isSubPath(currentWorkspace.location, path) &&
4243
(isWorkspacePath(name, value) || isSubPath(location, path)) &&
4344
!Object.keys(dependencies).includes(name) &&
4445
!Object.keys(peerDependencies).includes(name) &&

0 commit comments

Comments
 (0)