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
- Expand the shorthand: `{ x }` -> `{ x: x }`.
- Expand method shorthand: `{ run() {} }` -> `{ run: function () {} }`.
- Autofix with `oxlint --fix`.
- 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
- Under a `never` config, always write explicit `key: value` pairs.
- Double-check the config string - `never` is easy to paste by accident when you meant `always`.
- Use `oxlint --fix` to expand shorthands mechanically.
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
- Expected shorthand for all properties.
- Expected {setter_key} to be before {getter_key}.
- Unexpected comment inline with code
- Unnecessarily computed property `{key}` found.
- Use a regular expression literal instead of the `RegExp` con
AI-assisted analysis of oxc-project/oxc@a3d33dda7c (2026-08-20).
Data as JSON: /api/errors/54071f78c7f51609.
Report an issue: GitHub.