eslint-plugin-strict-dependencies
NOTE: eslint-plugin-strict-dependencies uses tsconfig, tsconfig.json must be present.
Installation
npm install eslint-plugin-strict-dependencies --save-dev
Supported Rules
- strict-dependencies
- module:
string
(Glob or Forward matching string)
- allowReferenceFrom:
string[]
(Glob or Forward matching string)
- Paths of files where target module imports are allowed.
- allowSameModule:
boolean
- Whether or not the target module itself can import on the target module
Usage
.eslintrc:
"plugins": [
"strict-dependencies",
],
"rules": {
"strict-dependencies/strict-dependencies": [
"error",
[
{
"module": "src/components/page",
"allowReferenceFrom": ["src/pages"],
"allowSameModule": false
},
{
"module": "src/components/ui",
"allowReferenceFrom": ["src/components/page"],
"allowSameModule": true
},
{
"module": "next/router",
"allowReferenceFrom": ["src/libs/router.ts"],
"allowSameModule": false
},
],
],
}
License
MIT