Skip to main content

Manual setup

Follow these steps:

  1. Install the package from npm.

    npm install -D eslint 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, tseslint } from 'eslint-config-sheriff';

    const sheriffOptions = {
    react: false,
    next: false,
    astro: false,
    lodash: false,
    remeda: false,
    playwright: false,
    jest: false,
    vitest: false,
    };

    export default tseslint.config(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, tseslint } from 'eslint-config-sheriff'; // 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 tseslint(
    sheriff(sheriffOptions), // Add this
    // Any other configurations...
    );
  3. Adopt eslint.config.ts (optional). If you want to have a .ts configuration file (learn more) instead of the default .js file, follow these steps:

    • ensure your installed ESLint version is >=9.9.0 (preferably >=9.18.0. See why)

    • 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,
      tseslint,
      } from 'eslint-config-sheriff';

      const sheriffOptions: SheriffSettings = {
      react: false,
      next: false,
      astro: false,
      lodash: false,
      remeda: false,
      playwright: false,
      jest: false,
      vitest: false,
      };

      export default tseslint.config(sheriff(sheriffOptions));
  4. Configure Sheriff (optional)

  5. Set up 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.