JS.TS.NO.UNNECESSARY.QUALIFIER

Warns when a namespace qualifier is unnecessary

Rule Details

This rule aims to let users know when a namespace or enum qualifier is unnecessary, whether used for a type or for a value.

Examples of code for this rule:

<!--tabs-->

Incorrect

コピー
namespace A {
  export type B = number;
  const x: A.B = 3;
}
コピー
namespace A {
  export const x = 3;
  export const y = A.x;
}
コピー
enum A {
  B,
  C = A.B,
}
コピー
namespace A {
  export namespace B {
    export type T = number;
    const x: A.B.T = 3;
  }
}

Correct

コピー
namespace X {
  export type T = number;
}

namespace Y {
  export const x: X.T = 3;
}
コピー
enum A {
  X,
  Y,
}

enum B {
  Z = A.X,
}
コピー
namespace X {
  export type T = number;
  namespace Y {
    type T = string;
    const x: X.T = 0;
  }
}

Options

コピー
// .eslintrc.json
{
  "rules": {
    "@typescript-eslint/no-unnecessary-qualifier": "warn"
  }
}

This rule is not configurable.

When Not To Use It

If you don't care about having unneeded namespace or enum qualifiers, then you don't need to use this rule.

The content on this page is adapted from the ESLint User Guide. Copyright © OpenJS Foundation and other contributors, www.openjsf.org. All rights reserved. https://eslint.org/docs/rules/