noCatchAssign (since v0.7.0)
This rule is recommended by Rome.
Disallow reassigning exceptions in catch clauses
Examples
Invalid
try {
} catch (e) {
e;
e = 10;
}
suspicious/noCatchAssign.js:5:3 lint/suspicious/noCatchAssign ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Do not reassign catch parameters.
3 │ } catch (e) {
4 │ e;
> 5 │ e = 10;
│ ^
6 │ }
7 │
ℹ The catch parameter is declared here
1 │ try {
2 │
> 3 │ } catch (e) {
│ ^
4 │ e;
5 │ e = 10;
ℹ Use a local variable instead.
Valid
try {
} catch (e) {
let e = 10;
e = 100;
}