{"id":13625835,"url":"https://github.com/uhyo/eslint-plugin-import-access","last_synced_at":"2025-05-14T20:09:05.323Z","repository":{"id":45068208,"uuid":"379661674","full_name":"uhyo/eslint-plugin-import-access","owner":"uhyo","description":null,"archived":false,"fork":false,"pushed_at":"2025-05-14T13:52:37.000Z","size":782,"stargazers_count":391,"open_issues_count":9,"forks_count":10,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-05-14T14:41:37.547Z","etag":null,"topics":["eslint","eslint-plugin"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/eslint-plugin-import-access","language":"TypeScript","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/uhyo.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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-06-23T16:12:29.000Z","updated_at":"2025-05-14T13:52:39.000Z","dependencies_parsed_at":"2024-01-14T08:14:41.785Z","dependency_job_id":"1160f168-9a71-4488-ba03-7c2f5dde4728","html_url":"https://github.com/uhyo/eslint-plugin-import-access","commit_stats":{"total_commits":119,"total_committers":7,"mean_commits":17.0,"dds":0.3529411764705882,"last_synced_commit":"bd6f6e48970cd8c728ebb7ce1ded4b7de3eae431"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uhyo%2Feslint-plugin-import-access","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uhyo%2Feslint-plugin-import-access/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uhyo%2Feslint-plugin-import-access/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uhyo%2Feslint-plugin-import-access/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/uhyo","download_url":"https://codeload.github.com/uhyo/eslint-plugin-import-access/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254179903,"owners_count":22027884,"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-01T21:02:03.387Z","updated_at":"2025-05-14T20:09:05.282Z","avatar_url":"https://github.com/uhyo.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# eslint-plugin-import-access\n\n## What?\n\nThis package provides a [typescript-eslint](https://github.com/typescript-eslint/typescript-eslint) rule that restricts importing variables marked as `@package` from a file outside the same directory. Also, this package serves as a TypeScript Language Service Plugin that prevents auto-completion of such imports.\n\n![Illustration of how `@package` works.](./docs/images/concept.png)\n\n## Why?\n\nThe largest encapsulation unit available for a TypeScript project is a file. That is, variables not exported from a file is only visible to code in the same file. Once a variable is exported, it is visible from the entire project.\n\nSometimes this is insufficient. A rational effort for proper encapsulation may result in a large file that is hard to maintain.\n\nThis package solves this problem by providing a new directory-level layer and enabling a “package-private” export that is only visible to files in the same directory.\n\n## Installation\n\n```sh\nnpm i -D eslint-plugin-import-access\n```\n\nDepending on how you configure ESLint, use either Flat Config or eslintrc to configure eslint-plugin-import-access.\n\nAlso, you can enable the TypeScript Language Service Plugin by adding it to the `plugins` array in `tsconfig.json`.\n\n### Flat Config\n\nIn **eslint.config.js**:\n\n```js\nimport typescriptEslintParser from \"@typescript-eslint/parser\";\nimport importAccess from \"eslint-plugin-import-access/flat-config\";\n\nexport default [\n  // other settings...\n  {\n    // set up typescript-eslint\n    languageOptions: {\n      parser: typescriptEslintParser,\n      parserOptions: {\n        project: true,\n        sourceType: \"module\",\n      },\n    },\n  },\n  {\n    plugins: {\n      \"import-access\": importAccess,\n    },\n  },\n  {\n    rules: {\n      \"import-access/jsdoc\": [\"error\"],\n    },\n  },\n];\n```\n\n_Note: currently you need to import the plugin from the `/flat-config` subpath. In a future version, this will be simplified._\n\n### eslintrc\n\nIn **.eslintrc.js**:\n\n```js\n  // set up typescript-eslint\n  \"parser\": \"@typescript-eslint/parser\",\n  \"parserOptions\": {\n    \"project\": true,\n    \"sourceType\": \"module\"\n  },\n  \"plugins\": [\n    \"import-access\",\n    // ...\n  ],\n  \"rules\": {\n    \"import-access/jsdoc\": [\"error\"],\n  }\n```\n\n### TypeScript Language Service Plugin\n\nIn **tsconfig.json**:\n\n```json\n{\n  \"compilerOptions\": {\n    // ...\n    \"plugins\": [\n      // ...\n      {\n        \"name\": \"eslint-plugin-import-access\"\n      }\n    ]\n  }\n}\n```\n\n_Note: to enable TypeScript language service plugins installed locally, you must use TypeScript in `node_modules`, not the one bundled with VSCode._\n\n## Example\n\n```ts\n// ----- sub/foo.ts -----\n\n/**\n * @package\n */\nexport const fooPackageVariable = \"I am package-private export\";\n\n// ----- sub/bar.ts -----\n// This is correct because foo.ts is in the same directory\nimport { fooPackageVariable } from \"./foo\";\n\n// ----- baz.ts -----\n// This is INCORRECT because package-private exports\n// cannot be imported from outside the sub directory\nimport { fooPackageVariable } from \"./sub/foo\";\n```\n\n## Rule References\n\n- [import-access/jsdoc](./docs/rule-jsdoc.md)\n\n- [Language Service Plugin](./docs/ts-server.md)\n\n## Contributing\n\nWelcome\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuhyo%2Feslint-plugin-import-access","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fuhyo%2Feslint-plugin-import-access","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuhyo%2Feslint-plugin-import-access/lists"}