> For AI agents: the complete documentation index is available at https://rslint.rs/llms.txt, the full documentation bundle is available at https://rslint.rs/llms-full.txt.

# prefer-namespace-keyword

[Added in v0.2.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.2.1)
## Configuration

| Preset                              | Configured Value |
| ----------------------------------- | ---------------- |
| ✅ ts.configs.recommended            | `"error"`        |
| ✅ ts.configs.recommendedTypeChecked | `"error"`        |
| ✅ ts.configs.strict                 | `"error"`        |
| ✅ ts.configs.strictTypeChecked      | `"error"`        |


```ts title=rslint.config.ts
import { defineConfig, ts } from '@rslint/core';

export default defineConfig([
  ts.configs.recommended,
  {
    rules: {
      '@typescript-eslint/prefer-namespace-keyword': 'error',
    },
  },
]);
```

## Rule Details

Require using `namespace` keyword over `module` keyword to declare custom TypeScript modules.

TypeScript historically allowed `module` keyword as a way to group related code. The newer `namespace` keyword was added in TypeScript 1.5 to distinguish between built-in modules and user-defined modules. While the two keywords are functionally identical, using `namespace` is recommended as `module` may cause confusion with ECMAScript modules.

Examples of **incorrect** code for this rule:

```typescript
module Foo {}

declare module Foo {}
```

Examples of **correct** code for this rule:

```typescript
namespace Foo {}

declare namespace Foo {}

declare module 'foo' {}
```

## Original Documentation

- [typescript-eslint: prefer-namespace-keyword](https://typescript-eslint.io/rules/prefer-namespace-keyword)
- [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/prefer-namespace-keyword.ts)
