This page documents the ESLint configuration for the TypeScript compiler repository, including core rules, custom rules, and file-specific configurations. For automated code formatting, see Code Formatting. For broader code quality infrastructure, see Code Quality Tools.
ESLint enforces code quality standards across the TypeScript codebase through a combination of:
@internal usage).src/, scripts/, lib/, etc.).The configuration is defined in eslint.config.mjs1-262 using the flat config format and executed via the lint task in the build system Herebyfile.mjs559-583
Sources: eslint.config.mjs1-262 scripts/eslint/rules/
The configuration uses tseslint.config() to compose multiple configuration objects, each targeting specific file patterns or providing specific rule sets eslint.config.mjs21-262
| Package | Version | Purpose |
|---|---|---|
eslint | ^10.1.0 | Core ESLint engine package.json64 |
typescript-eslint | ^8.57.2 | TypeScript-specific rules and parser package.json82 |
@eslint/js | ^10.0.1 | ESLint recommended JavaScript rules package.json45 |
eslint-plugin-regexp | ^3.1.0 | RegExp best practices and security package.json65 |
globals | ^17.4.0 | Global variable definitions for environments package.json68 |
Sources: package.json41-84 eslint.config.mjs1-10
The configuration also loads custom rules dynamically from the scripts/eslint/rules/ directory using fs.readdirSync eslint.config.mjs16-18
The configuration extends recommended rule sets from the core plugins to establish a baseline of quality:
Sources: eslint.config.mjs37-40
Selected rules from the base configurations are customized to fit the TypeScript project's coding style:
| Rule | Value | Rationale |
|---|---|---|
dot-notation | error | Enforce consistent property access eslint.config.mjs62 |
eqeqeq | error | Require === and !== eslint.config.mjs63 |
no-var | error | Enforce let/const over var eslint.config.mjs66 |
prefer-const | error | Use const for never-reassigned variables eslint.config.mjs68 |
no-restricted-syntax | error | Disallow null in favor of undefined eslint.config.mjs71-80 |
@typescript-eslint/naming-convention | error | Enforce specific naming patterns eslint.config.mjs102-143 |
@typescript-eslint/no-unused-vars | warn | Allow _ prefix for unused vars eslint.config.mjs93-100 |
Sources: eslint.config.mjs59-143
The @typescript-eslint/naming-convention rule enforces TypeScript-specific patterns, such as forbidding the "I" prefix for interfaces eslint.config.mjs108-110:
Sources: eslint.config.mjs102-143
The repository maintains local rules to enforce patterns unique to the compiler codebase.
Sources: eslint.config.mjs42-47 scripts/eslint/rules/
jsdoc-formatValidates JSDoc comment usage, particularly @internal annotations and multiple JSDoc blocks scripts/eslint/rules/jsdoc-format.cjs6-23:
| Check | Error Message |
|---|---|
@internal in non-JSDoc comment | @internal should not appear in non-JSDoc comment... scripts/eslint/rules/jsdoc-format.cjs13 |
@internal not in final JSDoc | @internal should only appear in final JSDoc comment... scripts/eslint/rules/jsdoc-format.cjs14 |
| Multiple JSDoc comments | Declaration has multiple JSDoc comments. scripts/eslint/rules/jsdoc-format.cjs15 |
@internal on unexported declaration | @internal should not appear on an unexported declaration. scripts/eslint/rules/jsdoc-format.cjs17 |
@internal on private member | @internal should not appear on a private declaration. scripts/eslint/rules/jsdoc-format.cjs18 |
Sources: scripts/eslint/rules/jsdoc-format.cjs1-147
argument-triviaRequires trivial arguments (literals, undefined, null, true, false) to be annotated with parameter names for clarity scripts/eslint/rules/argument-trivia.cjs33-46:
The rule uses TypeScript's type checker via context.sourceCode.parserServices.program.getTypeChecker() to verify parameter names match the comments scripts/eslint/rules/argument-trivia.cjs122-125
Sources: scripts/eslint/rules/argument-trivia.cjs1-180
only-arrow-functionsDisallows traditional function expressions in favor of arrow functions, with exceptions for named function declarations and methods scripts/eslint/rules/only-arrow-functions.cjs6-24
Sources: scripts/eslint/rules/only-arrow-functions.cjs1-95
no-keywordsPrevents using TypeScript keywords (e.g., abstract, declare, readonly) as variable or parameter names to avoid ambiguity scripts/eslint/rules/no-keywords.cjs6-18
Sources: scripts/eslint/rules/no-keywords.cjs1-88
debug-assertEnforces that Debug.assert() calls include a failure message as the second parameter scripts/eslint/rules/debug-assert.cjs6-17
Sources: scripts/eslint/rules/debug-assert.cjs1-69
js-extensionsRequires .js extensions in relative import paths, as TypeScript uses .js extensions for module resolution in modern Node.js environments scripts/eslint/rules/js-extensions.cjs6-18
Sources: scripts/eslint/rules/js-extensions.cjs1-78
no-in-operatorDisallows the in operator, suggesting explicit property checks instead scripts/eslint/rules/no-in-operator.cjs6-15
Sources: scripts/eslint/rules/no-in-operator.cjs1-33
The configuration applies different rule sets based on file patterns to account for varying environments (browser vs. node) and project roles (compiler vs. scripts).
Sources: eslint.config.mjs179-260
src/**Source code files use type-checking rules via a specific TSConfig eslint.config.mjs180-188 It restricts the use of Node.js globals like setTimeout to ensure compatibility across environments eslint.config.mjs192-211
Sources: eslint.config.mjs180-213
src/lib/*.d.tsLibrary definition files have most rules disabled to allow standard library patterns (like var or shadowed names) that are otherwise forbidden in the compiler eslint.config.mjs229-254
Sources: eslint.config.mjs229-254
**/*.mjsES modules are restricted from using CommonJS-specific globals like __dirname or require eslint.config.mjs166-178
Sources: eslint.config.mjs166-178
The lint task is defined in Herebyfile.mjs and executes the eslint CLI Herebyfile.mjs559-583
Sources: Herebyfile.mjs559-583
The task implementation uses exec from build utilities to run the linter and enforces a zero-warning policy Herebyfile.mjs567-579
The linting process is validated in CI pipelines:
npm run lint or hereby lint package.json97--fix flag can be passed via command line options to hereby Herebyfile.mjs576-578Sources: package.json88-101 Herebyfile.mjs559-583
Files and directories excluded from linting to prevent processing generated artifacts or third-party code eslint.config.mjs24-35:
node_modules/built/ (compiler output)tests/ (baselines and test cases)lib/ (LKG artifacts)src/lib/*.generated.d.tsSources: eslint.config.mjs24-35
Refresh this wiki