Lint Rules

noNamespace (since v12.0.0)

Disallow the use of TypeScript’s namespaces.

Namespaces are an old way to organize your code in TypeScript. They are not recommended anymore and should be replaced by ES6 modules (the import/export syntax).

Source: https://typescript-eslint.io/rules/no-namespace

Examples

Invalid

module foo {}
style/noNamespace.js:1:1 lint/style/noNamespace ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

   TypeScript's namespaces are an oudated way to organize code.
  
  > 1 │ module foo {}
   ^^^^^^^^^^^^^
    2 │ 
  
   Prefer the ES6 modules (import/export) over namespaces.
  
declare module foo {}
style/noNamespace.js:1:9 lint/style/noNamespace ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

   TypeScript's namespaces are an oudated way to organize code.
  
  > 1 │ declare module foo {}
           ^^^^^^^^^^^^^
    2 │ 
  
   Prefer the ES6 modules (import/export) over namespaces.
  
namespace foo {}
style/noNamespace.js:1:1 lint/style/noNamespace ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

   TypeScript's namespaces are an oudated way to organize code.
  
  > 1 │ namespace foo {}
   ^^^^^^^^^^^^^^^^
    2 │ 
  
   Prefer the ES6 modules (import/export) over namespaces.
  
declare namespace foo {}
style/noNamespace.js:1:9 lint/style/noNamespace ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

   TypeScript's namespaces are an oudated way to organize code.
  
  > 1 │ declare namespace foo {}
           ^^^^^^^^^^^^^^^^
    2 │ 
  
   Prefer the ES6 modules (import/export) over namespaces.
  

Valid

import foo from 'foo';
export { bar };
declare global {}
declare module 'foo' {}