oxc-project/oxc · error · OxcDiagnostic
Expected the component literal to be directly exported.
Error message
Expected the component literal to be directly exported.
What it means
Emitted by run/check_expression/check_call_expression in the vue require-direct-export rule when the component object literal is not exported directly — e.g. it is assigned to a variable that is then exported, or wrapped in a factory call. It is a structural guard so tooling can statically find the component definition.
Source
Thrown at crates/oxc_linter/src/rules/vue/require_direct_export.rs:27
},
match_expression,
};
use oxc_ast_visit::VisitJs;
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_semantic::ScopeFlags;
use oxc_span::Span;
use crate::{
AstNode,
ast_util::is_method_call,
context::{ContextHost, LintContext},
frameworks::FrameworkOptions,
rule::{DefaultRuleConfig, Rule},
};
fn require_direct_export_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Expected the component literal to be directly exported.")
.with_help(
"Export the component object directly instead of assigning it to a variable first.",
)
.with_label(span)
}
#[derive(Debug, Clone, Default, JsonSchema, Deserialize)]
#[serde(rename_all = "camelCase", default, deny_unknown_fields)]
pub struct RequireDirectExport {
/// When set `true`, disallow functional component functions.
disallow_functional_component_function: bool,
}
declare_oxc_lint!(
/// ### What it does
///
/// This rule requires that the component object be directly exported.
///View on GitHub (pinned to e1e7af627c)
Solutions
- Inline the component object into the export, e.g. export default { ... } instead of const c = { ... }; export default c
- Avoid wrapping the component literal in helper calls at export time
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/oxc_linter/src/rules/vue/require_direct_export.rs:27 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20).
Data as JSON: /api/errors/49389382a4fe7f32.
Report an issue: GitHub.