oxc-project/oxc · warning
Invalid fix capabilities. Did you mean 'fix'?
Error message
Invalid fix capabilities. Did you mean 'fix'?
What it means
Diagnostic from oxlint's vue/return-in-computed-property rule (crates/oxc_linter/src/rules/vue/return_in_computed_property.rs). Every computed getter must return a value on all code paths — a falling-through path yields `undefined`, which then flows silently into templates and other computeds. The rule analyzes the getter body (definitely_returns_in_all_codepaths over the computed getter context) and, by default (`treatUndefinedAsUnspecified: true`), treats a bare `return;` as a missing return.
Source
Thrown at crates/oxc_macros/src/declare_oxc_lint.rs:424
fn parse_fix(s: &str) -> proc_macro2::TokenStream {
const SEP: char = '_';
match s {
"none" => {
return quote! { RuleFixMeta::None };
}
"pending" => {
return quote! { RuleFixMeta::FixPending };
}
"fix" => return quote! { RuleFixMeta::Fixable(FixKind::SafeFix) },
"suggestion" => return quote! { RuleFixMeta::Fixable(FixKind::Suggestion) },
"conditional" => {
panic!("Invalid fix capabilities: missing a fix kind. Did you mean 'fix-conditional'?")
}
"None" => panic!("Invalid fix capabilities. Did you mean 'none'?"),
"Pending" => panic!("Invalid fix capabilities. Did you mean 'pending'?"),
"Fix" => panic!("Invalid fix capabilities. Did you mean 'fix'?"),
"Suggestion" => panic!("Invalid fix capabilities. Did you mean 'suggestion'?"),
invalid if !invalid.contains(SEP) => panic!(
"invalid fix capabilities: {invalid}. Valid capabilities are none, pending, fix, suggestion, or [fix|suggestion]_[conditional?]_[dangerous?]."
),
_ => {}
}
assert!(s.contains(SEP));
let mut is_conditional = false;
let fix_kinds = s
.split(SEP)
.filter(|seg| match *seg {
"conditional" => {
is_conditional = true;
false
}
// e.g. "safe_fix". safe is impliedView on GitHub (pinned to a3d33dda7c)
Solutions
- Add a final fallback return: `return 0;`.
- Restructure to a single return: `return this.items ? this.items.length : 0;`.
- If bare `return;` is accepted team style, set the rule option treatUndefinedAsUnspecified: false.
Example fix
// before
computed: {
total() { if (this.items) return this.items.length; }
}
// after
computed: {
total() { return this.items ? this.items.length : 0; }
} Defensive patterns
Strategy: validation
Validate before calling
// a computed getter must contain a value-returning statement
function getterReturns(getterSrc) {
const body = getterSrc.slice(getterSrc.indexOf('{') + 1, getterSrc.lastIndexOf('}'));
return /\breturn\s+[^;\s]/.test(body);
}
if (!getterReturns(getterSource)) {
throw new Error('computed getter must return a value on every path');
} Prevention
- End every computed getter with an unconditional return.
- Prefer single-expression getters over guard-clause chains.
- Unit-test computeds against edge inputs, asserting a non-undefined result.
When it happens
Trigger: `computed: { total() { if (this.items) return this.items.length; } }` — the else path returns undefined. Also getters whose only returns sit inside callbacks (which don't count as returns of the getter), and bare `return;` statements under the default option.
Common situations: Guard clauses added to computeds; refactoring computed logic into forEach callbacks where returns no longer propagate; migrating Vue 2 components with loose getter styles.
Related errors
- The computed property cannot be used in `data()` because it
- TS5081
- You should not use an arrow function to define a watcher.
- Unexpected {} in "{}" computed property.
- Unexpected {} in computed function.
AI-assisted analysis of oxc-project/oxc@a3d33dda7c (2026-08-20).
Data as JSON: /api/errors/4beeaa360a0f1488.
Report an issue: GitHub.