oxc-project/oxc · warning · OxcDiagnostic
Function name `{func_name}` should match property name `{nam
Error message
Function name `{func_name}` should match property name `{name}`. What it means
The 'always + property' 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 used as an object property must have the same name as the property; this message is selected when the property-variant mismatch occurs. The shared help suggests renaming the function or the variable/property so the names satisfy the rule.
Source
Thrown at crates/oxc_linter/src/rules/eslint/func_name_matching.rs:46
mode: FuncNameMatchingMode,
span: Span,
) -> OxcDiagnostic {
let msg = match (mode, is_property) {
(FuncNameMatchingMode::Always, true) => {
format!("Function name `{func_name}` should match property name `{name}`.")
}
(FuncNameMatchingMode::Always, false) => {
format!("Function name `{func_name}` should match variable name `{name}`.")
}
(FuncNameMatchingMode::Never, true) => {
format!("Function name `{func_name}` should not match property name `{name}`.")
}
(FuncNameMatchingMode::Never, false) => {
format!("Function name `{func_name}` should not match variable name `{name}`.")
}
};
OxcDiagnostic::warn(msg)
.with_help("Rename the function or the variable/property so the names satisfy this rule.")
.with_label(span)
}
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "kebab-case")]
enum FuncNameMatchingMode {
#[default]
Always,
Never,
}
#[derive(Debug, Default, Clone, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
struct FuncNameMatchingConfig {
#[serde(default)]
/// If `considerPropertyDescriptor` is set to `true`, the check will take into account the use of `Object.create`, `Object.defineProperty`, `Object.defineProperties`, and `Reflect.defineProperty`.
consider_property_descriptor: bool,View on GitHub (pinned to e1e7af627c)
Solutions
- Drop the redundant name so the property name applies: use shorthand method syntax or an anonymous function.
- Rename the function expression to match the property.
- If different names are intended, switch the rule mode to `never` or disable it.
Example fix
// before
const api = {
load: function loadFromDisk() { /* ... */ }
};
// after
const api = {
load() { /* ... */ }
}; Defensive patterns
Strategy: validation
Validate before calling
// .oxlintrc.json — pick a mode that matches your naming convention
{
"rules": {
"func-name-matching": ["warn", "always"]
}
} Prevention
- Prefer shorthand method syntax `{ load() {} }` — it cannot mismatch.
- When renaming a property or variable, rename the assigned function in the same change.
- Use `never` mode only team-wide; mixing modes across configs causes churn.
When it happens
Trigger: `const obj = { load: function loadFromDisk() {} }` — the property name differs from the function expression's name under mode `always` (the FuncNameMatchingMode default).
Common situations: Deliberately different implementation names for recursion or aliasing; renaming properties without updating function names; code generation that suffixes implementation names.
Related errors
- Function name `{func_name}` should match variable name `{nam
- Function name `{func_name}` should not match property name `
- Function name `{func_name}` should not match variable name `
- Unexpected named {function_name}.
- Expected a function {style}.
AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20).
Data as JSON: /api/errors/889a39e57c596e2a.
Report an issue: GitHub.