π 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 you a default
.prettierrc.json
configuration. You can modify it if you need to, 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. - attempt to install the
prettier
dependency in your project. - attempt to 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 yourself.
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 stopped shipping formatting rules, and shortly after
@typesript/eslint
followed suit. This change madeeslint-config-prettier
completely irrelevant and now the only formatting rules left in Sheriff are@stylistic/padding-line-between-statements
andcurly
, which don't 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.
You can use Biome.js or Dprint, but the Sheriff CLI will not provide direct support for them. You will have to integrate them yourself.