β» Migration guide
If you are setting up Sheriff in an already established codebase, follow these steps:
- Start by running the
npm init @sherifforg/config
command and follow the advice it prints in the console - Ensure the only ESLint config file present in any workspace package is
eslint.config.js
- If you want to keep your existing custom rules on top of Sheriff, ensure you put them after the
sheriff
function, so that they override it. Refer to the configuration instructions - (Recommended) Uninstall packages that Sheriff already incorporates out-of-the-box
Progressive adoption storyβ
In massive codebases, it can be troublesome to adapt to all these rules all at once. It is often preferable to progressively fix the errors at your own pace with atomic commits and focused PRs.
You can use this method by leveraging two techniques:
-
Add a
files
key to thesheriffOptions
object in youreslint.config.js
. The value accepts an array of filepaths, and supports minimatch syntax. Only the matching files found in this array will be lintedSee the example below:
- JS
- TS
import sheriff from "eslint-config-sheriff";
import { defineFlatConfig } from "eslint-define-config";
const sheriffOptions = {
files: ["src/**/*"], // Only the files in the src directory will be linted.
react: false,
next: false,
astro: false,
lodash: false,
remeda: false,
playwright: false,
jest: false,
vitest: false,
};
export default defineFlatConfig([...sheriff(sheriffOptions)]);
import { sheriff, type SheriffSettings } from "eslint-config-sheriff";
import { defineFlatConfig } from "eslint-define-config";
const sheriffOptions: SheriffSettings = {
files: ["src/**/*"], // Only the files in the src directory will be linted.
react: false,
next: false,
astro: false,
lodash: false,
remeda: false,
playwright: false,
jest: false,
vitest: false,
};
export default defineFlatConfig([...sheriff(sheriffOptions)]);
By default, the automatic setup process will not add the files
in the object and every JS/TS file will be linted. Only use this if you specifically want to lint only a subsection of the codebase.
- Use
eslint-interactive
.