{"record":{"id":"2984c3513530a8f8","repo":"oxc-project/oxc","slug":"prefer-omitting-the-catch-binding-parameter-if-it","errorCode":null,"errorMessage":"Prefer omitting the catch binding parameter if it is unused","messagePattern":"Prefer omitting the catch binding parameter if it is unused","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/unicorn/prefer_optional_catch_binding.rs","lineNumber":9,"sourceCode":"use oxc_ast::{AstKind, ast::BindingPattern};\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::{GetSpan, Span};\n\nuse crate::{AstNode, context::LintContext, rule::Rule};\n\nfn prefer_optional_catch_binding_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Prefer omitting the catch binding parameter if it is unused\")\n        .with_label(span)\n}\n\n#[derive(Debug, Default, Clone)]\npub struct PreferOptionalCatchBinding;\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///\n    /// Prefers omitting the catch binding parameter if it is unused.\n    ///\n    /// ### Why is this bad?\n    ///\n    /// It is unnecessary to bind the error to a variable if it is not used.\n    ///\n    /// ### Examples\n    ///\n    /// Examples of **incorrect** code for this rule:","sourceCodeStart":1,"sourceCodeEnd":27,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/unicorn/prefer_optional_catch_binding.rs#L1-L27","documentation":"Diagnostic from the unicorn/prefer-optional-catch-binding lint rule. It fires when a `try`/`catch` declares a catch binding parameter (e.g. `catch (error)`) that is never referenced in the catch body; ES2019 allows omitting it entirely (`catch { ... }`). The flagged input is the unused binding pattern's span. It is a lint suggestion, not a runtime error.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/unicorn/prefer_optional_catch_binding.rs:9 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Remove the unused catch parameter: write `catch {` instead of `catch (error) {`","Apply the rule's auto-fix","If the error is needed later, actually use the binding instead of removing it"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e1e7af627c8843ab64044ed466b128fcc21a035b","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}