{"record":{"id":"03d425890a7c3fed","repo":"oxc-project/oxc","slug":"do-not-use-an-object-literal-as-default-for-parame","errorCode":null,"errorMessage":"Do not use an object literal as default for parameter `{param}`.","messagePattern":"Do not use an object literal as default for parameter `(.+?)`\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/unicorn/no_object_as_default_parameter.rs","lineNumber":12,"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.","sourceCodeStart":1,"sourceCodeEnd":30,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/unicorn/no_object_as_default_parameter.rs#L1-L30","documentation":"Raised by unicorn/no-object-as-default-parameter when a function parameter's default value is an object literal (e.g. `function f(a = {})`). The identifier helper names the parameter; the faulting input is the default parameter at the labeled span.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/unicorn/no_object_as_default_parameter.rs:12 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Destructure inside the default: `function f({ a, b } = {})`","Default each property individually: `function f(options = {}) { const a = options.a ?? defaultA }`","Use `undefined` as the default and build the object in the 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"}