Lesson 19 / 27

Linting TypeScript with typescript-eslint

Add typescript-eslint to a flat config to lint TypeScript with type-aware rules.

Flat config for TypeScript

typescript-eslint ships a ready-made config helper that combines the parser, plugin and recommended rules.

// eslint.config.mjs
import js from '@eslint/js';
import tseslint from 'typescript-eslint';
import prettier from 'eslint-config-prettier';

export default tseslint.config(
  js.configs.recommended,
  ...tseslint.configs.recommended,
  prettier,
);

Type-aware rules (such as no-floating-promises) need parserOptions.projectService: true. They catch more bugs but run slower, so enable them where they pay off.