ESLint flat config is quite different from the previous format. To help understand the "flat config" the following pointers helped me:

  • Config is nothing more complicated than an array of objects. This is simpler than the previous format but might not be obvious at first.
  • Each object in the array can define whatever ESLint configuration it wants
  • Each object can target certain files by including or ignoring a set of files (useful because .eslintignore is no longer available)
  • Each file being linted will have all matching configurations applied - I believe in the order they appear in the array

Setup for VS Code - at the time of writing you'll need:

  • ESLint plugin v3.0.5 or above (this currently requires "switch to pre-release version") in the plugin's installation page
  • Add "eslint.useFlatConfig": true to your settings.json (this was previously eslint.experimental.useFlatConfig)

Install the following dependencies:

    yarn add --dev \
      eslint \
      @eslint/js \
      typescript-eslint \
      --

Use the following eslint.config.mjs file to get you started (locate it alongside package.json). This provides defaults from https://typescript-eslint.io/getting-started/. This config additionally allows you to add ignored files, which is useful because .eslintignore is no longer available. NB the config is 'just Javascript' so you can make additional changes. This uses module.exports which avoids the need to add type: "module" to package.json:

// @ts-check

import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';

// https://typescript-eslint.io/getting-started/

const ignores = [
  '**/*.js',
];

export default tseslint.config(
  {
    ...eslint.configs.recommended,
    ignores,
  },
  ...tseslint.configs.recommended.map((config) => ({
    ...config,
    ignores,
  })),
);

Pro:

  • It's actually quite clean
  • The config above is a lot smaller than the sticky nest of stuff I had accumulated under the old config

Con:

  • I was previously using AirBnB config but decided I needed to dump that because it's not (yet) available in flat config format
  • Applying a different set of linting rules meant a raft of (mostly simple) changes across my codebase
Answer from David Carboni on Stack Overflow
🌐
ESLint
eslint.org › docs › latest › use › configure › migration-guide
Configuration Migration Guide - ESLint - Pluggable JavaScript Linter
First, install the @eslint/eslintrc package: ... Then, import FlatCompat and create a new instance to convert an existing eslintrc config.
🌐
ESLint
eslint.org › blog › 2024 › 05 › eslint-compatibility-utilities
Introducing ESLint Compatibility Utilities - ESLint - Pluggable JavaScript Linter
// eslint.config.js import { fixupConfigRules } from "@eslint/compat"; import { FlatCompat } from "@eslint/eslintrc"; const flatCompat = new FlatCompat(); export default [ ...fixupConfigRules( flatCompat.extends("my-config") ) // other config ];
🌐
GitHub
github.com › vercel › next.js › discussions › 49337
How to use new "flat config" approach in Eslint? · vercel/next.js · Discussion #49337
import path from "node:path"; import { fileURLToPath } from "url"; import { FlatCompat } from "@eslint/eslintrc"; import { defineFlatConfig } from "eslint-define-config"; import ts from "@typescript-eslint/eslint-plugin"; import tsParser from "@typescript-eslint/parser"; import js from "@eslint/js"; const baseDirectory = path.dirname(fileURLToPath(import.meta.url)); const compat = new FlatCompat({ baseDirectory, resolvePluginsRelativeTo: baseDirectory, }); export default defineFlatConfig([ { files: ["**/*.{ts,tsx}"], plugins: { "@typescript-eslint": ts, }, languageOptions: { parser: tsParser, }, rules: { ...js.configs.recommended.rules, ...ts.configs.recommended.rules, }, }, compat.config({ overrides: [ { files: "ui/**/*.{ts,tsx}", extends: "next/core-web-vitals" }, ], }) ]);
Author   vercel
🌐
Nx
nx.dev › docs › technologies › eslint › guides › flat-config
Switching to ESLint's Flat Config Format | Nx
It will also convert the base .eslintrc.json and .eslintignore. Section titled “Correctness and best practices” · The purpose of this generator is to create a flat config that works the same way as the original JSON config did. Depending on the complexity of your original config, it may be using the FlatCompat utility to provide a compatibility wrapper around parts of the original config.
🌐
Raul Melo
raulmelo.me › en › blog › migration-eslint-to-flat-config
Embrace the Future: Navigating the New Flat Configuration of ESLint · Raul Melo
July 20, 2023 - This package provides a mechanism for backward compatibility between eslint and flat config during the transition period. We can use extends, env, plugins, or a full configuration (check their README for more details).
🌐
Medium
medium.com › @1608naman › a-flat-attempt-at-the-eslint-flat-config-393005212d67
A Flat Attempt at the ESLint Flat Config | by Naman Dhingra | Medium
September 28, 2024 - The @eslint/eslintrc package offers a FlatCompat class that helps translate your existing .eslintrc configurations into the new flat config format.
Top answer
1 of 1
9

ESLint flat config is quite different from the previous format. To help understand the "flat config" the following pointers helped me:

  • Config is nothing more complicated than an array of objects. This is simpler than the previous format but might not be obvious at first.
  • Each object in the array can define whatever ESLint configuration it wants
  • Each object can target certain files by including or ignoring a set of files (useful because .eslintignore is no longer available)
  • Each file being linted will have all matching configurations applied - I believe in the order they appear in the array

Setup for VS Code - at the time of writing you'll need:

  • ESLint plugin v3.0.5 or above (this currently requires "switch to pre-release version") in the plugin's installation page
  • Add "eslint.useFlatConfig": true to your settings.json (this was previously eslint.experimental.useFlatConfig)

Install the following dependencies:

    yarn add --dev \
      eslint \
      @eslint/js \
      typescript-eslint \
      --

Use the following eslint.config.mjs file to get you started (locate it alongside package.json). This provides defaults from https://typescript-eslint.io/getting-started/. This config additionally allows you to add ignored files, which is useful because .eslintignore is no longer available. NB the config is 'just Javascript' so you can make additional changes. This uses module.exports which avoids the need to add type: "module" to package.json:

// @ts-check

import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';

// https://typescript-eslint.io/getting-started/

const ignores = [
  '**/*.js',
];

export default tseslint.config(
  {
    ...eslint.configs.recommended,
    ignores,
  },
  ...tseslint.configs.recommended.map((config) => ({
    ...config,
    ignores,
  })),
);

Pro:

  • It's actually quite clean
  • The config above is a lot smaller than the sticky nest of stuff I had accumulated under the old config

Con:

  • I was previously using AirBnB config but decided I needed to dump that because it's not (yet) available in flat config format
  • Applying a different set of linting rules meant a raft of (mostly simple) changes across my codebase
🌐
npm
npmjs.com › package › @eslint › eslintrc
eslint/eslintrc
Here's how you use it inside of your eslint.config.js file: import { FlatCompat } from "@eslint/eslintrc"; import js from "@eslint/js"; import path from "path"; import { fileURLToPath } from "url"; // mimic CommonJS variables -- not needed if using CommonJS const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); const compat = new FlatCompat({ baseDirectory: __dirname, // optional; default: process.cwd() resolvePluginsRelativeTo: __dirname, // optional recommendedConfig: js.configs.recommended, // optional unless you're using "eslint:recommended" allConfi
      » npm install @eslint/eslintrc
    
Published   Mar 06, 2026
Version   3.3.5
Author   Nicholas C. Zakas
Find elsewhere
🌐
Medium
allalmohamedlamine.medium.com › eslint-flat-config-and-new-system-an-ultimate-deep-dive-2023-46aa151cbf2b
Eslint flat config and new system an ultimate deep dive 2023 | by Mohamed Lamine Allal | Medium
November 27, 2023 - Using the FlatCompat class allows you to continue using all of your existing eslintrc files while optimizing them for use with flat config. We envision this as a necessary transitional step to allow the ecosystem to slowly convert over to flat ...
🌐
ESLint
eslint.org › blog › 2022 › 08 › new-config-system-part-2
ESLint's new config system, Part 2: Introduction to flat config - ESLint - Pluggable JavaScript Linter
import { FlatCompat } from "@eslint/eslintrc"; import path from "path"; import { fileURLToPath } from "url"; // mimic CommonJS variables -- not needed if using CommonJS const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); const compat = new FlatCompat({ baseDirectory: __dirname }); export default [ // mimic ESLintRC-style extends ...compat.extends("standard", "example"), // mimic environments ...compat.env({ es2020: true, node: true }), // mimic plugins ...compat.plugins("airbnb", "react"), // translate an entire config ...compat.config({ plugins: ["airbnb", "react"], extends: "standard", env: { es2020: true, node: true }, rules: { semi: "error" } }) ];
🌐
GitHub
github.com › eslint › eslintrc
GitHub - eslint/eslintrc: The legacy ESLintRC config file format for ESLint · GitHub
Here's how you use it inside of your eslint.config.js file: import { FlatCompat } from "@eslint/eslintrc"; import js from "@eslint/js"; import path from "path"; import { fileURLToPath } from "url"; // mimic CommonJS variables -- not needed if using CommonJS const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); const compat = new FlatCompat({ baseDirectory: __dirname, // optional; default: process.cwd() resolvePluginsRelativeTo: __dirname, // optional recommendedConfig: js.configs.recommended, // optional unless you're using "eslint:recommended" allConfi
Starred by 167 users
Forked by 52 users
Languages   JavaScript 99.7% | TypeScript 0.3%
🌐
Jmugliston
jmugliston.dev › blog › using-the-new-eslint-flat-config
Using the New ESLint Flat Config
import { FlatCompat } from "@eslint/eslintrc"; import path from "path"; import { fileURLToPath } from "url"; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); const compat = new FlatCompat({ baseDirectory: __dirname, }); const config = [ ...compat.extends("standard"), { files: ["**/*.js"], rules: { "no-unused-vars": "error", }, }, { files: ["packages/package-a/**/*.js"], rules: {}, }, { files: ["packages/package-b/**/*.js"], rules: { "no-unused-vars": "off", }, }, ]; export default config;
🌐
ESLint
eslint.org › blog › 2024 › 05 › eslint-configuration-migrator
Introducing the ESLint Configuration Migrator - ESLint - Pluggable JavaScript Linter
npx @eslint/migrate-config .eslintrc.json --commonjs # or yarn dlx @eslint/migrate-config .eslintrc.json --commonjs # or pnpm dlx @eslint/migrate-config .eslintrc.json --commonjs # or bunx @eslint/migrate-config .eslintrc.json --commonjs ... The goal of the configuration migrator is to reduce the likelihood of running into errors when you use it for the first time, and as a result, it aggressively employs FlatCompat and the compatibility utilities.
🌐
DEV Community
dev.to › psychosynthesis › new-eslint-flat-config-file-format-example-217c
New ESLint flat config file format example - DEV Community
April 12, 2024 - import path from "path"; import { fileURLToPath } from "url"; import { FlatCompat } from "@eslint/eslintrc"; import pluginJs from "@eslint/js"; // mimic CommonJS variables -- not needed if using CommonJS const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); const compat = new FlatCompat({ baseDirectory: __dirname, recommendedConfig: pluginJs.configs.recommended }); export default [ ...compat.extends("standard-with-typescript").map( config => ({ ...config, files: ["**/*.tsx"], rules: { ...config.rules, "semi": "off", // For some reason the old rule is bu
🌐
Medium
medium.com › @oliviarizona › eslint-flat-config-e94d4bd11525
ESlint flat config
December 19, 2024 - Replace all .eslintrc configurations with eslint.config.js. Use import statements for plugins, parsers, and other configurations. For compatibility during migration, you can use FlatCompat to continue using existing .eslintrc configurations temporarily:
🌐
ESLint
eslint.org › docs › latest › extend › plugin-migration-flat-config
Plugin Migration to Flat Config - ESLint - Pluggable JavaScript Linter
We recommend prefixing older format configs with legacy-. For example, if your primary config is called recommended and is in flat config format, then you can also have a config named legacy-recommended that is the eslintrc config format. If you don’t want to update the config name, you can also create an additional entry in the configs object prefixed with "flat/" (for example, "flat/recommended").
🌐
npm
npmjs.com › package › @archoleat › eslint-flat-compatibility
@archoleat/eslint-flat-compatibility - npm
Start using @archoleat/eslint-flat-compatibility in your project by running `npm i @archoleat/eslint-flat-compatibility`. There are no other projects in the npm registry using @archoleat/eslint-flat-compatibility.
      » npm install @archoleat/eslint-flat-compatibility
    
Published   Oct 25, 2024
Version   1.2.1
Author   Archoleat