# eslint-plugin-strict-dependencies

> ESlint plugin to define custom module dependency rules.

Latest version **1.3.36** (published 2026-07-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install eslint-plugin-strict-dependencies
pnpm add eslint-plugin-strict-dependencies
yarn add eslint-plugin-strict-dependencies
bun add eslint-plugin-strict-dependencies
```

## Health

**Score 60/100 (C)** — status: active.

Positive: no vulnerabilities; has provenance; recently updated; high maintenance score.

Warnings: low downloads; no types; no esm support.

## Facts

| | |
|---|---|
| Version | 1.3.36 |
| Published | 2026-07-15 |
| First published | 2021-09-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 11.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 242 |
| Maintainers | deepblue-will, yoshiko, mayahjp, otofu-square, sisisin |
| Keywords | eslint, eslintplugin, lint, rule, check, import, module, directory, strict, dependencies |

## Links

- npm: https://www.npmjs.com/package/eslint-plugin-strict-dependencies
- Repository: https://github.com/knowledge-work/eslint-plugin-strict-dependencies
- Homepage: https://github.com/knowledge-work/eslint-plugin-strict-dependencies#readme
- Issues: https://github.com/knowledge-work/eslint-plugin-strict-dependencies/issues
- npm.io page: https://npm.io/package/eslint-plugin-strict-dependencies

## Dependencies (4)

- [is-glob](https://npm.io/package/is-glob.md) 4.0.3
- [micromatch](https://npm.io/package/micromatch.md) 4.0.8
- [normalize-path](https://npm.io/package/normalize-path.md) 3.0.0
- [require-strip-json-comments](https://npm.io/package/require-strip-json-comments.md) 2.0.0

## Alternatives

- [eslint-plugin-sonarjs](https://npm.io/package/eslint-plugin-sonarjs.md) — 2.9M weekly downloads
- [eslint-config-expo](https://npm.io/package/eslint-config-expo.md) — 1.5M weekly downloads
- [@matter/protocol](https://npm.io/package/@matter/protocol.md) — 63.5K weekly downloads
- [@eventcatalog/linter](https://npm.io/package/@eventcatalog/linter.md) — 24.8K weekly downloads
- [@pandacss/eslint-plugin](https://npm.io/package/@pandacss/eslint-plugin.md) — 18.7K weekly downloads

## Recent versions

- 1.3.36 (latest) — 2026-07-15
- 1.3.35 — 2026-06-15
- 1.3.34 — 2026-05-15
- 1.3.33 — 2026-04-15
- 1.3.32 — 2026-03-15
- 1.3.31 — 2026-02-15
- 1.3.30 — 2026-01-15
- 1.3.29 — 2025-12-15
- 1.3.28 — 2025-11-15
- 1.3.27 — 2025-10-15
- 1.3.26 — 2025-09-25
- 1.3.25 — 2025-09-25
- 1.3.24 — 2025-09-16
- 1.3.23 — 2025-09-15
- 1.3.22 — 2025-08-15
- … 33 more at https://npm.io/package/eslint-plugin-strict-dependencies/versions

## README

# eslint-plugin-strict-dependencies

ESLint plugin to define custom module dependency rules.

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)
    - Target module path
  - targetMembers: `string[]`
    - Target member name
    - e.x. `["Suspense"]` in `import { Suspense } from 'react'`
  - allowReferenceFrom: `string[]` (Glob or Forward matching string)
    - Paths of files where target module imports are allowed.
  - allowSameModule: `boolean`
    - Whether it can be imported by other files in the same directory
  - excludeTypeImportChecks: `boolean`
    - Whether to exclude type import checks
    - e.x. `import type { Suspense } from 'react'`

### Options

- resolveRelativeImport: `boolean[default = false]`
  - Whether to resolve relative import as in the following example
  - `src/components/aaa.ts`
    ```typescript
    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]`
  - In eslint-plugin-strict-dependencies, path alias resolution is performed based on the paths specified in the tsconfig.
  - By default, the value with an index number of `0` is used, but you can specify an option to use a value with any index number.
  - Specify it as in the following example:
    - `tsconfig.json`
      ```json
      {
        "compilerOptions": {
            "*": ["aaa/*", "bbb/*"]
          },
      }
      ```
    - `pathIndexMap = { "*": 1 } `: `"bbb/*"` is used.

## Usage

.eslintrc:

```js
"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 }
    // }
  ]
}

```


## License

MIT

---
_Source: https://npm.io/package/eslint-plugin-strict-dependencies · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
