Registry / testing / eslint-plugin-import-path

eslint-plugin-import-path

JSON →
library0.0.2jsnpmunverified

A tiny ESLint plugin (v0.0.2) for checking import/export paths against forbidden patterns and depth limits. It allows defining regex-based or substring-based blacklists and a maximum parent directory depth. Unlike the more comprehensive eslint-plugin-import, this plugin focuses solely on simple path validation without full module resolution. It is stable enough for development use, but the version 0.0.2 indicates it is still in early stages with no release cadence. Key differentiators: lightweight, no external dependencies beyond ESLint, and supports both regex and substring matching with custom error messages.

npm install eslint-plugin-import-path
INSTALL
IMPORT
SIG · ESLINT-PLUGIN-IMPO
E
eslint-plugin-import-path
testingjavascriptv0.0.2
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.

eslint-plugin-import-path
import 'eslint-plugin-import-path' // no symbols to import, just side effects
import { /index$ } from 'eslint-plugin-import-path'
This is a plugin, not a module with exports. It is loaded via ESLint's plugins configuration, not imported in code.
rules
// In .eslintrc: "rules": { "import-path/forbidden": ["error", ["/index$"]] }
// Trying to import a rule object: const { forbidden } = require('eslint-plugin-import-path');
Rules are configured inside ESLint config, not imported as JavaScript objects.

Installs the plugin and configures two rules: forbidding paths ending in '/index' and limiting parent directory depth to 2.

// Install the plugin npm install eslint-plugin-import-path --save-dev // In your .eslintrc (JSON or JS config): { "plugins": ["import-path"], "rules": { "import-path/forbidden": ["warn", ["/index$"]], "import-path/parent-depth": ["warn", 2] } } // Now ESLint will warn on imports like: import Foo from 'somewhere/index'; // warns: path matches /index$ import Bar from '../../../../../deep'; // warns: depth > 2
Debug
Known issues
gotchaThe 'forbidden' rule uses regex strings; ensure you escape backslashes and special characters appropriately in JSON.
fix
Use double escaping in JSON strings, e.g., 'match': '\\.' for a literal '.'
affects: >=0.0.0
gotchaThe 'forbidden' rule with 'contains' property does simple substring matching, not regex; ensure you use 'match' for regex patterns.
fix
Use 'match' for regex, 'contains' for plain substring.
affects: >=0.0.0
Errors
Common errors & fixes
ESLint couldn't find the plugin "eslint-plugin-import-path".
The plugin is not installed or not listed in the devDependencies.
fix
Run npm install eslint-plugin-import-path --save-dev
Configuration for rule "import-path/forbidden" is invalid: severity should be one of off, warn, error.
The rule severity is set to an invalid value (e.g., 'warning' instead of 'warn').
fix
Use one of: 'off', 'warn', or 'error'.
Upgrade
Version history
0.0.2latest on npm
Audit
Dependencies
eslintrequiredPeer dependency: the plugin operates as an ESLint rule and requires ESLint to function.
Agent activity
2 hits · last 30 days
node
2
Resources
eslint-plugin-import-path — npm install eslint-plugin-import-path · libregistry