规则名 | 规则类型 | 关联规则 | 深入了解 | ||
---|---|---|---|---|---|
no-empty-static-block |
suggestion |
|
Empty static blocks, while not technically errors, usually occur due to refactoring that wasn't completed. They can cause confusion when reading code.
This rule disallows empty static blocks. This rule ignores static blocks which contain a comment.
此规则的 错误 代码实例:
/*eslint no-empty-static-block: "error"*/
class Foo {
static {}
}
此规则的 正确 代码实例:
/*eslint no-empty-static-block: "error"*/
class Foo {
static {
bar();
}
}
class Foo {
static {
// comment
}
}
This rule should not be used in environments prior to ES2022.