Manual setup
Follow these steps:
-
Install the package from npm.
- npm
- Yarn
- pnpm
npm install -D eslint eslint-define-config eslint-config-sheriff
yarn add --dev eslint eslint-define-config eslint-config-sheriff
pnpm add -D eslint eslint-define-config eslint-config-sheriff
-
Create a
eslint.config.mjs
file at the root of your project and copy/paste the contents of the following snippet of code:eslint.config.mjsimport sheriff from "eslint-config-sheriff";
import { defineFlatConfig } from "eslint-define-config";
const sheriffOptions = {
react: false,
next: false,
astro: false,
lodash: false,
remeda: false,
playwright: false,
jest: false,
vitest: false,
};
export default defineFlatConfig([...sheriff(sheriffOptions)]);or, if you already have a
eslint.config.mjs
in your project, just append Sheriff to the configs array, like this:eslint.config.mjsimport sheriff from "eslint-config-sheriff"; // add this
import { defineFlatConfig } from "eslint-define-config"; // add this
// my other imports...
// add this
const sheriffOptions = {
react: false,
next: false,
astro: false,
lodash: false,
remeda: false,
playwright: false,
jest: false,
vitest: false,
};
export default [
...sheriff(sheriffOptions), // add this
// my other configurations...
]; -
Adopt
eslint.config.ts
(optional).If you want to have a
.ts
configuration file instead of the default.js
file, follow these steps:-
make sure your installed ESLint version is
>=9.9.0
-
install jiti
- npm
- Yarn
- pnpm
npm install -D jiti
yarn add --dev jiti
pnpm add -D jiti
-
change the extension of
eslint.config.mjs
from.mjs
to.ts
-
define the types of the
sheriffOptions
object:eslint.config.tsimport { sheriff, type SheriffSettings } from "eslint-config-sheriff";
import { defineFlatConfig } from "eslint-define-config";
const sheriffOptions: SheriffSettings = {
react: false,
next: false,
astro: false,
lodash: false,
remeda: false,
playwright: false,
jest: false,
vitest: false,
};
export default defineFlatConfig([...sheriff(sheriffOptions)]);
-
-
Configure Sheriff (optional)
-
Setup Prettier (optional)
-
Setup VSCode support (optional)
Sheriff is based on the new format of ESLint configs. You cannot extend Sheriff from an old config format, it wouldn't work.