noCatchAssign
Diagnostic Category: lint/suspicious/noCatchAssign
Since: v1.0.0
Sources:
- Same as:
no-ex-assign
Disallow reassigning exceptions in catch clauses.
Assignment to a catch
parameter can be misleading and confusing.
It is often unintended and indicative of a programmer error.
Examples
Section titled ExamplesInvalid
Section titled Invalidcode-block.js:5:3 lint/suspicious/noCatchAssign ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Reassigning a catch parameter is confusing.
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.