ESLint

ESLint is the standard static analysis tool for identifying and fixing problematic patterns in JavaScript and TypeScript codebases.

Modern Flat Config (eslint.config.js)

In ESLint v9+, the legacy .eslintrc.* format is superseded by Flat Config (eslint.config.js), which uses native ES module exports:

// eslint.config.js
import js from '@eslint/js';
import reactPlugin from 'eslint-plugin-react';

export default [
  // Recommended standard rules
  js.configs.recommended,

  // React configuration
  {
    files: ['**/*.{js,jsx,mjs,cjs}'],
    plugins: {
      react: reactPlugin,
    },
    languageOptions: {
      parserOptions: {
        ecmaFeatures: {
          jsx: true,
        },
      },
    },
    rules: {
      'no-unused-vars': 'warn',
      'react/prop-types': 'off', // Disable prop-types in favor of TypeScript
      'react/react-in-jsx-scope': 'off', // Not needed with React 17+ JSX transform
    },
  },

  // Global ignores
  {
    ignores: ['node_modules/**', '.next/**', 'out/**', 'dist/**'],
  },
];

Running ESLint via CLI

# Run lint check across the project
npx eslint .

# Automatically fix fixable styling and formatting issues
npx eslint . --fix

Inline Rule Overrides

Disable a rule for a specific line:

// eslint-disable-next-line no-console
console.log('Debugging log output');

Disable a rule for an entire file (place at the very top):

/* eslint-disable react/prop-types */
Recommended Reading
Sponsored
JavaScript: The Definitive Guide
The JS Bible
JavaScript: The Definitive Guide
By David FlanaganView on Amazon