oxc-project/oxc · warning · OxcDiagnostic

Expected longform property syntax.

Error message

Expected longform property syntax.

What it means

Diagnostic from `object-shorthand` configured as `never` (apply_never). The rule is inverted: shorthand properties are forbidden and every property must be written explicitly as `key: value`, so `{ x }` is reported with 'Expected longform property syntax.' Oxc sets apply_never from ShorthandType::Never in the tuple config.

Source

Thrown at crates/oxc_linter/src/rules/eslint/object_shorthand.rs:38

    context::LintContext,
    rule::{Rule, TupleRuleConfig},
    utils::deserialize_regex_option,
};

fn expected_all_properties_shorthanded(span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn("Expected shorthand for all properties.").with_label(span)
}

fn expected_literal_method_longform(span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn("Expected longform method syntax for string literal keys.").with_label(span)
}

fn expected_property_shorthand(span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn("Expected property shorthand.").with_label(span)
}

fn expected_property_longform(span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn("Expected longform property syntax.").with_label(span)
}

fn expected_method_shorthand(span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn("Expected method shorthand.").with_label(span)
}

fn expected_method_longform(span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn("Expected longform method syntax.").with_label(span)
}

fn unexpected_mix(span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn("Unexpected mix of shorthand and non-shorthand properties.")
        .with_label(span)
}

#[derive(Debug, Default, Clone)]
pub struct ObjectShorthand(Box<ObjectShorthandConfig>);

View on GitHub (pinned to a3d33dda7c)

Solutions

  1. Expand the shorthand: `{ x }` -> `{ x: x }`.
  2. Expand method shorthand: `{ run() {} }` -> `{ run: function () {} }`.
  3. Autofix with `oxlint --fix`.
  4. If you did not intend the inverted mode, fix the config to `"always"` (the default).

Example fix

// before
const o = { x, y };

// after
const o = { x: x, y: y };
Defensive patterns

Strategy: validation

Validate before calling

const hasShorthandProperty = /\{\s*[\w$]+\s*[,}]/.test(objectLiteralSource);

Prevention

When it happens

Trigger: Config `["object-shorthand", "error", "never"]` with code like `const o = { x, y };` or function-valued shorthand `const m = { run() {} };` (methods also flagged under never). Any ObjectProperty lacking an explicit value triggers it.

Common situations: Teams standardizing on explicit key-value style for grep-ability or to ease future key renames; codebases whose style guide predates ES6 and adopted oxlint with a never config.

Related errors


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