> 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.

# no-namespace

[Added in v0.1.6](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.6)
## 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/no-namespace': 'error',
    },
  },
]);
```

## Rule Details

Disallows the use of TypeScript `namespace` declarations. TypeScript historically allowed organizing code with custom `namespace` blocks, but ES2015 modules (using `import`/`export`) are the modern standard for code organization. Namespaces are generally considered outdated and should be replaced with modules. By default, this rule allows namespaces in `.d.ts` definition files, since they are commonly used there.

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

```typescript
namespace MyNamespace {
  export const value = 1;
}

namespace Nested {
  export namespace Inner {
    export type Foo = string;
  }
}
```

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

```typescript
// Use ES modules instead
export const value = 1;

// Declare namespaces are allowed with allowDeclarations option
declare namespace ExternalLib {
  function doWork(): void;
}

// Namespaces in .d.ts files are allowed by default
// (in file.d.ts)
declare namespace MyLib {
  interface Options {}
}
```

## Original Documentation

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