Lint Rules

useNamespaceKeyword (since v12.0.0)

This rule is recommended by Rome.

Require using the namespace keyword over the module keyword to declare TypeScript namespaces.

TypeScript historically allowed a code organization called namespace. ECMAScript modules are preferred (import / export).

For projects still using namespaces, it’s preferred to use the namespace keyword instead of the module keyword. The module keyword is deprecated to avoid any confusion with the ECMAScript modules which are often called modules.

Note that TypeScript module declarations to describe external APIs (declare module "foo" {}) are still allowed.

Source: https://typescript-eslint.io/rules/prefer-namespace-keyword

See also: https://www.typescriptlang.org/docs/handbook/namespaces-and-modules.html

Examples

Invalid

module Example {}
suspicious/useNamespaceKeyword.js:1:1 lint/suspicious/useNamespaceKeyword  FIXABLE  ━━━━━━━━━━━━━━━━

   Use the namespace keyword instead of the outdated module keyword.
  
  > 1 │ module Example {}
   ^^^^^^
    2 │ 
  
   The module keyword is deprecated to avoid any confusion with the ECMAScript modules which are often called modules.
  
   Safe fix: Use namespace instead.
  
    1  - module·Example·{}
      1+ namespace·Example·{}
    2 2  
  

Valid

namespace Example {}
declare module "foo" {}