📝 Enforce consistent naming for catch clause parameters across the codebase.
💼 This rule is enabled in the following configs: 🌐 all, ✅ recommended, 🎨 style.
💡 This rule is manually fixable by editor suggestions.
LLMs frequently mix naming conventions (e, err, error, ex) in the same codebase. Consistent naming makes error handling patterns more recognizable, reduces cognitive load when reviewing AI-generated code, and makes search/refactoring easier.
By default the expected name is "error". You can configure any valid identifier via the name option.
{
"llm-core/consistent-catch-param-name": ["error", { "name": "error" }]
}| Option | Type | Default | Description |
|---|---|---|---|
name |
string | "error" |
The required name for all catch clause parameters |
| Pattern | Checked? |
|---|---|
catch (e) {} |
✅ Yes |
catch (err) {} |
✅ Yes |
catch (e: unknown) {} |
✅ Yes |
catch {} (optional binding) |
❌ No |
catch ({ message }) {} (object destructuring) |
❌ No |
catch ([a]) {} (array destructuring) |
❌ No |
// "e" when "error" is expected (default)
try {
doWork();
} catch (e) {
console.error(e);
}
// "err" when "error" is expected
try {
saveRecord();
} catch (err) {
logger.error(err);
}
// Mixed names in the same file
try {
doWork();
} catch (e) {
console.error(e);
}
try {
doMore();
} catch (err) {
console.error(err);
}// Default option — "error"
try {
doWork();
} catch (error) {
console.error(error);
}
// Custom option — "err"
// eslint-config: ["error", { "name": "err" }]
try {
doWork();
} catch (err) {
console.error(err);
}
// Optional catch binding — not checked
try {
doWork();
} catch {
// intentionally suppressed
}
// Destructuring — not checked
try {
doWork();
} catch ({ message }) {
console.error(message);
}When the rule fires, the message teaches:
- What's wrong — the catch parameter is named
'{{ actual }}'but should be'{{ expected }}' - Why — LLMs mix naming conventions, making patterns harder to recognize and refactor
- How to fix — rename the parameter from
{{ actual }}to{{ expected }}
A suggestion fix is provided to rename the parameter and all its references within the catch block in a single editor action.
If your team intentionally allows multiple catch variable names in different contexts, you can disable this rule or set it to "warn".