Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/joshuajaco/eslint-plugin-workspaces

An ESLint plugin for enforcing consistent imports across monorepo packages.
https://github.com/joshuajaco/eslint-plugin-workspaces

bolt eslint eslint-plugin lerna-monorepo monorepo npm-workspaces pnpm-workspace workspaces yarn-workspaces

Last synced: 3 days ago
JSON representation

An ESLint plugin for enforcing consistent imports across monorepo packages.

Awesome Lists containing this project

README

        

# eslint-plugin-workspaces ![npm downloads](https://img.shields.io/npm/dw/eslint-plugin-workspaces) [![Coverage Status](https://coveralls.io/repos/github/joshuajaco/eslint-plugin-workspaces/badge.svg)](https://coveralls.io/github/joshuajaco/eslint-plugin-workspaces) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)

An ESLint plugin for enforcing consistent imports across monorepo packages.

It supports:

- [Yarn workspaces](https://classic.yarnpkg.com/en/docs/workspaces)
- [npm workspaces](https://docs.npmjs.com/cli/v7/using-npm/workspaces)
- [pnpm workspaces](https://pnpm.io/workspaces)
- [lerna](https://github.com/lerna/lerna)
- [bolt](https://github.com/boltpkg/bolt)

## Installation

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

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

## Configuration

Enable the rules in your ESLint configuration file:

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

Or add the "recommended" preset:

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

## Rules

✔ included in the "recommended" preset

🔧 fixable using the `--fix` command line option

| | | Name | Description |
| --- | --- | ------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------- |
| ✔ | 🔧 | [no-absolute-imports](https://github.com/joshuajaco/eslint-plugin-workspaces/blob/main/docs/rules/no-absolute-imports.md) | disallow absolute imports for files that are within the current package |
| | | [no-cross-imports](https://github.com/joshuajaco/eslint-plugin-workspaces/blob/main/docs/rules/no-cross-imports.md) | disallow imports of files that are inside another package |
| ✔ | 🔧 | [no-relative-imports](https://github.com/joshuajaco/eslint-plugin-workspaces/blob/main/docs/rules/no-relative-imports.md) | disallow relative imports of files that are outside of the current package |
| ✔ | | [require-dependency](https://github.com/joshuajaco/eslint-plugin-workspaces/blob/main/docs/rules/require-dependency.md) | 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](https://github.com/joshuajaco/eslint-plugin-workspaces/blob/main/LICENSE)