{"record":{"id":"74dfb9902707f9f9","repo":"oxc-project/oxc","slug":"module-export-name-has-named-export-module-na","errorCode":null,"errorMessage":"Module {export_name:?} has named export {module_name:?}","messagePattern":"Module (.+?) has named export (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/oxc_linter/src/rules/import/no_named_as_default.rs","lineNumber":16,"sourceCode":"use oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::Span;\n\nuse crate::{\n    context::LintContext,\n    module_record::{ExportExportName, ExportImportName, ImportImportName, ModuleRecord},\n    rule::Rule,\n};\n\nfn no_named_as_default_diagnostic(\n    span: Span,\n    module_name: &str,\n    export_name: &str,\n) -> OxcDiagnostic {\n    OxcDiagnostic::warn(format!(\"Module {export_name:?} has named export {module_name:?}\"))\n        .with_help(format!(\"Using default import as {module_name:?} can be confusing. Use another name for default import to avoid confusion.\"))\n        .with_label(span)\n}\n\n// <https://github.com/import-js/eslint-plugin-import/blob/v2.29.1/docs/rules/no-named-as-default.md>\n#[derive(Debug, Default, Clone)]\npub struct NoNamedAsDefault;\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///\n    /// Reports use of an exported name as the locally imported name of a default export.\n    /// This happens when an imported default export is assigned a name that conflicts\n    /// with a named export from the same module.\n    ///\n    /// ### Why is this bad?\n    ///\n    /// Using a named export's identifier for a default export can cause confusion","sourceCodeStart":1,"sourceCodeEnd":34,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/import/no_named_as_default.rs#L1-L34","documentation":"Diagnostic from the oxlint rule import/no-named-as-default (suspicious category). It fires when a default import's local name matches a named export of the source module: e.g. given `foo.js` has `export default 'foo'` and `export const bar = true`, writing `import bar from './foo.js'` is reported. The code works but strongly suggests the author meant the named export and got the default instead — a classic import mistake. Type-only imports, unresolved modules, and the case where default and name are the same re-exported value (`export { foo as default }` alongside `export { foo }`) are skipped.","triggerScenarios":"run_once iterates import entries; for ImportImportName::Default entries whose local name appears in the remote module's exported_bindings (and the same-reexport check of PR #3032 does not apply), it reports at the import specifier span — crates/oxc_linter/src/rules/import/no_named_as_default.rs:16. Typical: `import bar from './foo.js'` when './foo.js' also named-exports `bar`.","commonSituations":"IDE auto-import picking the default export but suggesting the named export's name; refactors where a component switches from named to default export and old import sites keep the name; large shared UI/utility modules exposing both defaults and many named exports.","solutions":["If you meant the named export (most common): change to `import { bar } from './foo.js'`","If you really want the default, rename the local binding to something that does not collide: `import foo from './foo.js'`","Add the named export check to code review for shared modules that mix default and named exports"],"exampleFix":"// foo.js\nexport default 'foo';\nexport const bar = true;\n\n// before\nimport bar from './foo.js'; // bar is actually the string 'foo', not the boolean\n\n// after\nimport { bar } from './foo.js';","handlingStrategy":"validation","validationCode":"// keep the suspicious-category rule on in CI (default-enabled set):\n// npx oxlint src\n// For mixed default+named modules, prefer named exports at the boundary.","typeGuard":null,"tryCatchPattern":null,"preventionTips":["For modules with both a default and many named exports, import named exports by preference","Treat an IDE auto-import that names a default import after a named export as a smell — verify","Keep the rule enabled in review pipelines; it catches the classic 'meant the named export' mistake"],"tags":["lint","oxlint","imports","default-export","named-export","confusion","suspicious"],"backgroundTag":"default-import-name-collision","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"}