Lint Rules

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;
}
correctness/noCatchAssign.js:5:3 lint/correctness/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;
}