Sherif: Zero-Config Monorepo Linter
Sherif is an opinionated, zero-config linter designed specifically for TypeScript and JavaScript monorepos. It aims to standardize the developer experience (DX) and prevent regressions by enforcing a predefined set of rules across multiple packages within a single repository. Written in Rust for performance, Sherif operates efficiently without requiring `node_modules` to be installed, supporting all major package managers including PNPM, Bun, NPM, and Yarn. The current stable version is 1.11.1, with frequent minor releases indicating active development and maintenance. Key differentiators include its zero-configuration approach, cross-package manager compatibility, high execution speed, and robust autofix capabilities which can be run interactively or non- interactively via a `--select` flag for consistent dependency versioning.
Common errors
-
Command failed with exit code 1
cause Sherif detected issues, either errors or warnings (if `--fail-on-warnings` is enabled).fixReview Sherif's output to identify the reported issues. Run `npx sherif@latest --fix` to attempt automatic resolution for most problems, or apply manual fixes. If warnings are acceptable in CI, remove the `--fail-on-warnings` flag. -
Error: Command `install` has been disabled.
cause Sherif attempted to run a package manager install command after autofix, but it was prevented.fixIf you wish to prevent Sherif from running `install` after autofix, use the `--no-install` flag (or `noInstall: true` in config). Otherwise, ensure your environment allows package manager commands to run. -
error: unknown argument '--some-non-existent-flag'
cause An unrecognized command-line argument was passed to Sherif.fixVerify the spelling and existence of the flag in Sherif's documentation. Ensure that arguments are passed correctly, distinguishing between CLI flags and configuration options in `package.json`. CLI arguments take precedence over `package.json` configuration.
Warnings
- breaking The GitHub Action for Sherif was upgraded to use Node.js 24. Users relying on older Node.js versions in their CI might experience build failures if not updated.
- gotcha Autofixing with the `--fix` flag is automatically disabled in CI environments (when the `$CI` environment variable is set). This prevents unintended modifications in automated workflows.
- gotcha Sherif will exit with an error code (1) if any errors are found, but exits with code 0 for warnings. To make warnings also cause a failure, the `--fail-on-warnings` flag is needed.
- gotcha Running `sherif@latest` in CI environments can introduce regressions if a new version with breaking changes or new rules is released. It's best practice to pin a specific version.
Install
-
npm install sherif -
yarn add sherif -
pnpm add sherif
Imports
- sherif (CLI)
import sherif from 'sherif';
npx sherif@latest
- sherif --fix
sherif.fixIssues(); // Programmatic autofix is not supported.
npx sherif@latest --fix
- sherif --select
sherif.selectVersion('highest'); // There is no programmatic API for selection.npx sherif@latest --fix --select highest
Quickstart
{
"name": "my-monorepo-root",
"private": true,
"workspaces": [
"packages/*"
],
"scripts": {
"lint:monorepo": "sherif",
"lint:monorepo:fix": "sherif --fix --select highest"
},
"sherif": {
"failOnWarnings": true,
"ignoreRule": ["root-package-manager-field"],
"rules": {
"multiple-dependency-versions": true,
"unsync-similar-dependencies": true
}
}
}
// To run the linting:
// npx sherif@latest
// or using the script defined above:
// npm run lint:monorepo
// To run the autofix:
// npm run lint:monorepo:fix