oxc-project/oxc · error · OxcDiagnostic
Use {} import for module `{module_name}`.
Error message
Use {} import for module `{module_name}`. What it means
Raised by the unicorn/import-style rule when an import statement's style (named vs default, and specifier ordering) for a module does not match the configured allowed styles. The diagnostic formats the StyleSet of permitted styles into the message, so the faulting input is the import declaration at the labeled span and its module specifier.
Source
Thrown at crates/oxc_linter/src/rules/unicorn/import_style.rs:36
};
use oxc_diagnostics::OxcDiagnostic;
use oxc_ecmascript::{ToJsString, WithoutGlobalReferenceInformation};
use oxc_macros::declare_oxc_lint;
use oxc_span::{GetSpan, Span};
use crate::{
AstNode,
context::LintContext,
rule::{DefaultRuleConfig, Rule},
utils::default_true,
};
fn import_style_diagnostic(
span: Span,
module_name: &str,
allowed_styles: StyleSet,
) -> OxcDiagnostic {
OxcDiagnostic::warn(format!(
"Use {} import for module `{module_name}`.",
allowed_styles.format_for_diagnostic()
))
.with_label(span)
}
#[derive(Debug, Default, Clone, Deserialize)]
pub struct ImportStyle(Box<ImportStyleConfig>);
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "camelCase", default, deny_unknown_fields)]
pub struct ImportStyleConfig {
/// Per-module import style preferences.
///
/// Each key is a module specifier. Set the value to `false` to disable checking for the
/// module, or to an object that allows one or more import styles. The available styles are
/// `unassigned`, `default`, `namespace`, and `named`. When `extendDefaultStyles` is `true`,
/// these entries extend the built-in defaults instead of replacing them.View on GitHub (pinned to e1e7af627c)
Solutions
- Rewrite the import to one of the allowed styles reported in the message (e.g. switch a default import to a named import for that module)
- Update the rule's styles config for that module if the project convention actually permits the current style
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/oxc_linter/src/rules/unicorn/import_style.rs:36 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/17e8afed1aa28de5.
Report an issue: GitHub.