TypeScript ESLint

8.58.2 · active · verified Sun Apr 19

typescript-eslint is a comprehensive tooling ecosystem that enables ESLint to lint TypeScript code. It integrates the TypeScript compiler's type information with ESLint's powerful static analysis capabilities, allowing developers to enforce code style, best practices, and catch logical errors specifically within TypeScript projects. The project is actively maintained, with frequent patch releases occurring weekly and minor versions released as needed. Major versions are released non-periodically to accommodate breaking changes or significant feature additions. Currently stable at version 8.58.2, typescript-eslint differentiates itself by providing over 100 specialized rules and robust support for modern ESLint 'flat' configurations, making it the de-facto standard for type-aware linting in the TypeScript ecosystem. It complements the TypeScript compiler by focusing on code quality and stylistic issues beyond pure type checking.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to set up `typescript-eslint` with ESLint's flat configuration format, including recommended rules, type-aware linting, and custom rule overrides for both TypeScript and JavaScript files.

/* eslint.config.mjs */
// @ts-check

import js from '@eslint/js';
import tseslint from 'typescript-eslint';
import { defineConfig } from 'eslint/config';

export default defineConfig(
  js.configs.recommended,
  ...tseslint.configs.recommended,
  {
    files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'],
    languageOptions: {
      parserOptions: {
        project: true,
        tsconfigRootDir: import.meta.dirname,
      },
    },
    rules: {
      // Example custom rule: enforce consistent usage of type imports
      '@typescript-eslint/consistent-type-imports': 'error',
      // Example: disable a base ESLint rule that has a TypeScript equivalent
      'no-unused-vars': 'off',
      '@typescript-eslint/no-unused-vars': [
        'warn',
        { 'argsIgnorePattern': '^_' }
      ]
    },
  }
);

/* Example tsconfig.json */
// {
//   "compilerOptions": {
//     "target": "ES2022",
//     "module": "ESNext",
//     "esModuleInterop": true,
//     "forceConsistentCasingInFileNames": true,
//     "strict": true,
//     "skipLibCheck": true,
//     "jsx": "react-jsx",
//     "lib": ["ES2022", "DOM", "DOM.Iterable"],
//     "include": ["src"]
//   }
// }

view raw JSON →