Index of every page on this site: llms.txt
All skills
Run it yourself

ESLint 9 flat config patterns for JavaScript and TypeScript projects. Covers migration from .eslintrc, defineConfig, TypeScript config files, plugin setup, and common rule configurations. Use when setting up ESLint, migrating to flat config, configuring linting rules, or when the user asks about ESLint configuration or code quality tooling.

Use this Skill: https://skilld.dev/gh/grahamcrackers/skills/eslint-9

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

SKILL.md

≈88 tokens for metadata: the name and description. ≈1.5k when used: this file.

Description uses 4.4% of example budget

Before choosing a Skill, your Agent reads its name and description. All available Skills share that space.

  • A shorter description leaves more room for other Skills. This entry exceeds our 1% size suggestion.

In our Claude Code example, all Skill names and descriptions share 8,000 characters. This Skill uses ≈353 characters, or 4.4%.

The 1% threshold is a size suggestion. Longer descriptions can still fit.

Your model, settings, and other Skills decide how much text your Agent can read.

Example settings and source

The example uses a 200k-token context and default Claude Code settings. The count includes the name, description, separators, and when_to_use when present. Codex also counts local file paths.

Skit's source and limits: Codex 0.160.1, Claude Code 2.1.292.

ESLint 9 Flat Config Patterns

Overview

ESLint 9 uses flat config (eslint.config.js) as the default. The legacy .eslintrc.* format is deprecated.

Key differences from .eslintrc:

  • Single config file, explicit imports — no magic extends strings.
  • Config is an exported array of config objects, applied in order.
  • Plugins are imported directly, not referenced by string name.
  • Glob patterns in files replace the old overrides system.

Basic Setup

JavaScript

// eslint.config.js
import js from "@eslint/js";

export default [
    js.configs.recommended,
    {
        rules: {
            "no-unused-vars": "warn",
            "no-console": "warn",
        },
    },
];

TypeScript

npm install -D eslint @eslint/js typescript-eslint
// eslint.config.ts
import js from "@eslint/js";
import tseslint from "typescript-eslint";

export default tseslint.config(js.configs.recommended, tseslint.configs.recommended, {
    rules: {
        "@typescript-eslint/no-unused-vars": ["warn", { argsIgnorePattern: "^_", varsIgnorePattern: "^_" }],
    },
});

typescript-eslint exports a config() helper that provides type safety and handles array flattening.

TypeScript Config Files

ESLint 9 supports eslint.config.ts natively — no extra packages needed. Use it for full type checking of your config:

import type { Linter } from "eslint";

defineConfig

ESLint provides defineConfig for type-safe configs without typescript-eslint:

import { defineConfig } from "eslint/config";
import js from "@eslint/js";

export default defineConfig([
    js.configs.recommended,
    {
        files: ["**/*.js"],
        rules: {
            "no-console": "warn",
        },
    },
]);

defineConfig auto-flattens nested arrays and provides IntelliSense for rule names.

Adding Plugins

Plugins are imported and assigned to a namespace:

import reactPlugin from "eslint-plugin-react";
import reactHooksPlugin from "eslint-plugin-react-hooks";

export default tseslint.config(js.configs.recommended, tseslint.configs.recommended, {
    files: ["**/*.{tsx,jsx}"],
    plugins: {
        react: reactPlugin,
        "react-hooks": reactHooksPlugin,
    },
    rules: {
        "react/jsx-no-target-blank": "error",
        "react-hooks/rules-of-hooks": "error",
        "react-hooks/exhaustive-deps": "warn",
    },
    settings: {
        react: { version: "detect" },
    },
});

Many plugins now ship flat config presets. Check for plugin.configs["flat/recommended"] or similar exports.

Global Ignores

Use a config object with only ignores (no files) for global ignore patterns:

export default tseslint.config(
    { ignores: ["dist/", "node_modules/", "*.config.*", ".next/"] },
    js.configs.recommended,
    tseslint.configs.recommended,
);

Global ignores must be a standalone object — not combined with rules or files.

File-Specific Overrides

Use files globs to scope rules:

export default tseslint.config(
    js.configs.recommended,
    tseslint.configs.recommended,

    // Stricter rules for source code
    {
        files: ["src/**/*.{ts,tsx}"],
        rules: {
            "@typescript-eslint/explicit-function-return-type": "warn",
            "@typescript-eslint/no-explicit-any": "error",
        },
    },

    // Relaxed rules for tests
    {
        files: ["**/*.test.{ts,tsx}", "**/*.spec.{ts,tsx}"],
        rules: {
            "@typescript-eslint/no-explicit-any": "off",
            "@typescript-eslint/no-non-null-assertion": "off",
        },
    },

    // Config files (CommonJS)
    {
        files: ["*.config.{js,cjs,mjs}"],
        languageOptions: {
            sourceType: "commonjs",
        },
    },
);

Prettier Integration

Use eslint-config-prettier to disable formatting rules that conflict with Prettier:

import prettierConfig from "eslint-config-prettier";

export default tseslint.config(
    js.configs.recommended,
    tseslint.configs.recommended,
    prettierConfig, // must be last to override formatting rules
);

Don't use eslint-plugin-prettier — let Prettier handle formatting separately.

Common React + TypeScript Config

A complete config for a React + TypeScript project:

// eslint.config.ts
import js from "@eslint/js";
import tseslint from "typescript-eslint";
import reactPlugin from "eslint-plugin-react";
import reactHooksPlugin from "eslint-plugin-react-hooks";
import prettierConfig from "eslint-config-prettier";

export default tseslint.config(
    { ignores: ["dist/", "node_modules/", ".next/"] },

    js.configs.recommended,
    tseslint.configs.recommended,

    {
        files: ["**/*.{tsx,jsx}"],
        plugins: {
            react: reactPlugin,
            "react-hooks": reactHooksPlugin,
        },
        rules: {
            "react-hooks/rules-of-hooks": "error",
            "react-hooks/exhaustive-deps": "warn",
        },
        settings: {
            react: { version: "detect" },
        },
    },

    {
        rules: {
            "@typescript-eslint/no-unused-vars": ["warn", { argsIgnorePattern: "^_", varsIgnorePattern: "^_" }],
            "@typescript-eslint/consistent-type-imports": ["warn", { prefer: "type-imports" }],
        },
    },

    prettierConfig,
);

Migration from .eslintrc

  1. Run the migration tool: npx @eslint/migrate-config .eslintrc.json
  2. Review the generated eslint.config.mjs — the tool handles most conversions.
  3. Replace string-based plugin references with direct imports.
  4. Replace extends strings with imported config arrays.
  5. Convert overrides to separate config objects with files globs.
  6. Delete .eslintrc.* and .eslintignore files.

Debugging

Inspect the resolved config for any file:

npx eslint --inspect-config

This launches an interactive viewer showing which rules apply to each file and where they come from.

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts8mo4 checks · Risk SAFE
  • Gen Agent Trust Hub8mo

    This skill provides documentation and configuration examples for ESLint 9. It includes standard commands to install and use well-known development tools.

  • Socket8mo

    No alerts

  • Snyk8mo

    Risk: LOW · No issues

  • Runlayer8mo

    1 file scanned · No issues

Signed by skilld at ca83de4. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 months ago.

Dormantupdated 9 months ago

README badge

README badge for grahamcrackers/skills/eslint-9