eslint-config

mcclowes's avatarfrom mcclowes

Use when configuring ESLint - covers flat config, TypeScript integration, and custom rules

⭐3stars🔀0forks📁View on GitHub🕐Updated Jan 1, 2026⬇️1downloads

When & Why to Use This Skill

This Claude skill provides comprehensive guidance for configuring ESLint, specializing in the modern Flat Config system, seamless TypeScript integration, and the implementation of custom linting rules. It helps developers maintain high code quality, enforce consistent coding standards, and streamline the transition from legacy configurations to the latest ESLint standards.

Use Cases

  • Setting up a modern ESLint Flat Config (eslint.config.js) for new JavaScript or TypeScript projects to ensure optimized linting performance.
  • Migrating existing projects from legacy .eslintrc formats to the new Flat Config system with minimal friction.
  • Integrating TypeScript-ESLint for type-aware static analysis and enforcing strict type-checking rules across the codebase.
  • Defining custom linting rules and naming conventions to align with specific team style guides or project requirements.
  • Configuring file-specific overrides to apply different linting standards for source code, test files, and build scripts.
nameeslint-config
descriptionUse when configuring ESLint - covers flat config, TypeScript integration, and custom rules

ESLint Configuration Best Practices

Quick Start (Flat Config)

// eslint.config.js
import eslint from "@eslint/js";
import tseslint from "typescript-eslint";

export default tseslint.config(
  eslint.configs.recommended,
  ...tseslint.configs.recommended,
  {
    files: ["src/**/*.ts"],
    rules: {
      "@typescript-eslint/no-unused-vars": ["error", { argsIgnorePattern: "^_" }],
    },
  },
  {
    ignores: ["dist/", "node_modules/"],
  }
);

Core Configuration

TypeScript Integration

import tseslint from "typescript-eslint";

export default tseslint.config(
  ...tseslint.configs.strictTypeChecked,
  {
    languageOptions: {
      parserOptions: {
        project: "./tsconfig.json",
      },
    },
  }
);

Custom Rules

{
  rules: {
    // Disallow console in production
    "no-console": "warn",

    // Require explicit return types
    "@typescript-eslint/explicit-function-return-type": "error",

    // Prefer const
    "prefer-const": "error",

    // No floating promises
    "@typescript-eslint/no-floating-promises": "error",
  }
}

File-Specific Rules

export default [
  {
    files: ["src/**/*.ts"],
    rules: { /* production rules */ }
  },
  {
    files: ["**/*.test.ts", "__tests__/**/*.ts"],
    rules: {
      "@typescript-eslint/no-explicit-any": "off",
      "@typescript-eslint/no-non-null-assertion": "off",
    }
  },
  {
    files: ["scripts/**/*.ts"],
    rules: {
      "no-console": "off",
    }
  }
];

Common Patterns for Language Projects

Parser/Interpreter Specific

{
  rules: {
    // Allow switch fallthrough for token parsing
    "no-fallthrough": ["error", { commentPattern: "falls?\\s*through" }],

    // Allow bitwise for flags
    "no-bitwise": "off",

    // Complex functions in interpreters
    "complexity": ["warn", 20],
    "max-depth": ["warn", 5],
  }
}

Naming Conventions

{
  rules: {
    "@typescript-eslint/naming-convention": [
      "error",
      { selector: "interface", format: ["PascalCase"] },
      { selector: "typeAlias", format: ["PascalCase"] },
      { selector: "enum", format: ["PascalCase"] },
      { selector: "enumMember", format: ["UPPER_CASE"] },
    ]
  }
}

Migration from Legacy Config

// Old: .eslintrc.json
{
  "extends": ["eslint:recommended"],
  "rules": { "semi": "error" }
}

// New: eslint.config.js
import eslint from "@eslint/js";
export default [
  eslint.configs.recommended,
  { rules: { semi: "error" } }
];

Scripts

{
  "scripts": {
    "lint": "eslint src/",
    "lint:fix": "eslint src/ --fix"
  }
}

Reference Files