eslint-plugin-workspaces
Advanced tools
Comparing version
@@ -12,2 +12,3 @@ 'use strict'; | ||
recommended: { | ||
plugins: ['workspaces'], | ||
rules: { | ||
@@ -20,2 +21,3 @@ 'workspaces/no-relative-imports': 'error', | ||
all: { | ||
plugins: ['workspaces'], | ||
rules: { | ||
@@ -22,0 +24,0 @@ 'workspaces/no-relative-imports': 'error', |
@@ -11,7 +11,10 @@ 'use strict'; | ||
'disallow absolute imports for files that are within the current package', | ||
url: | ||
'https://github.com/joshuajaco/eslint-plugin-workspaces/blob/master/docs/rules/no-absolute-imports.md', | ||
url: 'https://github.com/joshuajaco/eslint-plugin-workspaces/blob/master/docs/rules/no-absolute-imports.md', | ||
}, | ||
fixable: 'code', | ||
schema: [], | ||
messages: { | ||
noAbsoluteImports: | ||
'Absolute imports within the current package are not allowed', | ||
}, | ||
}; | ||
@@ -25,4 +28,3 @@ | ||
node, | ||
message: | ||
'Absolute imports within the current package are not allowed', | ||
messageId: 'noAbsoluteImports', | ||
fix: (fixer) => | ||
@@ -29,0 +31,0 @@ fixer.replaceTextRange( |
@@ -9,4 +9,3 @@ 'use strict'; | ||
description: 'disallow imports of files that are inside another package', | ||
url: | ||
'https://github.com/joshuajaco/eslint-plugin-workspaces/blob/master/docs/rules/no-cross-imports.md', | ||
url: 'https://github.com/joshuajaco/eslint-plugin-workspaces/blob/master/docs/rules/no-cross-imports.md', | ||
}, | ||
@@ -46,18 +45,17 @@ schema: [ | ||
], | ||
messages: { noCrossImports: 'Import from package "{{name}}" is not allowed' }, | ||
}; | ||
const filterSharedPackagesInCurrentScope = ( | ||
{ location: currentLocation }, | ||
scopedEnabled, | ||
scopedSharingFolderName, | ||
) => ({ location }) => { | ||
if (!scopedEnabled) return true; | ||
const locationArray = location.split('/'); | ||
const forbiddenPackageParent = locationArray.slice(0, -1).join('/'); | ||
if (!isSubPath(forbiddenPackageParent, currentLocation)) { | ||
return true; | ||
} | ||
const filterSharedPackagesInCurrentScope = | ||
({ location: currentLocation }, scopedEnabled, scopedSharingFolderName) => | ||
({ location }) => { | ||
if (!scopedEnabled) return true; | ||
const locationArray = location.split('/'); | ||
const forbiddenPackageParent = locationArray.slice(0, -1).join('/'); | ||
if (!isSubPath(forbiddenPackageParent, currentLocation)) { | ||
return true; | ||
} | ||
return locationArray[locationArray.length - 1] !== scopedSharingFolderName; | ||
}; | ||
return locationArray[locationArray.length - 1] !== scopedSharingFolderName; | ||
}; | ||
@@ -91,3 +89,3 @@ module.exports.create = (context) => { | ||
node, | ||
message: 'Import from package "{{name}}" is not allowed', | ||
messageId: 'noCrossImports', | ||
data: { name }, | ||
@@ -94,0 +92,0 @@ }); |
@@ -10,7 +10,9 @@ 'use strict'; | ||
'disallow relative imports of files that are outside of the current package', | ||
url: | ||
'https://github.com/joshuajaco/eslint-plugin-workspaces/blob/master/docs/rules/no-relative-imports.md', | ||
url: 'https://github.com/joshuajaco/eslint-plugin-workspaces/blob/master/docs/rules/no-relative-imports.md', | ||
}, | ||
fixable: 'code', | ||
schema: [], | ||
messages: { | ||
noRelativeImports: 'Relative imports of other packages are not allowed', | ||
}, | ||
}; | ||
@@ -21,6 +23,10 @@ | ||
packages.forEach(({ name, location }) => { | ||
if (name !== currentPackage.name && isSubPath(location, path)) { | ||
if ( | ||
name !== path && | ||
name !== currentPackage.name && | ||
isSubPath(location, path) | ||
) { | ||
context.report({ | ||
node, | ||
message: 'Relative imports of other packages are not allowed', | ||
messageId: 'noRelativeImports', | ||
fix: (fixer) => | ||
@@ -27,0 +33,0 @@ fixer.replaceTextRange( |
@@ -10,6 +10,9 @@ 'use strict'; | ||
'disallow importing from packages that are not listed as a dependency', | ||
url: | ||
'https://github.com/joshuajaco/eslint-plugin-workspaces/blob/master/docs/rules/require-dependency.md', | ||
url: 'https://github.com/joshuajaco/eslint-plugin-workspaces/blob/master/docs/rules/require-dependency.md', | ||
}, | ||
schema: [], | ||
messages: { | ||
requireDependency: | ||
'Importing from another workspace without listing it as a dependency is not allowed', | ||
}, | ||
}; | ||
@@ -30,4 +33,3 @@ | ||
node, | ||
message: | ||
'Importing from another workspace without listing it as a dependency is not allowed', | ||
messageId: 'requireDependency', | ||
}); | ||
@@ -34,0 +36,0 @@ } |
{ | ||
"name": "eslint-plugin-workspaces", | ||
"version": "0.6.2", | ||
"version": "0.6.3-rc1", | ||
"main": "lib/index.js", | ||
@@ -35,3 +35,3 @@ "license": "MIT", | ||
"test": "yarn lint && nyc yarn mocha", | ||
"coverage": "nyc report --reporter=text-lcov | coveralls", | ||
"coverage": "mkdir -p coverage && touch ./coverage/lcov.info && nyc report --reporter=text-lcov > ./coverage/lcov.info", | ||
"lint": "eslint . --ignore-path .gitignore", | ||
@@ -46,12 +46,11 @@ "lint:fix": "yarn lint --fix" | ||
"babel-eslint": "^10.1.0", | ||
"coveralls": "^3.1.0", | ||
"eslint": "^7.7.0", | ||
"eslint-plugin-eslint-plugin": "^2.3.0", | ||
"eslint": "^7.32.0", | ||
"eslint-plugin-eslint-plugin": "^3.6.1", | ||
"eslint-plugin-node": "^11.1.0", | ||
"eslint-plugin-prettier": "^3.1.4", | ||
"mocha": "^8.1.1", | ||
"eslint-plugin-prettier": "^4.0.0", | ||
"mocha": "^9.1.2", | ||
"mock-require": "^3.0.3", | ||
"nyc": "^15.1.0", | ||
"prettier": "^2.0.5" | ||
"prettier": "^2.4.1" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
# eslint-plugin-workspaces [](https://travis-ci.com/joshuajaco/eslint-plugin-workspaces/) [](https://coveralls.io/github/joshuajaco/eslint-plugin-workspaces) [](https://github.com/prettier/prettier) | ||
# eslint-plugin-workspaces [](https://coveralls.io/github/joshuajaco/eslint-plugin-workspaces) [](https://github.com/prettier/prettier) | ||
@@ -3,0 +3,0 @@ An ESLint plugin for enforcing consistent imports across monorepo packages. |
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
15684
1.38%10
-9.09%315
3.28%1
Infinity%