{"record":{"id":"0e4b1f2f2fb8a72a","repo":"oxc-project/oxc","slug":"prefer-node-append-over-node-appendchild-f","errorCode":null,"errorMessage":"Prefer `Node#append()` over `Node#appendChild()` for DOM nodes.","messagePattern":"Prefer `Node#append\\(\\)` over `Node#appendChild\\(\\)` for DOM nodes\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/unicorn/prefer_dom_node_append.rs","lineNumber":9,"sourceCode":"use oxc_ast::{AstKind, ast::MemberExpression};\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::Span;\n\nuse crate::{AstNode, context::LintContext, rule::Rule};\n\nfn prefer_dom_node_append_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Prefer `Node#append()` over `Node#appendChild()` for DOM nodes.\")\n        .with_help(\"Replace `Node#appendChild()` with `Node#append()`.\")\n        .with_label(span)\n}\n\n#[derive(Debug, Default, Clone)]\npub struct PreferDomNodeAppend;\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///\n    /// Enforces the use of, for example, `document.body.append(div);` over `document.body.appendChild(div);` for DOM nodes.\n    ///\n    /// ### Why is this bad?\n    ///\n    /// There are [some advantages of using `Node#append()`](https://developer.mozilla.org/en-US/docs/Web/API/ParentNode/append), like the ability to append multiple nodes and to append both [`DOMString`](https://developer.mozilla.org/en-US/docs/Web/API/DOMString) and DOM node objects.\n    ///\n    /// ### Examples\n    ///","sourceCodeStart":1,"sourceCodeEnd":27,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/unicorn/prefer_dom_node_append.rs#L1-L27","documentation":"Diagnostic from the unicorn/prefer-dom-node-append lint rule. It fires when `appendChild()` is called on a DOM node, because the newer `append()` API accepts multiple arguments and DOM strings, while behaving the same for single-node insertion. The rule flags the `appendChild` member-call span. It is a style suggestion for modern DOM code, not a runtime error.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/unicorn/prefer_dom_node_append.rs:9 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Replace `parent.appendChild(child)` with `parent.append(child)`","Use `append()`'s multi-argument/string support when inserting several nodes or text","Apply the rule's auto-fix"],"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"}