require-strict-mode
Require "strict": true in compilerOptions to enable TypeScript's full
set of type-safety checks.
Targeted pattern scopeโ
The compilerOptions.strict field in any tsconfig*.json file.
What this rule reportsโ
This rule reports when compilerOptions is present and compilerOptions.strict is absent or set to false. The rule does not report if compilerOptions is not defined at all, since there is no compiler configuration to check.
Why this rule existsโ
strict: true is a composite flag that enables a suite of checks designed to
catch the most common classes of type-unsafe code:
strictNullChecksโ preventsundefined/nullfrom being assigned to non-nullable types.strictFunctionTypesโ enforces contravariant function parameter types.strictBindCallApplyโ checksbind,call, andapplyargument types.strictPropertyInitializationโ ensures class properties are initialized.noImplicitAnyโ disallows implicitanyon parameters and variables.noImplicitThisโ disallowsthisexpressions with an impliedanytype.alwaysStrictโ emits"use strict"in output files.useUnknownInCatchVariablesโ typescatchclause variables asunknown.
Omitting strict: true leaves these checks disabled, allowing entire
categories of runtime errors to compile without warning.
The auto-fixer adds "strict": true to compilerOptions.
โ Incorrectโ
{
"compilerOptions": {
"target": "ES2022",
"module": "NodeNext"
}
}
None of the strict checks are active.
{
"compilerOptions": {
"strict": false
}
}
Strict mode is explicitly disabled.
โ Correctโ
{
"compilerOptions": {
"target": "ES2022",
"module": "NodeNext",
"strict": true
}
}
When not to use itโ
Disable this rule for tsconfig files used exclusively to configure type-
checking tools or test runners that operate on already-compiled code, or for
configurations that extend a strict base tsconfig and therefore inherit the
strict setting from the parent.
Package documentationโ
Rule catalog ID: R024