prefer-readonly
Configuration
rslint.config.ts
Rule Details
Require private members to be marked as readonly if they're never modified outside of the constructor.
Member variables with the private modifier or # private fields are only accessible within their declaring class. If that member is never reassigned after initialization (either at declaration or in the constructor), it should be marked as readonly to communicate intent and prevent accidental mutation.
Examples of incorrect code for this rule:
Examples of correct code for this rule:
Options
onlyInlineLambdas
When set to true, only checks members that are assigned an arrow function expression. This can be useful when a project wants to enforce readonly only for function-like members.