Skip to main content

Manual setup

Follow these steps:

  1. Install the package from npm.

    npm install -D eslint eslint-define-config eslint-config-sheriff
  2. Create a eslint.config.mjs file at the root of your project and copy/paste the contents of the following code snippet:

    eslint.config.mjs
    import 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.mjs
    import sheriff from "eslint-config-sheriff"; // Add this
    import { defineFlatConfig } from "eslint-define-config"; // Add this
    // 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
    // Any other configurations...
    ];
  3. Adopt eslint.config.ts (optional). If you want to have a .ts configuration file instead of the default .js file, follow these steps:

    • ensure your installed ESLint version is >=9.9.0

    • install jiti

      npm install -D jiti
    • change the extension of eslint.config.mjs from .mjs to .ts

    • define the types of the sheriffOptions object:

      eslint.config.ts
      import { 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)]);
  4. Configure Sheriff (optional)

  5. Setup Prettier (optional)

  6. Setup VS Code support (optional)

warning

Sheriff is based on the new โ€œflatโ€ ESLint config format. You cannot extend Sheriff from an old config format, it wouldnโ€™t work.