oxc-project/oxc · warning · OxcDiagnostic

Function name `{func_name}` should not match property name `

Error message

Function name `{func_name}` should not match property name `{name}`.

What it means

The 'never + property' arm of oxlint's func-name-matching port (crates/oxc_linter/src/rules/eslint/func_name_matching.rs:46). When the rule is configured with mode `never` (FuncNameMatchingMode::Never), a named function expression used as an object property whose name EQUALS the property name is reported as redundant — the property already conveys the name.

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

  1. Remove the redundant name: use shorthand method syntax `save(data) {}` or an anonymous function.
  2. If matching names are your convention, switch the mode back to `always` (the default).

Example fix

// before
const store = {
  save: function save(data) { /* ... */ }
};

// after
const store = {
  save(data) { /* ... */ }
};
Defensive patterns

Strategy: validation

Validate before calling

// .oxlintrc.json
{
  "rules": {
    "func-name-matching": ["warn", "never"]
  }
}

Prevention

When it happens

Trigger: `{ save: function save(data) {} }` with the rule configured as ["warn", "never"].

Common situations: Teams adopting the `never` style after writing matching names; ESLint configs migrated with the mode flipped; generated object literals.

Related errors


AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20). Data as JSON: /api/errors/75152cbdc065927b. Report an issue: GitHub.