Skip to content

Latest commit

 

History

History
56 lines (40 loc) · 908 Bytes

no-empty-static-block.md

File metadata and controls

56 lines (40 loc) · 908 Bytes
title layout rule_type related_rules further_reading
no-empty-static-block
doc
suggestion
no-empty
no-empty-function

Empty static blocks, while not technically errors, usually occur due to refactoring that wasn't completed. They can cause confusion when reading code.

Rule Details

This rule disallows empty static blocks. This rule ignores static blocks which contain a comment.

Examples of incorrect code for this rule:

::: incorrect

/*eslint no-empty-static-block: "error"*/

class Foo {
    static {}
}

:::

Examples of correct code for this rule:

:::correct

/*eslint no-empty-static-block: "error"*/

class Foo {
    static {
        bar();
    }
}

class Foo {
    static {
        // comment
    }
}

:::

When Not To Use It

This rule should not be used in environments prior to ES2022.