Skip to content

unicorn/prefer-optional-catch-binding Style

🛠️ An auto-fix is available for this rule.

What it does

Prefers omitting the catch binding parameter if it is unused

Why is this bad?

It is unnecessary to bind the error to a variable if it is not used.

Example

Examples of incorrect code for this rule:

javascript
try {
  // ...
} catch (e) {}

Examples of correct code for this rule:

javascript
try {
  // ...
} catch {}

References

Released under the MIT License.