{"id":19790,"library":"eslint-plugin-import-access","title":"eslint-plugin-import-access","description":"ESLint plugin (v3.1.0) and TypeScript Language Service Plugin that enforces package-private imports via @package JSDoc annotations. The plugin restricts importing variables marked as @package from outside the same directory, providing a directory-level encapsulation layer beyond file-level exports. It requires TypeScript 5.0+, Node.js 20+, and @typescript-eslint/parser 8+. Key differentiators: supports both flat config and eslintrc, offers a language service plugin to prevent auto-completion of non-importable symbols, and is actively maintained with frequent releases.","status":"active","version":"3.1.0","language":"javascript","source_language":"en","source_url":"https://github.com/uhyo/eslint-plugin-import-access","tags":["javascript","eslint","eslintplugin","typescript"],"install":[{"cmd":"npm install eslint-plugin-import-access","lang":"bash","label":"npm"},{"cmd":"yarn add eslint-plugin-import-access","lang":"bash","label":"yarn"},{"cmd":"pnpm add eslint-plugin-import-access","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required for type-aware linting; the plugin relies on TypeScript type information to detect @package annotations.","package":"@typescript-eslint/parser","optional":false},{"reason":"Often used alongside for TypeScript ESLint rules, though not a direct dependency.","package":"@typescript-eslint/eslint-plugin","optional":true}],"imports":[{"note":"v3.x requires importing from the /flat-config subpath for flat config. Direct import is only for eslintrc.","wrong":"import importAccess from 'eslint-plugin-import-access'","symbol":"importAccess (flat config plugin)","correct":"import importAccess from 'eslint-plugin-import-access/flat-config'"},{"note":"In eslintrc, the plugin name is 'import-access' (without prefix). The prefix is automatically resolved.","wrong":"plugins: ['eslint-plugin-import-access']","symbol":"Plugin for eslintrc","correct":"plugins: ['import-access']"},{"note":"The rule requires an array with severity and options. String form is invalid.","wrong":"\"import-access/jsdoc\": \"error\"","symbol":"Rule: import-access/jsdoc","correct":"\"import-access/jsdoc\": [\"error\"]"}],"quickstart":{"code":"// Install\nnpm i -D eslint-plugin-import-access @typescript-eslint/parser @typescript-eslint/eslint-plugin\n\n// eslint.config.js (flat config)\nimport tsParser from '@typescript-eslint/parser';\nimport importAccess from 'eslint-plugin-import-access/flat-config';\n\nexport default [\n  {\n    languageOptions: {\n      parser: tsParser,\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// sub/foo.ts\n/** @package */\nexport const secret = 'private';\n\n// sub/bar.ts (valid)\nimport { secret } from './foo';\n\n// baz.ts (invalid)\nimport { secret } from './sub/foo'; // error\n","lang":"typescript","description":"Full setup of eslint-plugin-import-access with flat config, plus a code example showing valid and invalid package-private imports."},"warnings":[{"fix":"Upgrade to Node.js >=20, TypeScript >=5.0, and @typescript-eslint >=8.","message":"v3.0.0 drops support for Node.js <20, TypeScript <5.0, and @typescript-eslint <8.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Update import statement to use '/flat-config' subpath.","message":"Flat config import path changed: import from 'eslint-plugin-import-access/flat-config' instead of 'eslint-plugin-import-access'.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Use /** @package */ exactly.","message":"The @package JSDoc annotation is case-sensitive and must be exactly @package. @Package or @package-private will not work.","severity":"gotcha","affected_versions":"*"},{"fix":"Migrate to flat config using eslint.config.js.","message":"eslintrc configuration style is deprecated; flat config is recommended.","severity":"deprecated","affected_versions":">=3.0.0"},{"fix":"Ensure your project uses a local TypeScript installation (e.g., 'npx tsc').","message":"The TypeScript Language Service Plugin requires using TypeScript from node_modules, not the VSCode bundled version.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"search_vec":"'/parser':59 '20':54 '5.0':52 '8':60 'access':5 'activ':86 'annot':23 'auto':77 'auto-complet':76 'beyond':44 'complet':78 'config':66 'differenti':62 'directori':36,40 'directory-level':39 'encapsul':42 'enforc':15 'eslint':2,6,58,92 'eslint-plugin-import-access':1 'eslintplugin':93 'eslintrc':68 'export':48 'file':46 'file-level':45 'flat':65 'frequent':89 'import':4,19,27,82 'javascript':91 'jsdoc':22 'key':61 'languag':11,71 'layer':43 'level':41,47 'maintain':87 'mark':29 'node.js':53 'non':81 'non-import':80 'offer':69 'outsid':33 'packag':17,21,31 'package-priv':16 'plugin':3,7,13,25,73 'prevent':75 'privat':18 'provid':37 'releas':90 'requir':50 'restrict':26 'servic':12,72 'support':63 'symbol':83 'typescript':10,51,57,94 'typescript-eslint':56 'v3.1.0':8 'variabl':28 'via':20","created_at":"2026-04-25T11:19:40.073898+00:00","updated_at":"2026-04-25T11:19:40.073898+00:00","problems":[{"fix":"Run 'npm i -D eslint-plugin-import-access' and ensure it is listed in your dependencies.","cause":"The plugin is not installed or not properly resolved in the ESLint configuration.","error":"Error: Failed to load plugin 'import-access' declared in '...': Cannot find module 'eslint-plugin-import-access'"},{"fix":"Ensure parserOptions.project is set to true or a valid tsconfig.json path, and that the file is included in the project.","cause":"Missing or incorrect TypeScript project configuration for @typescript-eslint/parser.","error":"Parsing error: ESLint was configured to run on `<tsconfigRootDir>/...` using `parserOptions.project` but was not found."},{"fix":"Add the plugin to the 'plugins' array in flat config or eslintrc, and use the correct rule name 'import-access/jsdoc'.","cause":"The plugin is not registered in ESLint's plugins section, or the rule name is misspelled.","error":"Definition for rule 'import-access/jsdoc' was not found."},{"fix":"Enable 'parserOptions.project: true' and ensure the file is included in your tsconfig.","cause":"The rule needs TypeScript type information, but the parser is not set up to provide it.","error":"The 'import-access/jsdoc' rule requires typed linting."}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/uhyo/eslint-plugin-import-access","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/eslint-plugin-import-access","openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-24","install_tag":null}}