prefer-readonly-parameter-types
Added in v0.1.14Configuration
rslint.config.ts
Requires function parameters to have deeply readonly types, preventing code from accidentally mutating values supplied by callers.
Rule Details
Examples of incorrect code for this rule:
Examples of correct code for this rule:
The rule checks nested property and element types, so a readonly outer property whose value is mutable is still reported.
Options
allow(default[]): type specifiers that the rule should accept without checking their readonlyness. String names andfile,lib, orpackagespecifiers are supported.checkParameterProperties(defaulttrue): check TypeScript constructor parameter properties.ignoreInferredTypes(defaultfalse): skip parameters without an explicit type annotation.treatMethodsAsReadonly(defaultfalse): treat method declarations as readonly while checking object types. This is useful for types such asReadonlySetandReadonlyMap.