Manual setup
Follow these steps:
-
Install the package from npm.
- npm
- Yarn
- pnpm
npm install -D eslint eslint-define-config eslint-config-sheriffyarn add --dev eslint eslint-define-config eslint-config-sheriffpnpm add -D eslint eslint-define-config eslint-config-sheriff -
Create a
eslint.config.jsfile at the root of your project and copy/paste the contents of the following snippet of code:- ESM
- CommonJS
eslint.config.jsimport sheriff from "eslint-config-sheriff";
import { defineFlatConfig } from "eslint-define-config";
const sheriffOptions = {
react: false,
next: false,
astro: false,
lodash: false,
playwright: false,
jest: false,
vitest: false,
};
export default defineFlatConfig([...sheriff(sheriffOptions)]);eslint.config.jsconst { sheriff } = require("eslint-config-sheriff");
const { defineFlatConfig } = require("eslint-define-config");
const sheriffOptions = {
react: false,
next: false,
astro: false,
lodash: false,
playwright: false,
jest: false,
vitest: false,
};
module.exports = defineFlatConfig([...sheriff(sheriffOptions)]);or, if you already have a
eslint.config.jsin your project, just append Sheriff to the configs array, like this:- ESM
- CommonJS
eslint.config.jsimport 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,
playwright: false,
jest: false,
vitest: false,
};
export default [
...sheriff(sheriffOptions), // add this
// my other configurations...
];eslint.config.jsconst { sheriff } = require("eslint-config-sheriff"); // add this
const { defineFlatConfig } = require("eslint-define-config"); // add this
// my other imports...
// add this
const sheriffOptions = {
react: false,
next: false,
astro: false,
lodash: false,
playwright: false,
jest: false,
vitest: false,
};
module.exports = [
...sheriff(sheriffOptions), // add this
// my other configurations...
]; -
Adopt
eslint.config.ts(optional).If you want to have a
.tsconfiguration file instead of the default.jsfile, follow these steps:-
- npm
- Yarn
- pnpm
npm install -D eslint-ts-patch eslint@npm:eslint-ts-patch @sherifforg/typesyarn add --dev eslint-ts-patch eslint@npm:eslint-ts-patch @sherifforg/typespnpm add -D eslint-ts-patch eslint@npm:eslint-ts-patch @sherifforg/types -
change the extension of
eslint.config.jsfrom.jsto.ts -
define the types of the
sheriffOptionsobject:eslint.config.tsimport sheriff from "eslint-config-sheriff";
import { defineFlatConfig } from "eslint-define-config";
import type { SheriffSettings } from "@sherifforg/types";
const sheriffOptions: SheriffSettings = {
react: false,
next: false,
astro: false,
lodash: false,
playwright: false,
jest: false,
vitest: false,
};
export default defineFlatConfig([...sheriff(sheriffOptions)]);
-
-
Configure Sheriff (optional)
-
Setup Prettier (optional)
-
Setup VSCode support (optional)
warning
Sheriff is based on the new format of ESLint configs. You cannot extend Sheriff from an old config format, it wouldn't work.