Sherif Linter for Monorepos
Sherif is an opinionated, zero-config linter designed specifically for TypeScript and JavaScript monorepos. It enforces a set of rules to standardize the developer experience and prevent common regressions in multi-package repositories. The current stable version is `1.11.1`, with new minor versions being released frequently, indicating active development. A key differentiator is its performance; it's written in Rust, runs very fast, and doesn't require `node_modules` to be installed to function, making it efficient for CI/CD pipelines. It supports all major package managers including PNPM, Bun, NPM, and Yarn, and is primarily intended to be run as a CLI tool.
Common errors
-
Command 'sherif' not found
cause Sherif is a CLI tool and not installed globally, or the `npx`/`dlx` command was not used.fixRun Sherif using a package manager's executor: `npx sherif` (npm), `bunx sherif` (Bun), or `pnpm dlx sherif` (PNPM). If installed globally, ensure it's in your PATH. -
Autofix is disabled in CI environments. Please run locally or use '--select' for relevant rules.
cause Attempting to use `sherif --fix` within a continuous integration pipeline, where automatic modifications are prevented.fixTo enable autofix in CI for rules like `multiple-dependency-versions`, explicitly add `--select highest` or `--select lowest` to your command. For other rules, run `sherif --fix` locally and commit the changes. -
Missing configuration field: 'sherif'. Expected a 'sherif' object in root package.json for options 'fix', 'select', 'noInstall', 'failOnWarnings', 'ignoreDependency', 'ignorePackage'.
cause The `sherif` configuration block is missing from the root `package.json`, or the field names within it are incorrect (e.g., kebab-case instead of camelCase).fixAdd a `sherif` object to your root `package.json` with configuration options specified in `camelCase`, for example: `"sherif": { "failOnWarnings": false }`. -
Multiple versions found for dependency 'react': ['18.0.0', '18.2.0']. Please choose one interactively or use '--select highest|lowest'.
cause The `multiple-dependency-versions` rule was triggered with `--fix` in a non-interactive environment (like CI) without the `--select` flag.fixWhen running in non-interactive contexts, append `--select highest` or `--select lowest` to the `sherif --fix` command to automatically resolve version conflicts.
Warnings
- breaking The official GitHub Action (`QuiiBz/sherif`) was updated to use Node.js v24. If your CI environment is still running Node.js v20 or older, this change will cause the action to fail or behave unexpectedly.
- gotcha Running `sherif --fix` is automatically disabled in CI environments (where the `$CI` environment variable is set). This prevents unexpected modifications to your repository in automated pipelines.
- gotcha For non-interactive environments (e.g., CI/CD) and when using the `multiple-dependency-versions` rule with `--fix`, Sherif will prompt for version selection by default. This will cause the process to hang.
- gotcha When configuring Sherif in the root `package.json`, the options must be provided in `camelCase` (e.g., `failOnWarnings`), whereas the equivalent CLI arguments use `kebab-case` (e.g., `--fail-on-warnings`). Mismatched casing will result in the configuration being ignored.
- gotcha The `sherif-linux-x64-musl` package is a specific pre-compiled binary for Linux x64 with musl libc. Directly installing this package might not work on other operating systems or architectures.
- gotcha It is strongly recommended to pin Sherif to a specific version (e.g., `sherif@1.11.1`) in CI/CD pipelines instead of using `sherif@latest`. Using `@latest` can lead to unexpected behavior or breaking changes with new releases, potentially failing your builds.
Install
-
npm install sherif-linux-x64-musl -
yarn add sherif-linux-x64-musl -
pnpm add sherif-linux-x64-musl
Imports
- sherif (CLI)
import sherif from 'sherif-linux-x64-musl'
npx sherif@1.11.1
- Sherif Configuration
import { SherifConfig } from 'sherif-linux-x64-musl'/* package.json */ { "sherif": { "fix": false, "select": "highest" } } - GitHub Action
import { SherifAction } from 'sherif-linux-x64-musl'uses: QuiiBz/sherif@v1
Quickstart
{
"name": "my-monorepo",
"private": true,
"workspaces": [
"packages/*"
],
"scripts": {
"lint:monorepo": "sherif",
"lint:monorepo:fix": "sherif --fix --select highest"
},
"sherif": {
"failOnWarnings": false,
"ignoreRule": [
"root-package-manager-field"
]
}
}
// To run the linter:
pnpm dlx sherif@latest
// To run the linter and automatically fix issues, selecting the highest version for dependencies:
pnpm dlx sherif@latest --fix --select highest