Skip to content

noUselessQualifier (JavaScript)

Language JavaScript (and super languages)
biome.json
{
"linter": {
"rules": {
"nursery": {
"noUselessQualifier": "error"
}
}
}
}

Disallow unnecessary namespace and enum qualifiers.

The members of a TypeScript namespace or enum are usually accessed through the name of the namespace or enum, for example Direction.Up. The Direction. part is called a qualifier.

Inside the namespace or enum itself, the members can be used by their name alone, so the qualifier only repeats what is already known.

This rule doesn’t report a qualifier when the member name alone would refer to something else, for example because a local variable has the same name.

enum Direction {
Up,
Down = Direction.Up + 1,
}
code-block.ts:3:12 lint/nursery/noUselessQualifier  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

ℹ The qualifier before Up is unnecessary.

1 │ enum Direction {
2 │ Up,
> 3 │ Down = Direction.Up + 1,
│ ^^^^^^^^^
4 │ }
5 │

ℹ Inside a namespace or an enum, its members can be used by their name alone, so the qualifier only repeats what is already known.

ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

ℹ Unsafe fix: Remove the qualifier.

1 1 │ enum Direction {
2 2 │ Up,
3 │ - ····Down·=·Direction.Up·+·1,
3 │ + ····Down·=·Up·+·1,
4 4 │ }
5 5 │

namespace Shapes {
export type Point = { x: number; y: number };
const origin: Shapes.Point = { x: 0, y: 0 };
}
code-block.ts:3:19 lint/nursery/noUselessQualifier  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

ℹ The qualifier before Point is unnecessary.

1 │ namespace Shapes {
2 │ export type Point = { x: number; y: number };
> 3 │ const origin: Shapes.Point = { x: 0, y: 0 };
│ ^^^^^^
4 │ }
5 │

ℹ Inside a namespace or an enum, its members can be used by their name alone, so the qualifier only repeats what is already known.

ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

ℹ Unsafe fix: Remove the qualifier.

1 1 │ namespace Shapes {
2 2 │ export type Point = { x: number; y: number };
3 │ - ····const·origin:·Shapes.Point·=·{·x:·0,·y:·0·};
3 │ + ····const·origin:·Point·=·{·x:·0,·y:·0·};
4 4 │ }
5 5 │

namespace Config {
export const timeout = 1000;
export function getTimeout() {
return Config.timeout;
}
}
code-block.ts:4:16 lint/nursery/noUselessQualifier  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

ℹ The qualifier before timeout is unnecessary.

2 │ export const timeout = 1000;
3 │ export function getTimeout() {
> 4 │ return Config.timeout;
│ ^^^^^^
5 │ }
6 │ }

ℹ Inside a namespace or an enum, its members can be used by their name alone, so the qualifier only repeats what is already known.

ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

ℹ Unsafe fix: Remove the qualifier.

2 2 │ export const timeout = 1000;
3 3 │ export function getTimeout() {
4 │ - ········return·Config.timeout;
4 │ + ········return·timeout;
5 5 │ }
6 6 │ }

enum Direction {
Up,
Down = Up + 1,
}
namespace Shapes {
export type Point = { x: number; y: number };
const origin: Point = { x: 0, y: 0 };
}
namespace Outer {
export type Id = number;
namespace Inner {
type Id = string;
// `Id` alone would refer to `Inner.Id`.
const id: Outer.Id = 0;
}
}