v5.0.0
5.0.0 (2023-01-29)
Overview
It's finally here. With this release, I am happy to announce that we are finally adding the long-awaited support for the Readonly<T>
type (#51).
With this change, we are deprecating the rule prefer-readonly-type
in favor of two new rules prefer-immutable-types
and type-declaration-immutability
.
These new rules split the responsibility of enforcing immutability. prefer-immutable-types
is all about enforcing that immutable types are used in your runtime code (type annotations), while type-declaration-immutability
is all about enforcing the immutability of type declarations (type aliases and interfaces). These rules take a different approach to enforcing immutability than the old prefer-readonly-type
rule, so be sure to check each of their documentation files.
prefer-immutable-types
is also designed to be a replacement for @typescript-eslint's prefer-readonly-parameter-types as it offers the same functionality plus more.
Dependancies
When updating, be sure to have add these two new dependencies to your project: @typescript-eslint/type-utils
@typescript-eslint/utils
Ruleset Changes
We have introduced a new ruleset called strict
. This ruleset will enforce the strictest configuration of our rules.
Note: Each rules' default configuration is in its strictest mode.
The recommended
ruleset has in turn been made a little less strict.
New Rules
Deprecated Rules
Breaking Changes
Rule and Option
prefer-tacit
now provides suggestions instead of a fixer. In turnallowFixer
has been removed from theassumeTypes
option.
Name Changes
no-method-signature
=>prefer-property-signatures
.ignoreIfReadonly
=>ignoreIfReadonlyWrapped
(nowfalse
by default).
no-let
(unchanged)allowLocalMutation
=>allowInFunctions
no-return-void
(unchanged)ignoreImplicit
=>ignoreInferredTypes
The name of all the rules and options are now plural where appropriate.
no-class
=>no-classes
.no-conditional-statement
=>no-conditional-statements
.no-expression-statement
=>no-expression-statements
.no-loop-statement
=>no-loop-statements
.no-mixed-type
=>no-mixed-types
.no-this-expression
=>no-this-expressions
.no-throw-statement
=>no-throw-statements
.no-try-statement
=>no-try-statements
.immutable-data
(unchanged)ignoreClass
=>ignoreClasses
Rulesets
Name Changes
no-object-orientation
=>no-other-paradigms
.external-recommended
split intoexternal-vanilla-recommended
andexternal-typescript-recommended
.
Rule Changes
- The deprecated rule
prefer-readonly-type
has been removed from all rulesets (exceptoff
). prefer-property-signatures
(formallyno-method-signature
) has been moved to thestylistic
ruleset.no-this-expressions
has been removed from therecommended
andlite
rulesets.@typescript-eslint/prefer-readonly-parameter-types
has been removed from list of recommended external rules.
Dependencies
- minimum supported
TypeScript
version is nowv4.0.2
. - minimum supported
Node
version is nowv16.10.0
.