---
title: Performance Tips
description: Tips for improving ESLint performance when using Sheriff
icon: IoFlash
---

import { Tab, Tabs } from "fumadocs-ui/components/tabs";

Depending on the device you are operating on, in-editor performance can be a concern with Sheriff. <br />
`@typescript-eslint` can be particularly taxing on the system, so, some performance considerations are in order.

## Rules performance benchmarking

The currently known slowest rules in Sheriff are the ones of `@typescript-eslint` that [requires type information](https://typescript-eslint.io/getting-started/typed-linting) to work.

[List of types-aware rules](https://typescript-eslint.io/rules/?=typeInformation).

You can benchmark rules performance by yourself by running the following command in the terminal:

```npm
TIMING=1 pnpm dlx eslint
```

Learn more in the [ESLint official docs section](https://eslint.org/docs/latest/extend/custom-rules#profile-rule-performance).

## Rules performance optimization strategies

There are a few techniques you can leverage to improve slow linting time. <br />
You can choose which technique to employ or mix-and-match them.

### Disable some of the heaviest rules

As simple as it sounds, you could assess which of the slowest rules you can live without and simply disable them.

### Enable some of the heaviest rules only on CI

This approach has a little more overhead, but you could try to run the heaviest rules only on CI.

Here is an example on how you can achieve it:

<Tabs groupId="tsorjs" items={['JS', 'TS']} persist>
  <Tab value="JS">

```js title="eslint.config.mjs"
import { sheriff } from "eslint-config-sheriff";
import { defineConfig } from "eslint/config";

const sheriffOptions = {
  react: false,
  next: false,
  astro: false,
  lodash: false,
  remeda: false,
  playwright: false,
  storybook: true,
  jest: false,
  vitest: false,
  tsconfigRootDir: import.meta.dirname,
};

export default defineConfig(sheriff(sheriffOptions),
  {
    rules: {
      "@typescript-eslint/no-misused-promises": process.env.CI ? 2 : 0, // [!code highlight]
    },
  },
);
```

</Tab>
<Tab value="TS">

```ts twoslash title="eslint.config.ts"
import { sheriff, type SheriffSettings } from "eslint-config-sheriff";
import { defineConfig } from "eslint/config";

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

export default defineConfig(sheriff(sheriffOptions),
  {
    rules: {
      "@typescript-eslint/no-misused-promises": process.env.CI ? 2 : 0, // [!code highlight]
    },
  },
);
```

  </Tab>
</Tabs>

This is a tradeoff, as this approach is a DX degradation and could lead to some developer frustration, because perfectly valid code in local environment could instead fail in CI.

{/* Caching doesn't handles dependencies, breaking typescript-eslint and eslint-plugin-import: https://typescript-eslint.io/troubleshooting/faqs/eslint/#can-i-use-eslints---cache-with-typescript-eslint */}
{/* ### Adopt ESLint's cache

ESLint features an internal cache where you can store your previous runs.

This technique has pretty much no downsides and you should employ it in any case, regardless of any other factor.

Read the official docs on ESLint caching here: [command-line-interface#caching](https://eslint.org/docs/latest/use/command-line-interface#caching). <br />
Instead, if your project lives in a monorepo, you can follow [this guide](https://www.shew.dev/monorepos/guardrails/eslint). */}

### Review glob patterns

ESLint, Typescript and Sheriff use minimatch syntax to handle glob patterns.
Wide glob patterns can lead to performance degradation.

Pay special attention to:

- [ESLint files and ignore patterns](https://eslint.org/docs/latest/use/configure/configuration-files-new#specifying-files-and-ignores)
- [Typescript include and exclude patterns](https://typescript-eslint.io/troubleshooting/typed-linting/performance/#wide-includes-in-your-tsconfig)
- [Sheriff files options](/docs/configuration#files)
- [Sheriff pathsOverrides options](/docs/configuration#pathsoverrides)
  - [wide-globs-in-parseroptionsproject](https://typescript-eslint.io/troubleshooting/typed-linting/monorepos/#wide-globs-in-parseroptionsproject)
