{"record":{"id":"4f40c6a13c9040c4","repo":"oxc-project/oxc","slug":"enforce-using-the-separator-argument-with-array-jo","errorCode":null,"errorMessage":"Enforce using the separator argument with Array#join()","messagePattern":"Enforce using the separator argument with Array#join\\(\\)","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"warning","filePath":"crates/oxc_linter/src/rules/unicorn/require_array_join_separator.rs","lineNumber":15,"sourceCode":"use oxc_ast::{\n    AstKind,\n    ast::{Argument, MemberExpression},\n};\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::{GetSpan, Span};\n\nuse crate::{\n    AstNode, ast_util::is_method_call, context::LintContext, rule::Rule,\n    utils::is_prototype_property,\n};\n\nfn require_array_join_separator_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Enforce using the separator argument with Array#join()\")\n        .with_help(\"Missing the separator argument.\")\n        .with_label(span)\n}\n\n#[derive(Debug, Default, Clone)]\npub struct RequireArrayJoinSeparator;\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///\n    /// Enforce using the separator argument with `Array#join()`.\n    ///\n    /// ### Why is this bad?\n    ///\n    /// It's better to make it clear what the separator is when calling `Array#join()`,\n    /// instead of relying on the default comma (`','`) separator.\n    ///\n    /// ### Examples","sourceCodeStart":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/unicorn/require_array_join_separator.rs#L1-L33","documentation":"This is the oxlint rule `unicorn/require-array-join-separator`. `Array#join()` with no arguments defaults to a comma, which is implicit and often not what the author meant; the rule requires an explicit separator argument so intent is visible ('Missing the separator argument.'). The rule checks calls via `is_method_call` and `is_prototype_property` on the receiver.","triggerScenarios":"`list.join()` — a `.join` member call on an array-like receiver with zero arguments. Passing any explicit separator (`join(',')`, `join('')`, `join('-')`) silences it; `.join` accessed through `Array.prototype.join.call(...)` shapes is also covered by the prototype-property check.","commonSituations":"Joining to build strings (log lines, class lists, paths) where the author assumed no-separator but got `','`; or join-for-stringification in template building where the comma default slips into output. Reviewers use this rule to force `join('')` vs `join(',')` to be stated.","solutions":["Pass the separator you actually mean: `list.join('')` for concatenation, `list.join(',')` to make the default explicit.","Run `oxlint --fix` where the fixer inserts the separator.","Disable the rule with `\"unicorn/require-array-join-separator\": \"off\"` if your team accepts the implicit comma default."],"exampleFix":"// before\nconst csv = ids.join();\nconst className = mods.join();\n\n// after\nconst csv = ids.join(',');\nconst className = mods.join(' ');","handlingStrategy":"validation","validationCode":"// State the separator explicitly every time\nconst csv = ids.join(',');\nconst glued = parts.join('');\n// CI: npx oxlint --deny-warn unicorn/require-array-join-separator src/","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never call `.join()` bare — the comma default is rarely the intent.","Review join sites during string-building refactors; silent commas are a classic log/output bug.","Enable the rule repo-wide; it is cheap and prevents a whole class of formatting mistakes."],"tags":["oxlint","unicorn","array","join","explicit-arguments"],"backgroundTag":"array-join-separator","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"}