oxc-project/oxc · error · OxcDiagnostic

Component must be the default export.

Error message

Component must be the default export.

What it means

Emitted by run_once of the vue require-default-export rule when the file does export something but the component is not the default export (e.g. only named exports exist). It is a structural guard ensuring the Vue component is the module's default export.

Source

Thrown at crates/oxc_linter/src/rules/vue/require_default_export.rs:17

use oxc_ast::{AstKind, ast::Expression};
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::Span;

use crate::{
    context::{ContextHost, LintContext},
    frameworks::FrameworkOptions,
    rule::Rule,
};

fn missing_default_export_diagnostic(span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn("Missing default export.").with_label(span)
}

fn must_be_default_export_diagnostic(span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn("Component must be the default export.").with_label(span)
}

#[derive(Debug, Default, Clone)]
pub struct RequireDefaultExport;

declare_oxc_lint!(
    /// ### What it does
    ///
    /// Require components to be the default export.
    ///
    /// ### Why is this bad?
    ///
    /// Using SFCs (Single File Components) without a default export is
    /// not supported in Vue 3. Components should be exported as the default export.
    ///
    /// ### Examples
    ///
    /// Examples of **incorrect** code for this rule:

View on GitHub (pinned to e1e7af627c)

Solutions

  1. Make the component definition the default export, e.g. export default { ... } instead of a named export
  2. Move helper exports into a separate module so the component file only has the default export
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/oxc_linter/src/rules/vue/require_default_export.rs:17 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/397b2df1cd31d0ba. Report an issue: GitHub.