{"id":19986,"library":"eslint-plugin-workspaces","title":"eslint-plugin-workspaces","description":"An ESLint plugin for enforcing consistent imports across monorepo packages. Current stable version is 0.12.1, released in March 2025, with active development. It supports npm, pnpm, yarn, bun, lerna, and bolt workspaces. Key differentiators include automatic workspace detection, fixable rules for no-relative-imports and no-absolute-imports, and presets for both flat config and eslintrc. It provides TypeScript definitions and requires eslint >=8.40.0. The recommended preset enforces rules like no-relative-imports and require-dependency to prevent cross-package import violations.","status":"active","version":"0.12.1","language":"javascript","source_language":"en","source_url":"https://github.com/joshuajaco/eslint-plugin-workspaces","tags":["javascript","eslint","eslintplugin","eslint-plugin","monorepo","packages","workspaces","npm","pnpm","typescript"],"install":[{"cmd":"npm install eslint-plugin-workspaces","lang":"bash","label":"npm"},{"cmd":"yarn add eslint-plugin-workspaces","lang":"bash","label":"yarn"},{"cmd":"pnpm add eslint-plugin-workspaces","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency required for plugin to function","package":"eslint","optional":false}],"imports":[{"note":"ESM default import recommended for flat config; CommonJS require works but may lack TypeScript support","wrong":"const workspaces = require('eslint-plugin-workspaces')","symbol":"default","correct":"import workspaces from 'eslint-plugin-workspaces'"},{"note":"Named export for rules object; available in both ESM and CJS","wrong":"const { rules } = require('eslint-plugin-workspaces')","symbol":"rules","correct":"import { rules } from 'eslint-plugin-workspaces'"},{"note":"configs is a property of the default export, not a separate named export. Access via default import.","wrong":"import { configs } from 'eslint-plugin-workspaces';\nconfigs.recommended","symbol":"configs","correct":"import workspaces from 'eslint-plugin-workspaces';\nworkspaces.configs.recommended"}],"quickstart":{"code":"import workspaces from 'eslint-plugin-workspaces';\n\nexport default [\n  workspaces.configs.recommended,\n  {\n    rules: {\n      'workspaces/no-relative-imports': 'error',\n      'workspaces/require-dependency': 'warn',\n    },\n  },\n];","lang":"typescript","description":"This shows how to set up eslint-plugin-workspaces with flat config using TypeScript, including the recommended preset and custom rule overrides."},"warnings":[{"fix":"Use 'recommended' and 'all' instead.","message":"The presets 'flat/recommended' and 'flat/all' are deprecated since v0.12.0.","severity":"deprecated","affected_versions":">=0.12.0"},{"fix":"Remove scopes configuration; workspace detection is automatic.","message":"The 'scopes' configuration option is deprecated since v0.10.0.","severity":"deprecated","affected_versions":">=0.10.0"},{"fix":"For eslintrc use 'plugin:workspaces/legacy-recommended' instead of 'plugin:workspaces/recommended'.","message":"In v0.12.0, presets were migrated to flat config format. Legacy eslintrc format presets require 'legacy-' prefix.","severity":"breaking","affected_versions":">=0.12.0"},{"fix":"Ensure your workspace configuration is supported (npm, pnpm, yarn, bun, lerna, bolt) and that the root package.json has a 'workspaces' array.","message":"The plugin may not detect workspaces correctly if the package.json does not have a 'workspaces' field or if using an unsupported monorepo tool.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run `npm install -D eslint-plugin-workspaces`.","cause":"Package not installed as dev dependency.","error":"Error: Cannot find module 'eslint-plugin-workspaces'"},{"fix":"Use object syntax: `'workspaces/no-relative-imports': 'error'` is correct; ensure no extra wrapping.","cause":"Using string severity in flat config without proper object syntax.","error":"Configuration for rule \"workspaces/no-relative-imports\" is invalid: Value \"error\" is the wrong type."},{"fix":"Import the default export: `import workspaces from 'eslint-plugin-workspaces'` and add to plugins.","cause":"Plugin not loaded in flat config or incorrect import.","error":"ESLint couldn't find the plugin \"eslint-plugin-workspaces\"."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}