#111591Enforce type-checked linting for the TypeScript sources
Description
Goal
The ESLint run over Build/Sources/TypeScript uses the typescript-eslint preset recommended-type-checked, plus typescript-eslint/no-non-null-assertion@, with no rule switched off.
Motivation
The TypeScript build runs with strict, so strictNullChecks is enabled. Yet values typed as any and non-null assertions (!) bypass those checks without a word, for example in backend/user-pass-login.ts:
protected options: any;
// ...
const usernameField: HTMLInputElement = document.querySelector(this.options.usernameField);
querySelector() returns any here instead of HTMLInputElement | null, and the missing null handling is not reported. The type-aware lint setup is already in place (parserOptions.project in Build/eslint.config.mjs), so the rules only have to be enabled and their findings resolved.
Plan
- Switch
Build/eslint.config.mjsfromrecommendedtorecommended-type-checked. Every rule that still has findings is listed with"off", so the lint stays green and all other rules of the preset are enforced from then on.no-non-null-assertionis listed with"off"as well. - Per rule, one task as a subtask of this epic: resolve its findings with real types, not with casts or assertions, and remove its
"off"line. Large rules may be split per extension. - The epic is done when no
"off"line for these rules remains.
Open findings (typescript-eslint 8.58.1)
| Rule | Findings |
|---|---|
| no-non-null-assertion | 1948 |
| no-unsafe-member-access | 1016 |
| no-floating-promises | 971 |
| no-unsafe-assignment | 701 |
| no-unsafe-argument | 402 |
| no-unsafe-call | 390 |
| no-unsafe-return | 62 |
| require-await | 43 |
| no-misused-promises | 42 |
| no-unsafe-enum-comparison | 41 |
| only-throw-error | 32 |
| no-base-to-string | 21 |
| no-redundant-type-constituents | 14 |
| prefer-promise-reject-errors | 7 |
| await-thenable | 7 |
| restrict-template-expressions | 2 |
The findings partly overlap: resolving an any often clears several no-unsafe-* findings at once.
Related: #102560, #111568
Reviews 1
Subtasks 17
- #111589Report unsafe assignments of any values in TypeScript
- #111593Restrict template literal expressions in TypeScript
- #111594Await only promises in TypeScript sources
- #111595Reject promises only with Error objects in TypeScript
- #111596Remove redundant union members in TypeScript types
- #111597Avoid default object stringification in TypeScript
- #111598Throw only Error objects in TypeScript sources
- #111599Compare enums against enum members in TypeScript
- #111600Fix promises passed where void is expected in TypeScript
- #111601Remove async from functions without await in TypeScript
- #111602Resolve unsafe returns of any values in TypeScript
- #111603Resolve unsafe calls of any values in TypeScript
- #111604Resolve unsafe any arguments in TypeScript
- #111605Handle floating promises in TypeScript sources
- #111606Resolve unsafe member access on any values in TypeScript
- #111607Replace non-null assertions in TypeScript sources
- #111608Lint TypeScript with the recommended-type-checked preset
History 17
-
Benjamin Kott changed subtask #111593 11/25/26, 14:25
-
Benjamin Kott changed subtask #111594 11/25/26, 14:25
-
Benjamin Kott changed subtask #111595 11/25/26, 14:25
-
Benjamin Kott changed subtask #111596 11/25/26, 14:25
-
Benjamin Kott changed subtask #111597 11/25/26, 14:26
-
Benjamin Kott changed subtask #111598 11/25/26, 14:26
-
Benjamin Kott changed subtask #111599 11/25/26, 14:26
-
Benjamin Kott changed subtask #111600 11/25/26, 14:26
-
Benjamin Kott changed subtask #111601 11/25/26, 14:27
-
Benjamin Kott changed subtask #111602 11/25/26, 14:27
-
Benjamin Kott changed subtask #111603 11/25/26, 14:27
-
Benjamin Kott changed subtask #111604 11/25/26, 14:27
-
Benjamin Kott changed subtask #111589 11/25/26, 14:28
-
Benjamin Kott changed subtask #111605 11/25/26, 14:28
-
Benjamin Kott changed subtask #111606 11/25/26, 14:28
-
Benjamin Kott changed subtask #111607 11/25/26, 14:28
-
Benjamin Kott changed subtask #111608 11/25/26, 14:33