{"record":{"id":"1f837a7d901b2150","repo":"oxc-project/oxc","slug":"no-default-export-found-in-imported-module-import","errorCode":null,"errorMessage":"No default export found in imported module {imported_name:?}","messagePattern":"No default export found in imported module (.+?)","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/import/default.rs","lineNumber":8,"sourceCode":"use oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::{Span, VALID_EXTENSIONS};\n\nuse crate::{context::LintContext, module_record::ImportImportName, rule::Rule};\n\nfn default_diagnostic(imported_name: &str, span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(format!(\"No default export found in imported module {imported_name:?}\"))\n        .with_help(format!(\"Does {imported_name:?} have the default export?\"))\n        .with_label(span)\n}\n\n/// <https://github.com/import-js/eslint-plugin-import/blob/v2.29.1/docs/rules/default.md>\n#[derive(Debug, Default, Clone)]\npub struct Default;\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///\n    /// If a default import is requested, this rule will report if there is no\n    /// default export in the imported module.\n    ///\n    /// ### Why is this bad?\n    ///\n    /// Using a default import when there is no default export can lead to\n    /// confusion and runtime errors. It can make the code harder to understand","sourceCodeStart":1,"sourceCodeEnd":26,"githubUrl":"https://github.com/oxc-project/oxc/blob/a3d33dda7cb69da23db4fcaa2c0c05de61e760a1/crates/oxc_linter/src/rules/import/default.rs#L1-L26","documentation":"oxlint's `import/default` rule (port of eslint-plugin-import): when a statement requests a default import (`ImportImportName::Default`), the linter resolves the target module within the same lint run (validating its extension via VALID_EXTENSIONS) and inspects its module record; if no default export entry exists there, this diagnostic names the offending module specifier.","triggerScenarios":"`import Foo from './bar';` where bar.ts contains only named exports; `import util from './util'` where util.cjs assigns `module.exports = { a, b }` with no recognizable default; also behaves differently when the target file is outside the linted paths so its module record is unavailable.","commonSituations":"A refactor replacing `export default` with named exports without updating importers; barrel index files that only re-export names; TypeScript compiled without esModuleInterop-style interop; moving files so the specifier now hits a different module.","solutions":["Change the importer to a named import: `import { foo } from './bar';`","Add `export default Foo;` to the target module if a default export is genuinely intended","For CommonJS targets, import the namespace (`import * as util from './util'`) or align tsconfig esModuleInterop/allowSyntheticDefaultImports with how the code imports","Keep the imported file inside the directories oxlint lints so cross-module resolution can see its exports"],"exampleFix":"// before — bar.ts has only named exports\n// bar.ts: export function foo() {}\nimport foo from './bar';\n\n// after\nimport { foo } from './bar';","handlingStrategy":"validation","validationCode":"// dual static gates catch missing default exports before runtime\n// 1) TypeScript with real module resolution\n//    npx tsc --noEmit\n// 2) oxlint with the import plugin\n// .oxlintrc.json: { \"plugins\": [\"import\"], \"rules\": { \"import/default\": \"error\" } }\n//    npx oxlint src/","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep imported modules inside the linted project so oxlint can resolve their exports","When removing a default export, grep importers of that module in the same commit","Prefer named exports — they survive refactors better than defaults","For CJS dependencies, align tsconfig esModuleInterop/allowSyntheticDefaultImports with how the code imports them"],"tags":["lint","oxlint","import-plugin","esm","modules","default-export"],"backgroundTag":"missing-module-export","analyzedSha":"a3d33dda7cb69da23db4fcaa2c0c05de61e760a1","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}