Registry / testing / eslint-plugin-import-access

eslint-plugin-import-access

JSON →
library3.1.0jsnpmunverified

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.

npm install eslint-plugin-import-access
INSTALL
IMPORT
SIG · ESLINT-PLUGIN-IMPO
E
eslint-plugin-import-access
testingjavascriptv3.1.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

importAccess (flat config plugin)
import importAccess from 'eslint-plugin-import-access/flat-config'
import importAccess from 'eslint-plugin-import-access'
v3.x requires importing from the /flat-config subpath for flat config. Direct import is only for eslintrc.
Plugin for eslintrc
plugins: ['import-access']
plugins: ['eslint-plugin-import-access']
In eslintrc, the plugin name is 'import-access' (without prefix). The prefix is automatically resolved.
Rule: import-access/jsdoc
"import-access/jsdoc": ["error"]
"import-access/jsdoc": "error"
The rule requires an array with severity and options. String form is invalid.

Full setup of eslint-plugin-import-access with flat config, plus a code example showing valid and invalid package-private imports.

// Install npm i -D eslint-plugin-import-access @typescript-eslint/parser @typescript-eslint/eslint-plugin // eslint.config.js (flat config) import tsParser from '@typescript-eslint/parser'; import importAccess from 'eslint-plugin-import-access/flat-config'; export default [ { languageOptions: { parser: tsParser, parserOptions: { project: true, sourceType: 'module', }, }, }, { plugins: { 'import-access': importAccess, }, }, { rules: { 'import-access/jsdoc': ['error'], }, }, ]; // sub/foo.ts /** @package */ export const secret = 'private'; // sub/bar.ts (valid) import { secret } from './foo'; // baz.ts (invalid) import { secret } from './sub/foo'; // error
Debug
Known issues
breakingv3.0.0 drops support for Node.js <20, TypeScript <5.0, and @typescript-eslint <8.
fix
Upgrade to Node.js >=20, TypeScript >=5.0, and @typescript-eslint >=8.
affects: >=3.0.0
breakingFlat config import path changed: import from 'eslint-plugin-import-access/flat-config' instead of 'eslint-plugin-import-access'.
fix
Update import statement to use '/flat-config' subpath.
affects: >=3.0.0
gotchaThe @package JSDoc annotation is case-sensitive and must be exactly @package. @Package or @package-private will not work.
fix
Use /** @package */ exactly.
affects: *
deprecatedeslintrc configuration style is deprecated; flat config is recommended.
fix
Migrate to flat config using eslint.config.js.
affects: >=3.0.0
gotchaThe TypeScript Language Service Plugin requires using TypeScript from node_modules, not the VSCode bundled version.
fix
Ensure your project uses a local TypeScript installation (e.g., 'npx tsc').
affects: *
Errors
Common errors & fixes
Error: Failed to load plugin 'import-access' declared in '...': Cannot find module 'eslint-plugin-import-access'
The plugin is not installed or not properly resolved in the ESLint configuration.
fix
Run 'npm i -D eslint-plugin-import-access' and ensure it is listed in your dependencies.
Parsing error: ESLint was configured to run on `<tsconfigRootDir>/...` using `parserOptions.project` but was not found.
Missing or incorrect TypeScript project configuration for @typescript-eslint/parser.
fix
Ensure parserOptions.project is set to true or a valid tsconfig.json path, and that the file is included in the project.
Definition for rule 'import-access/jsdoc' was not found.
The plugin is not registered in ESLint's plugins section, or the rule name is misspelled.
fix
Add the plugin to the 'plugins' array in flat config or eslintrc, and use the correct rule name 'import-access/jsdoc'.
The 'import-access/jsdoc' rule requires typed linting.
The rule needs TypeScript type information, but the parser is not set up to provide it.
fix
Enable 'parserOptions.project: true' and ensure the file is included in your tsconfig.
Upgrade
Version history
3.1.0latest on npm
Audit
Dependencies
@typescript-eslint/parserrequiredRequired for type-aware linting; the plugin relies on TypeScript type information to detect @package annotations.
@typescript-eslint/eslint-pluginoptionalOften used alongside for TypeScript ESLint rules, though not a direct dependency.
Agent activity
10 hits · last 30 days
node
10
Resources
eslint-plugin-import-access — npm install eslint-plugin-import-access · libregistry