Package Exports
- eslint-config-sheriff
- eslint-config-sheriff/package.json
Readme
Sheriff
π Table of Contents
- π Table of Contents
- π Description
- π οΈ Setup
- β¨ Features
- π₯οΈ Techs
- π Requirements
- π§³ Eslint plugins
- π§Ά Rules
- π§ Configuration
- π§ Prior art
- β» Migration guide
- π§‘ Contributing
- π€ Changelog
- π License
- π Roadmap
- π Acknowledgments
π Description
π₯³ Introduction
sheriff
is a comprehensive Eslint configuration.
It supports various technologies.
sheriff
is very easy top get started with and use. It promotes a βzero overhead approachβ. See: philosophy.
Itβs a "plug & play" solution but you can customize it as much as you want. See: features.
β οΈ At the moment,
sheriff
supports only Typescript codebases with modern Ecmascript standards. Maybe in the future i'll take in consideration support for vanilla Javascript. See: roadmap.
π€ Why / Motivations
Managing a complex eslint configurazione takes time and effort. sheriff
does it for you.
π Philosophy / Criteria
This library is very opinionated, but it's for the better. I took a lot of decisions so you don't have to [^2].
You can now quickstart static analysis in all your Typescript projects with ease. It's just 1 create-sheriff-config
.
You can think of sheriff
like prettier
or create-react-app
. It's a tool that comes battery-packed with optimal defaults. It remove configuration decisions from the equation, so you or your team can focus on developing the actual product.
And if you don't like something, you can easily override it, and just as easily you can extend it. See: configuration.
[^2]: This config is particularly useful for big teams with developers of various skill levels. I worked in a lot of different projects and teams through the years and i got accustomed to seeing all kinds of mistake being made. sheriff
was made to prevent all of those mistakes. It is battle-tested in real-world scenarios, and shines especially in such.
π οΈ Setup
This config is highly opinionated, so make sure to meet the hard requirements in your project.
Then, let create-sheriff-config
handle the whole setup for you automatically, or do it yourself manually.
π€ Automatic setup (recommended)
Let the CLI take care of everything! Just run this command in your terminal:
β― npx create-sheriff-config
...and your good to go! Happy hacking π
π« Manual setup
Follow these steps:
Install the package from npm.
# npm β― npm install -D eslint-config-sheriff # yarn β― yarn add -D eslint-config-sheriff # pnpm β― pnpm add -D eslint-config-sheriff
Create a
eslint.config.js
[^1] file at the root of your project and copy/paste the contents of this snippet:// eslint.config.js import sheriff from 'eslint-config-sheriff/recommended'; export default [ ...sheriff, { files: ['**/*{js,ts,jsx,tsx}'], }, ];
or, if you already have a
eslint.config.js
in your project, just appendsheriff
to the configs array, like this:// eslint.config.js import sheriff from 'eslint-config-sheriff/recommended'; // my other imports... export default [ // my other configurations... ...sheriff, ];
Configure sheriff (optional)
[^1]: sheriff
is based on the new format of Eslint configs. You cannot extend sheriff
from a old config format, it wouldn't work.
β¨ Features
- β‘ Batteries included:
sheriff
is a all-in-one solution. You don't need to install or configure separately anything else. Everything is included here. - π No lock-in:
sheriff
is not a framework. You can extend theeslint.config.js
beyondsheriff
as much as you like, just like you normally would. Or you can disable any rulesheriff
comes with.sheriff
doesn't impose any limitation. - π Frictionless by design: to setup
sheriff
and take off, the only input required from the user is running the commandnpx create-sheriff-config
. The command will automatically infer the details of your project and figure out the optimalsheriff
configuration by itself. - β Interoperability: you can plop
sheriff
in your project at any moment.create-sheriff-config
will config automatically everything for you and will warn you if you need take any special precautions. Bottomline: it's never to late too installsheriff
. - π Cutting-edge:
sheriff
is one of the first attempts in the wild to adhere to the new eslint configuration format, theFlatConfig
. You can usesheriff
to easily and safely migrate your project to the new config format without effort. See: migration guide. - ποΈ Configurable:
sheriff
is fully configurable with it's own config filesheriffrc.json
. See: configuration. - π Modular:
sheriff
has opt-in support for a wide array of libraries. - β SemVer:
sheriff
releases follows Semantic Versioning with Conventional Commits standards.
π₯οΈ Techs
- Eslint
- Prettier
- Typescript
- React (opt-in)
- Next (opt-in)
- Lodash (opt-in)
- Playwright (opt-in)
π Requirements
Hard requirements
Recommendations
π§³ Eslint plugins
- @typescript/eslint
- eslint-config-prettier
- eslint-plugin-react
- eslint-plugin-jsx-a11y
- eslint-plugin-react-hooks
- eslint-plugin-unicorn
- eslint-plugin-sonarjs
- eslint-plugin-jsdoc
- eslint-plugin-import with eslint-import-resolver-typescript
- eslint-plugin-lodash-f
- my fork of eslint-plugin-lodash
- @next/eslint-plugin-next
- eslint-plugin-playwright
π§Ά Rules
See Rules.
π§ Configuration
Configure
sheriff
as desired in thesheriffrc.json
file [^3].
Every config option can be set on/off (you just pass them a boolean value). As they are all opt-in, they are all disabled by default.// sheriffrc.json (default) { react: false, next: false, lodash: false, playwright: false, }
[^3]: sheriff
utilizes cosmiconfig under-the-hood to power-up the sheriff
configuration. You are not forced to call the config file "sheriffrc.json", you can choose one of the alternative filetypes. See cosmiconfig for details.
- Override any
sheriff
rule as desired in theeslint.config.js
file.
π§ Prior art / Related projects
- eslint-config-galex
- eslint-kit
- eslint-config-everywhere
- xo
- eslint-prettier-typescript-config
- eslint-config-airbnb-typescript
β» Migration guide
TODO
π§‘ Contributing
TODO
π License
π€ Changelog
See Releases.
π Roadmap
- Consider more rules
-
eslint-plugin-next
- Create the
sheriffrc.json
file support - Create a cli ala
create-react-app
- Remove
react
as a hard requirement - Svelte support
- Solid support
- Vue support
- Astro support
- Create a documentation website
π Acknowledgments
For some of this config i partially used eslint-config-red as a base.
I don't take any attribution for the rules in the various eslint-plugins used here (expect for the few that i personally created). Please consider starring the respective projects for the awesome work their authors made. sheriff
wouldn't be possible without their efforts.
The full list of the plugins used is here.