Skip to content

Instantly share code, notes, and snippets.

@nzakas
Created May 27, 2025 16:08
Show Gist options
  • Save nzakas/a7531d0c175f1b15c40f27cf8826d48e to your computer and use it in GitHub Desktop.
Save nzakas/a7531d0c175f1b15c40f27cf8826d48e to your computer and use it in GitHub Desktop.
Using eslint-config-airbnb with ESLint v9
/*
* To install `eslint-config-airbnb`, run:
* npm install -D eslint-config-airbnb --force
*
* The --force flag is necessary because `eslint-config-airbnb` has a
* peer dependency on `eslint@^8.0.0`, which may conflict with other
* packages in your project.
*
* After installing, you'll need to use `npm install --force` when
* installing other packages to avoid conflicts with the peer dependencies.
*/
import js from "@eslint/js";
import { defineConfig } from "eslint/config";
import { FlatCompat } from "@eslint/eslintrc";
import { fileURLToPath } from "node:url";
import path from "node:path";
// 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: js.configs.recommended,
});
export default defineConfig([
{
files: ["**/*.{js,mjs,cjs}"],
extends: [compat.extends("airbnb")]
},
]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment