π Prettier support
Sheriff is designed to coexist smoothly with Prettier, allowing both tools to complement each other effectively. If you want Prettier support in your project, the next sections will guide you through the setup and usage of it.
Setupβ
The npm init @sherifforg/config
command will attempt to:
- spin up for a default
.prettierrc.json
configuration. You can modify it if you like, but it is discouraged. Act with caution. If you already have a Prettier config in your project, the command will not overwrite it, nor will it attempt to modify it. - install the
prettier
dependency in your project. - create a
.prettierignore
file in your project.
If you donβt use the npm init @sherifforg/config
command, you will have to do above setup steps manually.
Usageβ
By design, Sheriff doesn't incorporate:
- eslint-plugin-prettier. Its use is discouraged by the Prettier team itself, as it just slows down your editor. It's better to just let ESLint and Prettier run side-by-side.
- eslint-config-prettier. Starting from ESLint v8.53.0, ESLint deprecated formatting rules, and shortly after typescript-eslint followed suit. This change made
eslint-config-prettier
completely irrelevant and now the only formatting rules left in Sheriff are@stylistic/padding-line-between-statements
andcurly
, neither of which conflict with Prettier.
Instead, for your local editing experience, it's recommended to install the Prettier editor extension.
If you want to enforce Prettier at pre-commit stage, see the official Prettier docs.
To enforce Prettier in CI, see the Prettier CLI docs.
Other Formatting optionsβ
As Sheriff doesnβt enforce any formatting rules (except for @stylistic/padding-line-between-statements
and curly
), you can use any formatting tool you want to go alongside Sheriff. You are not limited to Prettier.
Alternatively, you could use Biome or dprint, but the Sheriff CLI will not provide direct support for them. You will have to integrate them yourself.