eslint-plugin-monorepo

raw JSON →
0.3.2 verified Sat Apr 25 auth: no javascript maintenance

ESLint plugin providing custom rules to enforce consistent import patterns within monorepos using Lerna or Yarn Workspaces. Current stable version is 0.3.2 (last released November 2020). It offers two rules: no-internal-import to forbid importing specific files from a package, and no-relative-import (fixable) to prevent relative imports between monorepo packages. Unlike generic import plugins, it automatically detects monorepo structure via package.json workspaces or lerna.json. Note: the package is in maintenance mode with no recent updates.

error ESLint couldn't find the plugin "eslint-plugin-monorepo".
cause Plugin is not installed or not listed in ESLint's plugins array.
fix
Run 'npm install eslint-plugin-monorepo --save-dev' and add 'plugins: ["monorepo"]' to your ESLint config.
error Cannot find module 'get-monorepo-packages'
cause Missing dependency when requiring the plugin.
fix
Ensure all dependencies are installed by running 'npm install eslint-plugin-monorepo get-monorepo-packages' (or reinstall the plugin itself).
error Parsing error: The keyword 'import' is reserved
cause ESLint parser not configured for ES modules.
fix
Add 'parserOptions: { sourceType: "module" }' or 'ecmaVersion: 2015, sourceType: "module"' to your ESLint config.
gotcha Plugin may not detect monorepo structure if the workspace root is not correctly configured.
fix Ensure package.json has 'workspaces' array or lerna.json exists. Optionally set 'settings.monorepo.root' in ESLint config.
gotcha The 'no-relative-import' rule can auto-fix imports, but may incorrectly change non-monorepo imports.
fix Review auto-fixes carefully. Consider using only in conjunction with proper workspace configuration.
gotcha Rules may not work correctly if there are nested workspaces or glob patterns in workspaces.
fix Prefer explicit workspace array over glob patterns. Ensure all packages are listed.
deprecated Package has not been updated since 2020; may not support newer ESLint versions (>=8).
fix Consider migrating to eslint-plugin-import or maintaining a fork.
npm install eslint-plugin-monorepo
yarn add eslint-plugin-monorepo
pnpm add eslint-plugin-monorepo

Basic ESLint configuration enabling the recommended monorepo rules.

// .eslintrc.cjs
module.exports = {
  extends: ['plugin:monorepo/recommended'],
  settings: {
    monorepo: {
      // optional: specify workspace root if not automatically detected
      root: './'
    }
  }
};