oxc-project/oxc · error · OxcDiagnostic
Options are not defined.
Error message
Options are not defined.
What it means
Diagnostic from the oxlint rule `vue/valid-define-options`. In `check_call`, if the first argument slot of `defineOptions(...)` has no expression (`call.arguments.first().and_then(|arg| arg.as_expression())` is None), the call is reported as having no options. `defineOptions` exists solely to declare compile-time options; calling it with no object literal is meaningless and the Vue compiler rejects it.
Source
Thrown at crates/oxc_linter/src/rules/vue/valid_define_options.rs:25
use oxc_macros::declare_oxc_lint;
use oxc_span::{GetSpan, Span};
use crate::{
AstNode, ast_util::variable_declaration_kind, context::LintContext,
frameworks::FrameworkOptions, rule::Rule,
};
fn referencing_locally_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("`defineOptions` is referencing locally declared variables.")
.with_label(span)
}
fn multiple_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("`defineOptions` has been called multiple times.").with_label(span)
}
fn not_defined_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Options are not defined.").with_label(span)
}
fn disallow_prop_diagnostic(span: Span, prop_name: &str, instead_macro: &str) -> OxcDiagnostic {
OxcDiagnostic::warn(format!(
"`defineOptions()` cannot be used to declare `{prop_name}`. Use `{instead_macro}()` instead."
))
.with_label(span)
}
fn type_args_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("`defineOptions()` cannot accept type arguments.").with_label(span)
}
#[derive(Debug, Default, Clone)]
pub struct ValidDefineOptions;
declare_oxc_lint!(
/// ### What it doesView on GitHub (pinned to e1e7af627c)
Solutions
- Pass an object literal with the options you need: `defineOptions({ name: 'Foo' })`.
- If you do not need any options, delete the `defineOptions()` call entirely.
- If you intended to declare props/emits, use `defineProps`/`defineEmits` instead of an empty `defineOptions`.
Example fix
// before
<script setup>
defineOptions()
</script>
// after
<script setup>
defineOptions({ name: 'Foo' })
</script> Defensive patterns
Strategy: validation
Validate before calling
if (/\bdefineOptions\s*\(\s*\)/.test(src)) {
throw new Error('defineOptions() called without an options object');
} Prevention
- Never scaffold an empty defineOptions() placeholder — add options when you add the call or omit it.
- Run oxlint in CI so the vue/valid-define-options rule catches empty calls.
When it happens
Trigger: A bare `defineOptions()` call in a .vue file (VueSetup framework option). Also triggered when the first argument is a spread or non-expression argument kind that `as_expression()` returns None for. The diagnostic points at the whole call span.
Common situations: Adding `defineOptions()` as a placeholder before filling in options; refactoring away the argument but leaving the call; typos like `defineOptions(;)`.
Related errors
- `defineOptions` is referencing locally declared variables.
- `defineOptions` has been called multiple times.
- `defineOptions()` cannot be used to declare `{prop_name}`. U
- `defineOptions()` cannot accept type arguments.
- Props are not defined.
AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20).
Data as JSON: /api/errors/cc707ff2cec371a0.
Report an issue: GitHub.