{"record":{"id":"17e8afed1aa28de5","repo":"oxc-project/oxc","slug":"use-import-for-module-module-name","errorCode":null,"errorMessage":"Use {} import for module `{module_name}`.","messagePattern":"Use (.+?) import for module `(.+?)`\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/unicorn/import_style.rs","lineNumber":36,"sourceCode":"};\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_ecmascript::{ToJsString, WithoutGlobalReferenceInformation};\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::{GetSpan, Span};\n\nuse crate::{\n    AstNode,\n    context::LintContext,\n    rule::{DefaultRuleConfig, Rule},\n    utils::default_true,\n};\n\nfn import_style_diagnostic(\n    span: Span,\n    module_name: &str,\n    allowed_styles: StyleSet,\n) -> OxcDiagnostic {\n    OxcDiagnostic::warn(format!(\n        \"Use {} import for module `{module_name}`.\",\n        allowed_styles.format_for_diagnostic()\n    ))\n    .with_label(span)\n}\n\n#[derive(Debug, Default, Clone, Deserialize)]\npub struct ImportStyle(Box<ImportStyleConfig>);\n\n#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]\n#[serde(rename_all = \"camelCase\", default, deny_unknown_fields)]\npub struct ImportStyleConfig {\n    /// Per-module import style preferences.\n    ///\n    /// Each key is a module specifier. Set the value to `false` to disable checking for the\n    /// module, or to an object that allows one or more import styles. The available styles are\n    /// `unassigned`, `default`, `namespace`, and `named`. When `extendDefaultStyles` is `true`,\n    /// these entries extend the built-in defaults instead of replacing them.","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/unicorn/import_style.rs#L18-L54","documentation":"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.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/unicorn/import_style.rs:36 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e1e7af627c8843ab64044ed466b128fcc21a035b","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}