oxc-project/oxc · error · OxcDiagnostic
File extension "{extension}" should not be included in the {
Error message
File extension "{extension}" should not be included in the {import_or_export} declaration. What it means
Raised by the import/extensions rule when a module specifier in an import or export declaration contains a file extension while the rule's configured mode forbids extensions for that path group. The extension string and whether the declaration is an import or export are interpolated into the message.
Source
Thrown at crates/oxc_linter/src/rules/import/extensions.rs:30
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use serde_json::Value;
use crate::{
AstNode,
context::LintContext,
rule::{MixedTupleRuleConfig, Rule},
};
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")]View on GitHub (pinned to e1e7af627c)
Solutions
- Remove the file extension from the module specifier
- Configure the rule's settings to allow extensions for this path type (e.g. inline scripts or CSS assets)
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/oxc_linter/src/rules/import/extensions.rs:30 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/7f6a5c23e9fce714.
Report an issue: GitHub.