{"record":{"id":"18e410927408b0da","repo":"oxc-project/oxc","slug":"replace-default-import-with-named-import","errorCode":null,"errorMessage":"Replace default import with named import.","messagePattern":"Replace default import with named import\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/oxc_linter/src/rules/import/no_named_default.rs","lineNumber":13,"sourceCode":"use oxc_ast::{\n    AstKind,\n    ast::{ImportDeclarationSpecifier, ImportOrExportKind},\n};\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_semantic::AstNode;\nuse oxc_span::{GetSpan, Span};\n\nuse crate::{context::LintContext, rule::Rule};\n\nfn no_named_default_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Replace default import with named import.\")\n        .with_help(\"Forbid named default exports.\")\n        .with_label(span)\n}\n\n#[derive(Debug, Default, Clone)]\npub struct NoNamedDefault;\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///\n    /// Reports use of a default export as a locally named import.\n    ///\n    /// ### Why is this bad?\n    ///\n    /// Rationale: the syntax exists to import default exports expressively, let's use it.\n    ///\n    /// ### Examples\n    ///","sourceCodeStart":1,"sourceCodeEnd":31,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/import/no_named_default.rs#L1-L31","documentation":"Diagnostic from the oxlint rule import/no-named-default (style category). It fires when the default export is imported through named-import syntax: `import { default as foo } from './foo.js'` (including string form `import { \"default\" as bar }`). The dedicated default-import syntax exists to express this directly — `import foo from './foo.js'` — and using the long form obscures which binding is the default. Value-kind specifiers are checked; an inline `type` modifier (`import { type default as Foo }`) is skipped.","triggerScenarios":"Any ImportSpecifier whose imported name is `default` with value import kind — crates/oxc_linter/src/rules/import/no_named_default.rs:63 reports the imported-name span. Also fires inside `import type { default as Quill } from 'quill'` statements used as values. Common producers: codemods, Replit-style auto-imports, and TypeScript code written before defaults were well understood.","commonSituations":"Auto-import tooling choosing `{ default as X }` when a named export with the wanted name also exists; codebases migrating from CommonJS where `require('./mod').default` was translated literally; copy-pasted snippets from older docs.","solutions":["Rewrite to default-import syntax: `import foo from './foo.js'`, combining with named imports as `import foo, { bar } from './foo.js'`","Configure your IDE/auto-import to prefer default-import syntax for default exports","If the alias is deliberate documentation, add a disable comment for that line"],"exampleFix":"// before\nimport { default as foo, bar } from './foo.js';\n\n// after\nimport foo, { bar } from './foo.js';","handlingStrategy":"validation","validationCode":"// rg -n \"import\\\\s*\\\\{[^}]*\\\\bdefault\\\\b[^}]*\\\\}\\\\s*from\" src\n// .oxlintrc.json: { \"rules\": { \"import/no-named-default\": \"warn\" } }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use dedicated default-import syntax (`import X from`) in hand-written code","Configure auto-import tooling to emit default syntax for default exports","During CJS→ESM migration, translate `require('./m').default` to `import X from './m'`, not `{ default as X }`"],"tags":["lint","oxlint","imports","default-export","import-syntax","style"],"backgroundTag":"default-as-named-import","analyzedSha":"e1e7af627c8843ab64044ed466b128fcc21a035b","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}