Skip to content

Latest commit

 

History

History
47 lines (35 loc) · 1.34 KB

no-empty-code-blocks.md

File metadata and controls

47 lines (35 loc) · 1.34 KB

@peggyjs/no-empty-code-blocks

Code blocks should not be empty.

  • ⭐️ This rule is included in plugin:@peggyjs/recommended preset.
  • ✒️ This rule will fix all errors it finds.

📖 Rule Details

Actions are the Javascript code that follow an expression. When provided, they replace the default result of the expression to be whatever the return value of the action is. They should always have some JavaScript inside.

Semantic predicates also should have some JavaScript inside their code blocks. If you are using the rule @peggyjs/semantic-predicate-must-return, then that rule will also trigger for empty blocks. If you are not using that rule, you can have this rule fire for empty semantic predicates.

👎 Examples of incorrect code for this rule:

// eslint @peggyjs/no-empty-code-blocks
foo = "1" {}
// eslint @peggyjs/no-empty-code-blocks: ["error", "semantic"]
foo = &{} "1"
bar = !{} "1"

👍 Examples of correct code for this rule:

// eslint @peggyjs/no-empty-code-blocks
foo = "1" { return 1; }
// eslint @peggyjs/no-empty-code-blocks: ["error", "semantic"]
foo = &{ return true; } "1"
bar = !{ return false; } "1"

🔎 Implementation