astro-ghostcms/.pnpm-store/v3/files/0a/b14da7afb1e27a194ee9c216fec...

52 lines
985 B
Plaintext
Raw Normal View History

2024-02-14 14:10:47 +00:00
---
description: 'Disallow unnecessary namespace qualifiers.'
---
> 🛑 This file is source code, not the primary documentation location! 🛑
>
> See **https://typescript-eslint.io/rules/no-unnecessary-qualifier** for documentation.
Members of TypeScript enums and namespaces are generally retrieved as qualified property lookups: e.g. `Enum.member`.
However, when accessed within their parent enum or namespace, the qualifier is unnecessary: e.g. just `member` instead of `Enum.member`.
This rule reports when an enum or namespace qualifier is unnecessary.
## Examples
<!--tabs-->
### ❌ Incorrect
```ts
enum A {
B,
C = A.B,
}
```
```ts
namespace A {
export type B = number;
const x: A.B = 3;
}
```
### ✅ Correct
```ts
enum A {
B,
C = B,
}
```
```ts
namespace A {
export type B = number;
const x: B = 3;
}
```
## When Not To Use It
If you explicitly prefer to use fully qualified names, such as for explicitness, then you don't need to use this rule.