src/content/docs/linter/rules/no-catch-assign.mdx
import { Tabs, TabItem } from '@astrojs/starlight/components';
<Tabs> <TabItem label="JavaScript (and super languages)" icon="seti:javascript"> ## Summary - Rule available since: `v1.0.0` - Diagnostic Category: [`lint/suspicious/noCatchAssign`](/reference/diagnostics#diagnostic-category) - This rule is **recommended**, meaning it is enabled by default. - This rule doesn't have a fix. - The default severity of this rule is [**warning**](/reference/diagnostics#warning). - Sources: - Same as [`no-ex-assign`](https://eslint.org/docs/latest/rules/no-ex-assign){
"linter": {
"rules": {
"suspicious": {
"noCatchAssign": "error"
}
}
}
}
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.
try {
} catch (e) {
e;
e = 10;
}
try {
} catch (e) {
let e = 10;
e = 100;
}