पाठ 19 / 27

typescript-eslint से TypeScript Linting

Type-aware rules के साथ TypeScript lint करने के लिए flat config में typescript-eslint जोड़ें।

TypeScript के लिए flat config

typescript-eslint तैयार config helper देता है जो parser, plugin और 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 (जैसे no-floating-promises) को parserOptions.projectService: true चाहिए। वे ज्यादा bugs पकड़ते हैं पर धीमे चलते हैं, इसलिए जहाँ लाभ हो वहीं चालू करें।