oxc-project/oxc · error · OxcDiagnostic

Missing file extension in {import_or_export} declaration.

Error message

Missing file extension in {import_or_export} declaration.

What it means

Raised by the import/extensions rule when a module specifier lacks a file extension while the rule's mode (e.g. 'always' or per-path 'always') requires one for that group. The helper builds the message from whether the declaration is an import or export.

Source

Thrown at crates/oxc_linter/src/rules/import/extensions.rs:40

fn extension_should_not_be_included_in_diagnostic(
    span: Span,
    extension: &str,
    is_import: bool,
) -> OxcDiagnostic {
    let import_or_export = if is_import { "import" } else { "export" };

    OxcDiagnostic::warn(format!(
        r#"File extension "{extension}" should not be included in the {import_or_export} declaration."#
    ))
    .with_help(format!("Remove the file extension from this {import_or_export}."))
    .with_label(span)
}

fn extension_missing_diagnostic(span: Span, is_import: bool) -> OxcDiagnostic {
    let import_or_export = if is_import { "import" } else { "export" };

    OxcDiagnostic::warn(format!("Missing file extension in {import_or_export} declaration."))
        .with_help(format!("Add a file extension to this {import_or_export}."))
        .with_label(span)
}

/// Extension rule configuration; Copy to avoid extra indirection.
#[repr(u8)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, JsonSchema, Serialize)]
#[serde(rename_all = "camelCase")]
pub enum ExtensionRule {
    Always = 0,
    Never = 1,
    IgnorePackages = 2,
}

impl ExtensionRule {
    /// Parse a string into an ExtensionRule variant.
    #[inline]
    pub fn from_str(s: &str) -> Option<ExtensionRule> {

View on GitHub (pinned to e1e7af627c)

Solutions

  1. Add the appropriate file extension to the import/export path
  2. Adjust the rule config if extensions should not be required here
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/oxc_linter/src/rules/import/extensions.rs:40 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/07b1b05cc9534563. Report an issue: GitHub.