
Product
Introducing Webhook Events for Alert Changes
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.
eslint-plugin-strict-dependencies
Advanced tools
ESlint plugin to define custom module dependency rules.
ESLint plugin to define custom module dependency rules.
NOTE: eslint-plugin-strict-dependencies uses tsconfig, tsconfig.json must be present.
npm install eslint-plugin-strict-dependencies --save-dev
string (Glob or Forward matching string)
string[]
["Suspense"] in import { Suspense } from 'react'string[] (Glob or Forward matching string)
boolean
boolean
import type { Suspense } from 'react'resolveRelativeImport: boolean[default = false]
src/components/aaa.ts
import bbb from './bbb';
resolveRelativeImport = false: Resolve as ./bbb (excluded from lint target)resolveRelativeImport = true: Resolve as src/components/bbb: (included from lint target)pathIndexMap: object[default = null]
0 is used, but you can specify an option to use a value with any index number.tsconfig.json
{
"compilerOptions": {
"*": ["aaa/*", "bbb/*"]
},
}
pathIndexMap = { "*": 1 } : "bbb/*" is used..eslintrc:
"plugins": [
"strict-dependencies",
],
"rules": {
"strict-dependencies/strict-dependencies": [
"error",
[
/**
* Example:
* Limit the dependencies in the following directions
* pages -> components/page -> components/ui
*/
{
"module": "src/components/page",
"allowReferenceFrom": ["src/pages"],
// components/page can't import other components/page
"allowSameModule": false
},
{
"module": "src/components/ui",
"allowReferenceFrom": ["src/components/page"],
// components/ui can import other components/ui
"allowSameModule": true,
// components/ui exclude type import checks
"excludeTypeImportChecks": true
},
/**
* example:
* Disallow to import `next/router` directly. it should always be imported using `libs/router.ts`.
*/
{
"module": "next/router",
"allowReferenceFrom": ["src/libs/router.ts"],
"allowSameModule": false
},
/**
* example:
* Disallow to import Suspense from react. it should always be imported using `libs/react.ts`.
*/
{
"module": "react",
"targetMembers": ["Suspense"],
"allowReferenceFrom": ["src/libs/react.ts"],
"allowSameModule": false
},
],
// options
// {
// "resolveRelativeImport": true
// "pathIndexMap": { "*": 1 }
// }
]
}
MIT
FAQs
ESlint plugin to define custom module dependency rules.
We found that eslint-plugin-strict-dependencies demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.

Product
Socket now scans OpenVSX extensions, giving teams early detection of risky behaviors, hidden capabilities, and supply chain threats in developer tools.

Product
Bringing supply chain security to the next generation of JavaScript package managers