no-namespace
Forbid namespace (a.k.a. "wildcard" *) imports
💼 This rule is enabled in the following configs: recommended, typescript.
Rule Details
A convention: modules are imported by name, so every import shows what it takes and bundlers can drop what is unused. This rule reports a namespace import, import * as ns from 'm', also import type * as ns from 'm' and import d, * as ns from 'm', unless an ignore glob matches the module specifier.
Named and default imports are fine, and so is the re-export export * as ns from 'm' (not an import).
❌ Incorrect
import * as utils from './utils';
import type * as Models from './models';✅ Correct
import { format, parse } from './utils';
import type { User } from './models';
export * as utils from './utils';Options
[
{
"type": "object",
"properties": {
"ignore": {
"type": "array",
"items": {
"type": "string"
}
}
},
"additionalProperties": false
}
]ignore(default[]): globs matched against the module specifier;*matches any run of characters. E.g.["*.css", "lodash"]keepsimport * as styles from './styles.css'.
When Not To Use It
When namespace imports are your convention, or a library is designed to be used through one.
Use this rule
npm install -D oxlint-plugin-import-next{ "jsPlugins": ["oxlint-plugin-import-next"], "rules": { "import-next/no-namespace": "error" }}import { defineConfig } from 'vite-plus';export default defineConfig({ lint: { jsPlugins: ['oxlint-plugin-import-next'], rules: { 'import-next/no-namespace': 'error', }, },});oxlint-plugin-import-next re-exports eslint-plugin-import-next/oxlint: the same rules under the same IDs, and no ESLint install. Why oxlint.
Did this rule catch something? Star the repo to get new CWE coverage as we ship it — or follow the AI-code-security benchmarks behind these rules.