{"id":13599453,"url":"https://github.com/knowledge-work/eslint-plugin-strict-dependencies","last_synced_at":"2025-05-15T07:06:10.792Z","repository":{"id":40510609,"uuid":"411604888","full_name":"knowledge-work/eslint-plugin-strict-dependencies","owner":"knowledge-work","description":"ESlint plugin to define custom module dependency rules.","archived":false,"fork":false,"pushed_at":"2025-05-11T22:37:48.000Z","size":637,"stargazers_count":232,"open_issues_count":1,"forks_count":10,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-05-11T23:25:20.163Z","etag":null,"topics":["eslint","eslint-plugin"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/eslint-plugin-strict-dependencies","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/knowledge-work.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-09-29T09:11:54.000Z","updated_at":"2025-05-11T22:37:51.000Z","dependencies_parsed_at":"2023-10-23T20:35:10.342Z","dependency_job_id":"8ae2b6b7-dfdc-418d-b2f1-304bdd78cb72","html_url":"https://github.com/knowledge-work/eslint-plugin-strict-dependencies","commit_stats":{"total_commits":45,"total_committers":8,"mean_commits":5.625,"dds":0.5555555555555556,"last_synced_commit":"3335d01af414b6e1e377881f8d95c462e712f1d3"},"previous_names":[],"tags_count":30,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knowledge-work%2Feslint-plugin-strict-dependencies","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knowledge-work%2Feslint-plugin-strict-dependencies/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knowledge-work%2Feslint-plugin-strict-dependencies/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knowledge-work%2Feslint-plugin-strict-dependencies/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/knowledge-work","download_url":"https://codeload.github.com/knowledge-work/eslint-plugin-strict-dependencies/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254292042,"owners_count":22046426,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["eslint","eslint-plugin"],"created_at":"2024-08-01T17:01:04.372Z","updated_at":"2025-05-15T07:06:05.783Z","avatar_url":"https://github.com/knowledge-work.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# eslint-plugin-strict-dependencies\n\nESLint plugin to define custom module dependency rules.\n\nNOTE: `eslint-plugin-strict-dependencies` uses tsconfig, tsconfig.json must be present.\n\n## Installation\n\n```\nnpm install eslint-plugin-strict-dependencies --save-dev\n```\n\n## Supported Rules\n\n- strict-dependencies\n  - module: `string` (Glob or Forward matching string)\n    - Target module path\n  - targetMembers: `string[]`\n    - Target member name\n    - e.x. `[\"Suspense\"]` in `import { Suspense } from 'react'`\n  - allowReferenceFrom: `string[]` (Glob or Forward matching string)\n    - Paths of files where target module imports are allowed.\n  - allowSameModule: `boolean`\n    - Whether it can be imported by other files in the same directory\n  - excludeTypeImportChecks: `boolean`\n    - Whether to exclude type import checks\n    - e.x. `import type { Suspense } from 'react'`\n\n### Options\n\n- resolveRelativeImport: `boolean[default = false]`\n  - Whether to resolve relative import as in the following example\n  - `src/components/aaa.ts`\n    ```typescript\n    import bbb from './bbb';\n    ```\n     - `resolveRelativeImport = false`: Resolve as `./bbb` (excluded from lint target)\n     - `resolveRelativeImport = true`:  Resolve as `src/components/bbb`: (included from lint target)\n\n- pathIndexMap: `object[default = null]`\n  - In eslint-plugin-strict-dependencies, path alias resolution is performed based on the paths specified in the tsconfig.\n  - 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.\n  - Specify it as in the following example:\n    - `tsconfig.json`\n      ```json\n      {\n        \"compilerOptions\": {\n            \"*\": [\"aaa/*\", \"bbb/*\"]\n          },\n      }\n      ```\n    - `pathIndexMap = { \"*\": 1 } `: `\"bbb/*\"` is used.\n\n## Usage\n\n.eslintrc:\n\n```js\n\"plugins\": [\n  \"strict-dependencies\",\n],\n\"rules\": {\n  \"strict-dependencies/strict-dependencies\": [\n    \"error\",\n    [\n      /**\n       * Example:\n       * Limit the dependencies in the following directions\n       * pages -\u003e components/page -\u003e components/ui\n       */\n      {\n        \"module\": \"src/components/page\",\n        \"allowReferenceFrom\": [\"src/pages\"],\n        // components/page can't import other components/page\n        \"allowSameModule\": false\n      },\n      {\n        \"module\": \"src/components/ui\",\n        \"allowReferenceFrom\": [\"src/components/page\"],\n        // components/ui can import other components/ui\n        \"allowSameModule\": true,\n        // components/ui exclude type import checks\n        \"excludeTypeImportChecks\": true\n      },\n\n      /**\n       * example:\n       * Disallow to import `next/router` directly. it should always be imported using `libs/router.ts`.\n       */\n      {\n        \"module\": \"next/router\",\n        \"allowReferenceFrom\": [\"src/libs/router.ts\"],\n        \"allowSameModule\": false\n      },\n\n      /**\n       * example:\n       * Disallow to import Suspense from react. it should always be imported using `libs/react.ts`.\n       */\n        {\n            \"module\": \"react\",\n            \"targetMembers\": [\"Suspense\"],\n            \"allowReferenceFrom\": [\"src/libs/react.ts\"],\n            \"allowSameModule\": false\n        },\n    ],\n    // options\n    // {\n    //   \"resolveRelativeImport\": true\n    //   \"pathIndexMap\": { \"*\": 1 }\n    // }\n  ]\n}\n\n```\n\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fknowledge-work%2Feslint-plugin-strict-dependencies","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fknowledge-work%2Feslint-plugin-strict-dependencies","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fknowledge-work%2Feslint-plugin-strict-dependencies/lists"}