Registry / testing / eslint-plugin-restrict-imports

eslint-plugin-restrict-imports

JSON →
library0.0.3jsnpmunverified

An ESLint plugin (v0.0.3) for restricting imports from specified paths in specified directories. Useful for enforcing barrel imports or preventing cross-package imports in monorepos. Rules use regex patterns to match import paths and file locations. Extends ESLint's plugin architecture and is compatible with Node >=0.10.0. No active maintenance since 2019, limited documentation, and no TypeScript support.

npm install eslint-plugin-restrict-imports
INSTALL
IMPORT
SIG · ESLINT-PLUGIN-REST
E
eslint-plugin-restrict-imports
testingjavascriptv0.0.3
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.

plugin
module.exports = { plugins: ['restrict-imports'] }
import restrictImports from 'eslint-plugin-restrict-imports'
ESLint plugin is configured via .eslintrc, not imported directly.
rule restrict-imports/restrict-imports
// In .eslintrc "rules": { "restrict-imports/restrict-imports": ["error", {...}] }
// Direct import for testing is not supported const rule = require('eslint-plugin-restrict-imports/rules/restrict-imports')
Rule name must be fully qualified with plugin prefix. No direct rule export.
config
// .eslintrc configuration object { "plugins": ["restrict-imports"], "rules": { "restrict-imports/restrict-imports": ["error", {...}] } }
// Incorrect: using require for config const config = require('eslint-plugin-restrict-imports/config')
Configuration is inline in rule options; no separate config export.

Configures eslint-plugin-restrict-imports to ban imports from clientA in clientB and direct common imports in client directories.

// .eslintrc { "plugins": ["restrict-imports"], "rules": { "restrict-imports/restrict-imports": [ "error", { "../../clientA(.*)": { "locations": ["(.*)/clientB(.*)"], "message": "Do not import client A in client B" }, "(.*)/common/(.*)": { "locations": ["(.*)/client(.*)"], "message": "Use barrelled import '@common'" } } ] } } // Run ESLint // npx eslint src/
Debug
Known issues
gotchaPlugin version 0.0.3 is no longer maintained; no updates since 2019. May have unresolved bugs.
fix
Consider using alternative plugins like eslint-plugin-import with no-restricted-paths or eslint-plugin-boundaries.
affects: 0.0.3
gotchaRule configuration uses regex strings for both import paths and file locations. Improper escaping can cause unexpected behavior.
fix
Test regex patterns thoroughly; use tools like regex101.com to validate.
affects: >=0.0.0
gotchaPlugin does not support TypeScript imports or path aliases (e.g., tsconfig paths).
fix
Use eslint-plugin-import with import/no-restricted-paths or eslint-plugin-boundaries for TypeScript projects.
affects: >=0.0.0
gotchaThe rule name is redundantly named 'restrict-imports/restrict-imports'. This can cause confusion when configuring.
fix
Remember the rule ID is 'restrict-imports/restrict-imports', not just 'restrict-imports'.
affects: >=0.0.0
Errors
Common errors & fixes
Error: Cannot find module 'eslint-plugin-restrict-imports'
Plugin is not installed or ESLint cannot resolve it.
fix
Run npm install eslint-plugin-restrict-imports --save-dev and ensure node_modules contains the plugin.
Configuration for rule 'restrict-imports/restrict-imports' is invalid: Expected an array but got something else
Rule configuration is not in the correct array format (e.g., missing severity level).
fix
Ensure the rule value is an array: ["error", {...}].
ESLint: Rules with multiple sources do not have a deterministic order
Plugin is loaded alongside another plugin that defines the same rule.
fix
Remove duplicate rule definitions or ensure only one source defines 'restrict-imports/restrict-imports'.
Upgrade
Version history
0.0.3latest on npm
Audit
Dependencies
eslintoptionalpeer dependency required for plugin functionality
Agent activity
2 hits · last 30 days
node
2
Resources
eslint-plugin-restrict-imports — npm install eslint-plugin-restrict-imports · libregistry