Helper utilities for creating ESLint configuration.
For Node.js and compatible runtimes:
npm install @eslint/config-helpers
# or
yarn add @eslint/config-helpers
# or
pnpm install @eslint/config-helpers
# or
bun add @eslint/config-helpersFor Deno:
deno add @eslint/config-helpersThe defineConfig() function allows you to specify an ESLint configuration with full type checking and additional capabilities, such as extends. Here's an example:
// eslint.config.js
import { defineConfig } from "@eslint/config-helpers";
import js from "@eslint/js";
export default defineConfig([
{
files: ["src/**/*.js"],
plugins: { js },
extends: ["js/recommended"],
rules: {
"no-var": "error",
"prefer-const": "error",
},
},
{
files: ["test/**/*.js"],
rules: {
"no-console": "off",
},
},
]);The globalIgnores() function allows you to specify patterns for files and directories that should be globally ignored by ESLint. This is useful for excluding files that you don't want to lint, such as build directories or third-party libraries. Here's an example:
// eslint.config.js
import { defineConfig, globalIgnores } from "@eslint/config-helpers";
export default defineConfig([
{
files: ["src/**/*.js"],
rules: {
"no-var": "error",
"prefer-const": "error",
},
},
globalIgnores(["node_modules/", "dist/", "coverage/"]),
]);The includeIgnoreFile() function reads a file with gitignore-style patterns (such as a .gitignore) and returns a config object with the patterns converted to a global ignores object. Pass the absolute path to the ignore file as the first argument:
// eslint.config.js
import { defineConfig, includeIgnoreFile } from "@eslint/config-helpers";
import path from "node:path";
const ignorePath = path.join(import.meta.dirname, ".gitignore");
export default defineConfig([
includeIgnoreFile(ignorePath, {
gitignoreResolution: true,
}),
// ...
]);The second argument is an optional options object:
gitignoreResolution(boolean): Controls how ignore patterns are interpreted.false(default) — patterns are resolved relative to the location of the configuration file.true— patterns are resolved relative to the location of the ignore file, matching the behavior of.gitignorefiles.
name(string): A custom name for the resulting config object.
For backwards compatibility with includeIgnoreFile() from @eslint/compat, passing a string instead of an object as the second argument is treated as equivalent to providing a value for name.
You can also pass an array of absolute paths to include multiple ignore files at once. In this case an array of config objects is returned:
// eslint.config.js
import { defineConfig, includeIgnoreFile } from "@eslint/config-helpers";
import path from "node:path";
export default defineConfig([
includeIgnoreFile(
[
path.join(import.meta.dirname, ".gitignore"),
path.join(import.meta.dirname, "packages/lib/.gitignore"),
],
{ gitignoreResolution: true },
),
// ...
]);Apache 2.0
The following companies, organizations, and individuals support ESLint's ongoing maintenance and development. Become a Sponsor to get your logo on our READMEs and website.
Technology sponsors allow us to use their products and services for free as part of a contribution to the open source ecosystem and our work.


