{"record":{"id":"84fb9f6c79c9cc61","repo":"oxc-project/oxc","slug":"do-not-use-an-object-literal-as-default","errorCode":null,"errorMessage":"Do not use an object literal as default","messagePattern":"Do not use an object literal as default","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/unicorn/no_object_as_default_parameter.rs","lineNumber":17,"sourceCode":"use oxc_ast::{\n    AstKind,\n    ast::{BindingPattern, Expression},\n};\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::Span;\n\nuse crate::{AstNode, context::LintContext, rule::Rule};\n\nfn identifier(span: Span, param: &str) -> OxcDiagnostic {\n    OxcDiagnostic::warn(format!(\"Do not use an object literal as default for parameter `{param}`.\"))\n        .with_label(span)\n}\n\nfn non_identifier(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Do not use an object literal as default\").with_label(span)\n}\n\n#[derive(Debug, Default, Clone)]\npub struct NoObjectAsDefaultParameter;\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///\n    /// Disallow the use of an object literal as a default value for a parameter.\n    ///\n    /// ### Why is this bad?\n    ///\n    /// Default parameters should not be passed to a function through an object literal. The `foo = {a: false}` parameter works fine if only used with one option. As soon as additional options are added, you risk replacing the whole `foo = {a: false, b: true}` object when passing only one option: `{a: true}`. For this reason, object destructuring should be used instead.\n    ///\n    /// ### Examples\n    ///\n    /// Examples of **incorrect** code for this rule:\n    /// ```javascript","sourceCodeStart":1,"sourceCodeEnd":35,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/unicorn/no_object_as_default_parameter.rs#L1-L35","documentation":"Raised by unicorn/no-object-as-default-parameter when a non-identifier parameter pattern (destructured binding or computed name) defaults to an object literal, so the parameter name cannot be reported. The faulting input is the object-literal default at the labeled span.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/unicorn/no_object_as_default_parameter.rs:17 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Move defaults into the destructuring pattern itself","Replace the object-literal default with `undefined` and handle defaults in the function body"],"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-14T05:17:10.506Z"}