noUnusedPrivateClassMembers
诊断类别:lint/correctness/noUnusedPrivateClassMembers
¥Diagnostic Category: lint/correctness/noUnusedPrivateClassMembers
自从:v1.3.3
¥Since: v1.3.3
来源:
¥Sources:
-
与以下相同:
no-unused-private-class-members
¥Same as:
no-unused-private-class-members
禁止未使用的私有类成员
¥Disallow unused private class members
在代码中声明但未在任何地方使用的私有类成员很可能是由于重构不完整而导致的错误。这样的类成员会占用代码空间,并可能导致读者感到困惑。
¥Private class members that are declared and not used anywhere in the code are most likely an error due to incomplete refactoring. Such class members take up space in the code and can lead to confusion by readers.
¥Examples
¥Invalid
code-block.js:2:3 lint/correctness/noUnusedPrivateClassMembers FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ This private class member is defined but never used.
1 │ class OnlyWrite {
> 2 │ #usedOnlyInWrite = 5;
│ ^^^^^^^^^^^^^^^^
3 │
4 │ method() {
ℹ Unsafe fix: Remove unused declaration.
1 1 │ class OnlyWrite {
2 │ - ··#usedOnlyInWrite·=·5;
3 2 │
4 3 │ method() {
code-block.ts:2:12 lint/correctness/noUnusedPrivateClassMembers FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ This private class member is defined but never used.
1 │ class TsBioo {
> 2 │ private unusedProperty = 5;
│ ^^^^^^^^^^^^^^
3 │ }
4 │
ℹ Unsafe fix: Remove unused declaration.
1 1 │ class TsBioo {
2 │ - ···private·unusedProperty·=·5;
3 2 │ }
4 3 │
code-block.ts:2:12 lint/correctness/noUnusedPrivateClassMembers FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ This private class member is defined but never used.
1 │ class TsBioo {
> 2 │ private unusedMethod() {}
│ ^^^^^^^^^^^^
3 │ }
4 │
ℹ Unsafe fix: Remove unused declaration.
1 1 │ class TsBioo {
2 │ - ···private·unusedMethod()·{}
3 2 │ }
4 3 │
¥Valid
¥Related links