{"record":{"id":"1cd2dda5adb9500b","repo":"oxc-project/oxc","slug":"function-name-func-name-should-match-variable","errorCode":null,"errorMessage":"Function name `{func_name}` should match variable name `{name}`.","messagePattern":"Function name `(.+?)` should match variable name `(.+?)`\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"warning","filePath":"crates/oxc_linter/src/rules/eslint/func_name_matching.rs","lineNumber":46,"sourceCode":"    mode: FuncNameMatchingMode,\n    span: Span,\n) -> OxcDiagnostic {\n    let msg = match (mode, is_property) {\n        (FuncNameMatchingMode::Always, true) => {\n            format!(\"Function name `{func_name}` should match property name `{name}`.\")\n        }\n        (FuncNameMatchingMode::Always, false) => {\n            format!(\"Function name `{func_name}` should match variable name `{name}`.\")\n        }\n        (FuncNameMatchingMode::Never, true) => {\n            format!(\"Function name `{func_name}` should not match property name `{name}`.\")\n        }\n        (FuncNameMatchingMode::Never, false) => {\n            format!(\"Function name `{func_name}` should not match variable name `{name}`.\")\n        }\n    };\n\n    OxcDiagnostic::warn(msg)\n        .with_help(\"Rename the function or the variable/property so the names satisfy this rule.\")\n        .with_label(span)\n}\n\n#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]\n#[serde(rename_all = \"kebab-case\")]\nenum FuncNameMatchingMode {\n    #[default]\n    Always,\n    Never,\n}\n\n#[derive(Debug, Default, Clone, Serialize, Deserialize, JsonSchema)]\n#[serde(rename_all = \"camelCase\", deny_unknown_fields)]\nstruct FuncNameMatchingConfig {\n    #[serde(default)]\n    /// If `considerPropertyDescriptor` is set to `true`, the check will take into account the use of `Object.create`, `Object.defineProperty`, `Object.defineProperties`, and `Reflect.defineProperty`.\n    consider_property_descriptor: bool,","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/eslint/func_name_matching.rs#L28-L64","documentation":"The 'always + variable' arm of oxlint's func-name-matching port (crates/oxc_linter/src/rules/eslint/func_name_matching.rs:46). In the default mode `always`, a named function expression assigned to a variable must share the variable's name: `const foo = function bar() {}` is reported because `bar` differs from `foo`. The diagnostic labels the expression span and suggests renaming one side.","triggerScenarios":"`const format = function formatValue(x) { ... }` — any named function expression whose name differs from its assignee under mode `always`.","commonSituations":"Implementation-detail names kept for stack traces; renaming variables during refactor while the function name lags; module-pattern code.","solutions":["Rename the function expression to equal the variable name.","Use a plain function declaration `function format(x)` instead of an assigned expression.","Drop the name entirely if it is not needed for recursion.","Switch the mode to `never` if mismatched names are your convention."],"exampleFix":"// before\nconst format = function formatValue(x) {\n  return String(x);\n};\n\n// after\nfunction format(x) {\n  return String(x);\n}","handlingStrategy":"validation","validationCode":"// .oxlintrc.json\n{\n  \"rules\": {\n    \"func-name-matching\": [\"warn\", \"always\"]\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Prefer function declarations for named top-level functions.","Drop expression names unless the body recurses.","Keep renames atomic across variable and function expression names."],"tags":["eslint","oxlint","naming","function-expression","variable"],"backgroundTag":"function-name-mismatch","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"}