Opinionated, zero-config linter for JavaScript monorepos

Overview


Sherif: Opinionated, zero-config linter for JavaScript monorepos


Cover

About

Sherif is an opinionated, zero-config linter for JavaScript monorepos. It runs fast in any monorepo and enforces rules to provide a better, standardized DX.

Features

  • PNPM, NPM, Yarn...: sherif works with all package managers
  • 🔎 Zero-config: it just works and prevents regressions
  • Fast: doesn't need node_modules installed, written in 🦀 Rust

Installation

Run sherif in the root of your monorepo to list the found issues. Any error will cause Sherif to exit with a code 1:

# PNPM
pnpm dlx sherif@latest
# NPM
npx sherif@latest

We recommend running Sherif in your CI once all errors are fixed. Run it by specifying a version instead of latest. This is useful to prevent regressions (e.g. when adding a library to a package but forgetting to update the version in other packages of the monorepo).

GitHub Actions example
name: Sherif
on:
  pull_request:
jobs:
  check:
    name: Run Sherif
    runs-on: ubuntu-22.04
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - uses: actions/setup-node@v3
        with:
          node-version: 20
      - run: npx [email protected]

Rules

You can ignore a specific rule by using --ignore-rule <name> (or -r <name>):

# Ignore both rules
sherif -r packages-without-package-json -r root-package-manager-field

You can ignore all issues in a package by using --ignore-package <name> (or -p <name>):

# Ignore all issues in the package
sherif -p @repo/tools

Note
Sherif doesn't have many rules for now, but will likely have more in the future (along with more features).

empty-dependencies

package.json files should not have empty dependencies fields.

multiple-dependency-versions

A given dependency should use the same version across the monorepo.

You can ignore this rule for a dependency if you expect to have multiple versions by using --ignore-dependency <name> (or -i <name>):

# Ignore dependencies that are expected to have multiple versions
sherif -i react -i @types/node

packages-without-package-json ⚠️

All packages defined in the root package.json' workspaces field or pnpm-workspace.yaml should have a package.json file.

root-package-dependencies ⚠️

The root package.json is private, so making a distinction between dependencies and devDependencies is useless - only use devDependencies.

root-package-manager-field

The root package.json should specify the package manager and version to use. Useful for tools like corepack.

root-package-private-field

The root package.json should be private to prevent accidentaly publishing it to a registry.

types-in-dependencies

Private packages shouldn't have @types/* in dependencies, since they don't need it at runtime. Move them to devDependencies.

Credits

Sponsors

Sponsors

License

MIT

Comments
  • Clarify which packages are causing the `multiple-dependency-versions` rule

    Clarify which packages are causing the `multiple-dependency-versions` rule

    Just trying out sherif on our monorepo and got the following errors:

    12 issues found (12 ⨯, 0 ⚠️, 0 ⊙) across 24 packages:
    
     ⨯ error The `@team-plain/typescript-sdk` dependency has multiple versions, ^2.2.0 being the lowest and ^2.7.0 the highest.
             multiple-dependency-versions: @team-plain/typescript-sdk has 2 versions: ^2.2.0, ^2.7.0
    
     ⨯ error The `express` dependency has multiple versions, ^4.18.1 being the lowest and ^4.18.2 the highest.
             multiple-dependency-versions: express has 2 versions: ^4.18.1, ^4.18.2
    
     ⨯ error The `nanoid` dependency has multiple versions, ^3.3.4 being the lowest and ^4.0.2 the highest.
             multiple-dependency-versions: nanoid has 2 versions: ^3.3.4, ^4.0.2
    
     ⨯ error The `@types/node` dependency has multiple versions, ^16 being the lowest and ^18.11.15 the highest.
             multiple-dependency-versions: @types/node has 6 versions: ^16, 16.*, ^18, 18.*, ^18, ^18.11.15
    
     ⨯ error The `@types/node-fetch` dependency has multiple versions, 2.6.* being the lowest and ^2.6.2 the highest.
             multiple-dependency-versions: @types/node-fetch has 2 versions: 2.6.*, ^2.6.2
    
     ⨯ error The `eslint` dependency has multiple versions, ^8.19.0 being the lowest and ^8.24.0 the highest.
             multiple-dependency-versions: eslint has 2 versions: ^8.19.0, ^8.24.0
    
     ⨯ error The `typescript` dependency has multiple versions, ^4.8.4 being the lowest and ^5.2.2 the highest.
             multiple-dependency-versions: typescript has 4 versions: ^4.8.4, ^4.9.4, ^4.9.5, ^5.2.2
    
     ⨯ error The `tsup` dependency has multiple versions, ^6.5.0 being the lowest and ^7.2.0 the highest.
             multiple-dependency-versions: tsup has 4 versions: ^6.5.0, 7.1.*, ^7.1.0, ^7.2.0
    
     ⨯ error The `node-fetch` dependency has multiple versions, 2.6.* being the lowest and ^3.3.0 the highest.
             multiple-dependency-versions: node-fetch has 2 versions: 2.6.*, ^3.3.0
    
     ⨯ error The `resend` dependency has multiple versions, ^0.9.1 being the lowest and ^1.0.0 the highest.
             multiple-dependency-versions: resend has 2 versions: ^0.9.1, ^1.0.0
    
     ⨯ error The `openai` dependency has multiple versions, ^4.2.0 being the lowest and ^4.5.0 the highest.
             multiple-dependency-versions: openai has 2 versions: ^4.2.0, ^4.5.0
    
     ⨯ error The `vitest` dependency has multiple versions, ^0.34.3 being the lowest and ^0.34.4 the highest.
             multiple-dependency-versions: vitest has 2 versions: ^0.34.3, ^0.34.4
    

    Which is super helpful! But it would be even more helpful if it would print out which packages were using these dependencies and which versions each was on.

    opened by ericallam 2
  • feat: add types in dependencies rule

    feat: add types in dependencies rule

    Closes https://github.com/QuiiBz/sherif/issues/8

    Private packages shouldn't have @types/* in dependencies, since they don't need it at runtime. Move them to devDependencies.

    enhancement 
    opened by QuiiBz 0
  • feat: rule to detect `@types/*` packages in `dependencies` instead of `devDependencies`

    feat: rule to detect `@types/*` packages in `dependencies` instead of `devDependencies`

    We should add a new rule to automatically detect @types/* packages that are present in dependencies instead of being in devDependencies. The rule name could be types-in-dependencies

    enhancement 
    opened by QuiiBz 0
  • refactor: improve README & tweak issues level

    refactor: improve README & tweak issues level

    • Improve README with more examples
    • empty-dependencies is now an error
    • Ignore dependencies versions that are *, since they match any other defined version in the monorepo
    opened by QuiiBz 0
  • feat: add packages without package.json rule

    feat: add packages without package.json rule

    Detect packages that don't have a package.json file in their directory. Warning by default because it might be intended, but is not an ideal pattern: you should instead remove this package from the monorepo packages.

    enhancement 
    opened by QuiiBz 0
  • feat: add `--fix` option to autofix issues

    feat: add `--fix` option to autofix issues

    As suggested by @juliusmarminge: https://twitter.com/jullerino/status/1703794047104479562

    We should add support for a new --fix option, that will try to fix issues as much as possible. We can add a fn fix(&self) -> bool to the Issue trait, that will be executed on each issue. Returning true means the fix was successful, false that it wasn't: https://github.com/QuiiBz/sherif/blob/7b5a2075ace5d6c6ef88599612826fe4c62d668d/src/rules/mod.rs#L45

    enhancement 
    opened by QuiiBz 0
Releases(v0.3.0)
  • v0.3.0(Sep 27, 2023)

    What's Changed

    • feat: add more error messages by @QuiiBz in https://github.com/QuiiBz/sherif/pull/7
    • feat: add types in dependencies rule by @QuiiBz in https://github.com/QuiiBz/sherif/pull/9
    • feat: improve errors output by @QuiiBz in https://github.com/QuiiBz/sherif/pull/10
    • feat: improve perf by @QuiiBz in https://github.com/QuiiBz/sherif/pull/11

    Full Changelog: https://github.com/QuiiBz/sherif/compare/v0.2.0...v0.3.0

    Source code(tar.gz)
    Source code(zip)
Owner
Tom Lienard
Developer, enjoying Cloud and Open Source. Frontend @scaleway. Working on @lagonapp
Tom Lienard
A Faster(⚡) formatter, linter, bundler, and more for JavaScript, TypeScript, JSON, HTML, Markdown, and CSS Lapce Plugin

Lapce Plugin for Rome Lapce-rome is a Lapce plugin for rome, The Rome is faster ⚡ , A formatter, linter, compiler, bundler, and more for JavaScript, T

xiaoxin 7 Dec 16, 2022
The JavaScript Oxidation Compiler -> Linter / Prettier

The JavaScript Oxidation Compiler (oxc) Why this project? The goal of this project is to: Create a blazingly fast JavaScript Compiler written in Rust.

Boshen 125 Feb 22, 2023
A zero-config leptos component to display markdown

A port of yew-markdown using leptos ! Usage You can use this component to render both static and dynamic markdown. Static markdown use leptos::*; {

Antonin Peronnet 4 Aug 4, 2023
A very opinionated, zero-configuration shell prompt

A very opinionated, zero-configuration shell prompt

amy null 8 Nov 4, 2021
An extremely fast Python linter, written in Rust.

Ruff An extremely fast Python linter, written in Rust. Linting the CPython codebase from scratch. ⚡️ 10-100x faster than existing linters ?? Installab

Charlie Marsh 5.1k Dec 30, 2022
The dead easy way to use config files in your rust project

Configr The dead easy way to use config files in your project This will load a config.toml file if it exists, otherwise it will create the needed fold

Carsten Kragelund Jørgensen 4 Jul 1, 2022
FastSSH is a TUI that allows you to quickly connect to your services by navigating through your SSH config.

Connect quickly to your services ?? FastSSH is a TUI that allows you to quickly connect to your services by navigating through your SSH config. Instal

Julien 85 Dec 14, 2022
Most intuitive global cli maker. *(lazy_static + config-rs + clap)

argone Most intuitive global cli maker. *(lazy_static + config-rs + clap) | Examples | Docs | Latest Note | [dependencies] argone = "0.5" Phases Parsi

Doha Lee 6 Dec 9, 2022
Irx-config - The library provides convenient way to represent/parse configuration from different sources

The irx-config library provides convenient way to represent/parse configuration from different sources. The main goals is to be very easy to use and t

Andriy Bakay 2 Sep 14, 2022
⚙️ A curated list of static analysis (SAST) tools for all programming languages, config files, build tools, and more.

This repository lists static analysis tools for all programming languages, build tools, config files and more. The official website, analysis-tools.de

Analysis Tools 10.7k Jan 2, 2023
🕺 Run React code snippets/components from your command-line without config

Run React code snippets/components from your command-line without config.

Eliaz Bobadilla 11 Dec 30, 2022
🐙 Loads config and hosts for gh CLI in Rust.

gh-config-rs Loads config and hosts for gh CLI in Rust. Getting started [dependencies] gh-config = "0.2" Usage use std::error::Error; use gh_config::*

Naoki Ikeguchi 2 Jul 23, 2022
A lightweight, opinionated CQRS and event sourcing framework targeting serverless architectures.

cqrs A lightweight, opinionated CQRS and event sourcing framework targeting serverless architectures. Command Query Responsibility Segregation (CQRS)

Serverless Technology 161 Dec 29, 2022
MinMon - an opinionated minimal monitoring and alarming tool

MinMon - an opinionated minimal monitoring and alarming tool (for Linux) This tool is just a single binary and a config file. No database, no GUI, no

Florian Wickert 177 Jan 5, 2023
A opinionated and fast static analyzer for PHP.

TLDR; A static analyzer for PHP. It helps you catch common mistakes in your PHP code. These are the current checks implemented. Extending undefined cl

Denzyl Dick 11 Mar 6, 2023
Beautiful, minimal, opinionated CLI prompts inspired by the Clack NPM package

Effortlessly build beautiful command-line apps with Rust ?? ✨ Beautiful, minimal, opinionated CLI prompts inspired by the @clack/prompts npm package.

Alexander Fadeev 7 Jul 23, 2023
Opinionated set of extensions for use with rust-script

rust-script-ext Opinionated set of extensions for use with rust-script. Using rust-script to run Rust like a shell script is great! This crate provide

Kurt Lawrence 13 Sep 3, 2023
A simple, opinionated way to run containers for tests in your Rust project.

rustainers rustainers is a simple, opinionated way to run containers for tests. TLDR More information about this crate can be found in the crate docum

wefox 4 Nov 23, 2023
Build terminal dashboards using ascii/ansi art and javascript

blessed-contrib Build dashboards (or any other application) using ascii/ansi art and javascript. Friendly to terminals, ssh and developers.

Yaron Naveh 15k Jan 2, 2023