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.
npm install eslint-plugin-workspacesVerified import paths — ran on the pinned version, not inferred.
This shows how to set up eslint-plugin-workspaces with flat config using TypeScript, including the recommended preset and custom rule overrides.
Use 'recommended' and 'all' instead.
Remove scopes configuration; workspace detection is automatic.
For eslintrc use 'plugin:workspaces/legacy-recommended' instead of 'plugin:workspaces/recommended'.
Ensure your workspace configuration is supported (npm, pnpm, yarn, bun, lerna, bolt) and that the root package.json has a 'workspaces' array.
Run `npm install -D eslint-plugin-workspaces`.
Use object syntax: `'workspaces/no-relative-imports': 'error'` is correct; ensure no extra wrapping.
Import the default export: `import workspaces from 'eslint-plugin-workspaces'` and add to plugins.