{"id":19921,"library":"eslint-plugin-restrict-imports","title":"eslint-plugin-restrict-imports","description":"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.","status":"maintenance","version":"0.0.3","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","eslint","eslintplugin","eslint-plugin"],"install":[{"cmd":"npm install eslint-plugin-restrict-imports","lang":"bash","label":"npm"},{"cmd":"yarn add eslint-plugin-restrict-imports","lang":"bash","label":"yarn"},{"cmd":"pnpm add eslint-plugin-restrict-imports","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency required for plugin functionality","package":"eslint","optional":true}],"imports":[{"note":"ESLint plugin is configured via .eslintrc, not imported directly.","wrong":"import restrictImports from 'eslint-plugin-restrict-imports'","symbol":"plugin","correct":"module.exports = { plugins: ['restrict-imports'] }"},{"note":"Rule name must be fully qualified with plugin prefix. No direct rule export.","wrong":"// Direct import for testing is not supported\nconst rule = require('eslint-plugin-restrict-imports/rules/restrict-imports')","symbol":"rule restrict-imports/restrict-imports","correct":"// In .eslintrc\n\"rules\": {\n  \"restrict-imports/restrict-imports\": [\"error\", {...}]\n}"},{"note":"Configuration is inline in rule options; no separate config export.","wrong":"// Incorrect: using require for config\nconst config = require('eslint-plugin-restrict-imports/config')","symbol":"config","correct":"// .eslintrc configuration object\n{\n  \"plugins\": [\"restrict-imports\"],\n  \"rules\": { \"restrict-imports/restrict-imports\": [\"error\", {...}] }\n}"}],"quickstart":{"code":"// .eslintrc\n{\n  \"plugins\": [\"restrict-imports\"],\n  \"rules\": {\n    \"restrict-imports/restrict-imports\": [\n      \"error\",\n      {\n        \"../../clientA(.*)\": {\n          \"locations\": [\"(.*)/clientB(.*)\"],\n          \"message\": \"Do not import client A in client B\"\n        },\n        \"(.*)/common/(.*)\": {\n          \"locations\": [\"(.*)/client(.*)\"],\n          \"message\": \"Use barrelled import '@common'\"\n        }\n      }\n    ]\n  }\n}\n\n// Run ESLint\n// npx eslint src/","lang":"javascript","description":"Configures eslint-plugin-restrict-imports to ban imports from clientA in clientB and direct common imports in client directories."},"warnings":[{"fix":"Consider using alternative plugins like eslint-plugin-import with no-restricted-paths or eslint-plugin-boundaries.","message":"Plugin version 0.0.3 is no longer maintained; no updates since 2019. May have unresolved bugs.","severity":"gotcha","affected_versions":"0.0.3"},{"fix":"Test regex patterns thoroughly; use tools like regex101.com to validate.","message":"Rule configuration uses regex strings for both import paths and file locations. Improper escaping can cause unexpected behavior.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use eslint-plugin-import with import/no-restricted-paths or eslint-plugin-boundaries for TypeScript projects.","message":"Plugin does not support TypeScript imports or path aliases (e.g., tsconfig paths).","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Remember the rule ID is 'restrict-imports/restrict-imports', not just 'restrict-imports'.","message":"The rule name is redundantly named 'restrict-imports/restrict-imports'. This can cause confusion when configuring.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run npm install eslint-plugin-restrict-imports --save-dev and ensure node_modules contains the plugin.","cause":"Plugin is not installed or ESLint cannot resolve it.","error":"Error: Cannot find module 'eslint-plugin-restrict-imports'"},{"fix":"Ensure the rule value is an array: [\"error\", {...}].","cause":"Rule configuration is not in the correct array format (e.g., missing severity level).","error":"Configuration for rule 'restrict-imports/restrict-imports' is invalid: Expected an array but got something else"},{"fix":"Remove duplicate rule definitions or ensure only one source defines 'restrict-imports/restrict-imports'.","cause":"Plugin is loaded alongside another plugin that defines the same rule.","error":"ESLint: Rules with multiple sources do not have a deterministic order"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}