{"record":{"id":"6873b164c50f9388","repo":"oxc-project/oxc","slug":"all-fn-name-signatures-should-be-adjacent","errorCode":null,"errorMessage":"All {fn_name:?} signatures should be adjacent.","messagePattern":"All (.+?) signatures should be adjacent\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"warning","filePath":"crates/oxc_linter/src/rules/typescript/adjacent_overload_signatures.rs","lineNumber":24,"sourceCode":"    },\n};\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::{GetSpan, Span};\nuse oxc_str::CompactStr;\n\nuse crate::{\n    AstNode,\n    context::{ContextHost, LintContext},\n    rule::Rule,\n};\n\nfn adjacent_overload_signatures_diagnostic(\n    fn_name: &str,\n    first: Option<Span>,\n    second: Span,\n) -> OxcDiagnostic {\n    let mut d = OxcDiagnostic::warn(format!(\"All {fn_name:?} signatures should be adjacent.\"))\n        .with_help(format!(\"Move all {fn_name:?} overload signatures together, placing them consecutively before any other members.\"))\n        .with_note(\"Function overload signatures represent multiple ways a function can be called. Keeping them adjacent makes it easier for developers to understand all available call signatures at a glance.\");\n    if let Some(span) = first {\n        d = d.and_label(span);\n    }\n    d.and_label(second)\n}\n\n#[derive(Debug, Default, Clone)]\npub struct AdjacentOverloadSignatures;\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///\n    /// Require that function overload signatures be consecutive.\n    ///\n    /// ### Why is this bad?\n    ///","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/typescript/adjacent_overload_signatures.rs#L6-L42","documentation":"Diagnostic from the typescript `adjacent-overload-signatures` rule in oxlint. It fires when overloads of the same function or method are separated by other members (or statements), e.g. one `foo` signature, then `bar`, then another `foo` signature. Split overloads are easy to miss when reading and historically caused issues for some language-service consumers.","triggerScenarios":"The rule scans class/object/export declarations and statement lists; when two signature groups with the same name (fn_name) are non-adjacent, it reports 'All \"foo\" signatures should be adjacent.' with labels on the first and second spans. Examples: `class C { foo(): void; bar(): number; foo(x: number): number; }`, or overload declarations in a file separated by other statements or imports.","commonSituations":"Merge conflicts and copy-paste reordering inside interfaces/classes; generated `.d.ts`-style files that interleave members alphabetically; adding an overload at the bottom of a class far from its siblings.","solutions":["Move the stray overload next to its siblings, keeping all consecutive signatures before the implementation.","Sort/generate members deterministically (e.g. by name) in generated files so same-name signatures cluster.","In editors, use symbol search on the method name to find all signatures and gather them; then re-run oxlint to confirm the diagnostic clears."],"exampleFix":"// before\nclass Foo {\n  bar(): void;\n  foo(x: string): string;\n  baz(): void;\n  foo(x: number): number;\n}\n\n// after\nclass Foo {\n  bar(): void;\n  baz(): void;\n  foo(x: string): string;\n  foo(x: number): number;\n}","handlingStrategy":"validation","validationCode":"// report overload names that appear in non-adjacent member groups\nfunction nonAdjacentOverloads(members: { name: string }[][]): Set<string> {\n  const seen = new Map<string, number>();\n  const bad = new Set<string>();\n  let last = -1;\n  for (const group of members.flat()) { /* pair with your AST walker */ }\n  return bad;\n}\n// simplest: rely on oxlint -p 'class $C { $$$A; $$$B; $$$C; }' or run `oxlint --ts` in CI","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Add new overloads directly beneath existing ones for the same method; use editor symbol search to find them all.","Keep interfaces/classes sorted by member name in generated code so same-name signatures cluster.","Run oxlint with the typescript plugin in pre-commit to catch interleaved overloads before review."],"tags":["typescript","oxlint","overloads","code-organization","adjacent-overload-signatures"],"backgroundTag":"overload-signatures-not-adjacent","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"}