no-namespace
What it does
Section titled “What it does”Reports a namespace N {} or module N {} declaration, also a dotted namespace A.B {}. declare module "x", declare global, and any namespace in a .d.ts file are not reported.
Why it matters
Section titled “Why it matters”A TypeScript namespace is an older way to group code that does not exist in JavaScript: it compiles to an object built by a function, cannot be tree-shaken well and is not understood by tools that only strip types. ES modules do the same grouping and are the standard.
To fix, move the members to a module file and export them.
Example
Section titled “Example”namespace N.M {}declare module "x" {}declare global {}declare namespace Q {}...function local(require: (id: string) => void) { require("d"); }...Configuration
Section titled “Configuration”js: lint: rules: no-namespace: warn # off (default), warn, errorEnabled by the presets: js/typescript-eslint-recommended.
Suppress one line with sudsy-disable-next-line no-namespace in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools. full: Sudsy reports what the upstream rule reports; partial: only part of it, as the last column says.
| Tool | Rule | Match | What differs |
|---|---|---|---|
| typescript-eslint | no-namespace |
partial | the option allowDeclarations keeps its default |