oxc-project/oxc · warning
Usage of namespaced aka wildcard \"*\" imports prohibited
Error message
Usage of namespaced aka wildcard \"*\" imports prohibited
What it means
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"]`).
Source
Thrown at crates/oxc_linter/src/rules/import/no_namespace.rs:17
use fast_glob::glob_match;
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::Span;
use oxc_str::CompactStr;
use schemars::JsonSchema;
use serde::Deserialize;
use crate::{
context::LintContext,
module_record::ImportImportName,
rule::{DefaultRuleConfig, Rule},
};
fn no_namespace_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Usage of namespaced aka wildcard \"*\" imports prohibited")
.with_help("Use named or default imports")
.with_label(span)
}
#[derive(Debug, Default, Clone, Deserialize)]
pub struct NoNamespace(Box<NoNamespaceConfig>);
#[derive(Debug, Default, Clone, JsonSchema, Deserialize)]
#[serde(rename_all = "camelCase", default, deny_unknown_fields)]
pub struct NoNamespaceConfig {
/// An array of glob strings for modules that should be ignored by the rule.
/// For example, `["*.json"]` will ignore all JSON imports.
ignore: Vec<CompactStr>,
}
impl std::ops::Deref for NoNamespace {
type Target = NoNamespaceConfig;
View on GitHub (pinned to e1e7af627c)
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
Example fix
// before
import * as utils from './utils';
utils.debounce(fn, 100);
// after
import { debounce } from './utils';
debounce(fn, 100); Defensive patterns
Strategy: validation
Validate before calling
// .oxlintrc.json
{ "rules": { "import/no-namespace": ["warn", { "ignore": ["*.json"] }] } } Prevention
- 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
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- Expected '{curr_kind}' syntax before '{prev_kind}' syntax.
- Imports should be sorted alphabetically.
- Member '{name}' of the import declaration should be sorted a
- Assign instance to a variable before exporting as module def
- Assign array to a variable before exporting as module defaul
AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20).
Data as JSON: /api/errors/902eb0dc36e51481.
Report an issue: GitHub.