{"record":{"id":"902eb0dc36e51481","repo":"oxc-project/oxc","slug":"usage-of-namespaced-aka-wildcard-imports-pro","errorCode":null,"errorMessage":"Usage of namespaced aka wildcard \\\"*\\\" imports prohibited","messagePattern":"Usage of namespaced aka wildcard \\\\\"\\*\\\\\" imports prohibited","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/oxc_linter/src/rules/import/no_namespace.rs","lineNumber":17,"sourceCode":"use fast_glob::glob_match;\n\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::Span;\nuse oxc_str::CompactStr;\nuse schemars::JsonSchema;\nuse serde::Deserialize;\n\nuse crate::{\n    context::LintContext,\n    module_record::ImportImportName,\n    rule::{DefaultRuleConfig, Rule},\n};\n\nfn no_namespace_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Usage of namespaced aka wildcard \\\"*\\\" imports prohibited\")\n        .with_help(\"Use named or default imports\")\n        .with_label(span)\n}\n\n#[derive(Debug, Default, Clone, Deserialize)]\npub struct NoNamespace(Box<NoNamespaceConfig>);\n\n#[derive(Debug, Default, Clone, JsonSchema, Deserialize)]\n#[serde(rename_all = \"camelCase\", default, deny_unknown_fields)]\npub struct NoNamespaceConfig {\n    /// An array of glob strings for modules that should be ignored by the rule.\n    /// For example, `[\"*.json\"]` will ignore all JSON imports.\n    ignore: Vec<CompactStr>,\n}\n\nimpl std::ops::Deref for NoNamespace {\n    type Target = NoNamespaceConfig;\n","sourceCodeStart":1,"sourceCodeEnd":35,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/import/no_namespace.rs#L1-L35","documentation":"Diagnostic from the oxlint rule import/no-namespace (style category). It fires on wildcard imports: `import * as ns from 'mod'`. Namespace imports pull the whole module into one binding, which prevents tree-shaking in bundlers, obscures which members are used, and (for CJS interop) behaves differently across bundlers. The config accepts `ignore`: an array of globs for modules that may be namespace-imported (e.g. `[\"*.json\"]`).","triggerScenarios":"Any ImportNamespaceSpecifier whose module request does not match an `ignore` glob — reported via no_namespace_diagnostic at crates/oxc_linter/src/rules/import/no_namespace.rs:17. Typical: `import * as lodash from 'lodash'`, `import * as utils from './utils'`, `import * as data from './data.json'` (the JSON case unless ignored).","commonSituations":"Migrating from `const x = require('x')` habits; JSON/CJS-only modules with no named exports; performance reviews where namespace imports were found to bloat bundles.","solutions":["Import only what you use: `import { debounce } from './utils'` or the default export","Add legitimate exceptions to the ignore globs: `{ \"ignore\": [\"*.json\", \"cjs-lib\"] }`","For side-effect ordering or dynamic member access by name, replace with explicit named imports generated from a list"],"exampleFix":"// before\nimport * as utils from './utils';\nutils.debounce(fn, 100);\n\n// after\nimport { debounce } from './utils';\ndebounce(fn, 100);","handlingStrategy":"validation","validationCode":"// .oxlintrc.json\n{ \"rules\": { \"import/no-namespace\": [\"warn\", { \"ignore\": [\"*.json\"] }] } }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Import only used members to keep bundles tree-shakeable","List genuine exceptions (JSON, CJS-only libs) in the ignore globs once in shared config","Convert `const x = require('lib')` migrations to named/default imports, not namespace imports"],"tags":["lint","oxlint","imports","namespace-import","tree-shaking","style"],"backgroundTag":"namespace-import-restriction","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"}