Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

eslint-plugin-workspaces

joshuajaco228.5kMIT0.10.1

An ESLint plugin for enforcing consistent imports across monorepo packages.

eslint, eslintplugin, eslint-plugin, monorepo, packages, workspaces, yarn, lerna, npm, pnpm, bolt

readme

eslint-plugin-workspaces npm downloads Coverage Status code style: prettier

An ESLint plugin for enforcing consistent imports across monorepo packages.

It supports:

Installation

# npm
npm install eslint-plugin-workspaces --save-dev

# yarn
yarn add eslint-plugin-workspaces --dev

Configuration

Enable the rules in your ESLint configuration file:

{
  "plugins": ["workspaces"],
  "rules": {
    "workspaces/no-relative-imports": "error",
    "workspaces/require-dependency": "warn"
  }
}

Or add the "recommended" preset:

{
  "extends": ["plugin:workspaces/recommended"]
}

Rules

✔ included in the "recommended" preset

🔧 fixable using the --fix command line option

| | | Name | Description | | --- | --- | ------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------- | | ✔ | 🔧 | no-absolute-imports | disallow absolute imports for files that are within the current package | | | | no-cross-imports | disallow imports of files that are inside another package | | ✔ | 🔧 | no-relative-imports | disallow relative imports of files that are outside of the current package | | ✔ | | require-dependency | disallow importing from packages that are not listed as a dependency |

Presets

  • recommended enables rules recommended for all users
  • all enables all rules

License

MIT

changelog

Changelog

v0.10.1 - 2024-05-07

v0.10.0 - 2023-11-19

v0.9.0 - 2023-06-10

v0.8.0 - 2023-03-04

  • Replaced the underlying package to resolve monorepo packages (from get-monorepo-packages to find-workspaces) which comes with a few benefits:
    • pnpm workspaces support
    • bolt support
    • caching layer which allows this plugin to look for the workspaces root relative to the file that is being linted instead of the current working directory.
      This means you can run now eslint from outside a monorepo.

v0.7.0 - 2021-10-08

  • Fixed a bug where imports were incorrectly flagged as relative imports (#11)
  • It is no longer necessary to add the plugin when also extending one of the presets:
{
-  "plugins": ["workspaces"],
  "extends": ["plugin:workspaces/recommended"]
}

v0.6.2 - 2020-10-16

  • Fixed a bug where mismatched dependencies were listed as disallowed (#9)

v0.6.1 - 2020-10-15

v0.6.0 - 2020-10-06

  • Added Scopes -- a way to partially allow imports across workspace boundaries (@tobilen in #8)
  • Added this CHANGELOG file