{"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,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","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,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}