Registry / testing / eslint-plugin-workspaces

eslint-plugin-workspaces

JSON →
library0.12.1jsnpmunverified

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-workspaces
INSTALL
IMPORT
SIG · ESLINT-PLUGIN-WORK
E
eslint-plugin-workspaces
testingjavascriptv0.12.1
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
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 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
✓ import workspaces from 'eslint-plugin-workspaces'
✗ const workspaces = require('eslint-plugin-workspaces')
ESM default import recommended for flat config; CommonJS require works but may lack TypeScript support
rules
✓ import { rules } from 'eslint-plugin-workspaces'
✗ const { rules } = require('eslint-plugin-workspaces')
Named export for rules object; available in both ESM and CJS
configs
✓ import workspaces from 'eslint-plugin-workspaces'; workspaces.configs.recommended
✗ import { configs } from 'eslint-plugin-workspaces'; configs.recommended
configs is a property of the default export, not a separate named export. Access via default import.

This shows how to set up eslint-plugin-workspaces with flat config using TypeScript, including the recommended preset and custom rule overrides.

import workspaces from 'eslint-plugin-workspaces'; export default [ workspaces.configs.recommended, { rules: { 'workspaces/no-relative-imports': 'error', 'workspaces/require-dependency': 'warn', }, }, ];
Debug
Known issues
deprecatedThe presets 'flat/recommended' and 'flat/all' are deprecated since v0.12.0.
fix
Use 'recommended' and 'all' instead.
affects: >=0.12.0
deprecatedThe 'scopes' configuration option is deprecated since v0.10.0.
fix
Remove scopes configuration; workspace detection is automatic.
affects: >=0.10.0
breakingIn v0.12.0, presets were migrated to flat config format. Legacy eslintrc format presets require 'legacy-' prefix.
fix
For eslintrc use 'plugin:workspaces/legacy-recommended' instead of 'plugin:workspaces/recommended'.
affects: >=0.12.0
gotchaThe plugin may not detect workspaces correctly if the package.json does not have a 'workspaces' field or if using an unsupported monorepo tool.
fix
Ensure your workspace configuration is supported (npm, pnpm, yarn, bun, lerna, bolt) and that the root package.json has a 'workspaces' array.
affects: all
Errors
Common errors & fixes
Error: Cannot find module 'eslint-plugin-workspaces'
Package not installed as dev dependency.
fix
Run `npm install -D eslint-plugin-workspaces`.
Configuration for rule "workspaces/no-relative-imports" is invalid: Value "error" is the wrong type.
Using string severity in flat config without proper object syntax.
fix
Use object syntax: `'workspaces/no-relative-imports': 'error'` is correct; ensure no extra wrapping.
ESLint couldn't find the plugin "eslint-plugin-workspaces".
Plugin not loaded in flat config or incorrect import.
fix
Import the default export: `import workspaces from 'eslint-plugin-workspaces'` and add to plugins.
Upgrade
Version history
0.12.1latest on npm
Audit
Dependencies
eslintrequiredpeer dependency required for plugin to function
Agent activity
4 hits · last 30 days
node
4
Resources
eslint-plugin-workspaces — npm install eslint-plugin-workspaces · libregistry