Skip to content

Latest commit

 

History

History
44 lines (28 loc) · 1.04 KB

semantic-predicate-must-return.md

File metadata and controls

44 lines (28 loc) · 1.04 KB

@peggyjs/semantic-predicate-must-return

Top-level and per-instance initializers should not be empty.

  • ⭐️ This rule is included in plugin:@peggyjs/recommended preset.

📖 Rule Details

Semantic predicates (&{} and !{}) are used to assert that a certain condition is either true or false a the current parse position. They make no sense if they do not return something truthy or falsy.

👎 Examples of incorrect code for this rule:

// eslint @peggyjs/semantic-predicate-must-return

foo = n:"1" &{ n === "1"; }
// eslint @peggyjs/semantic-predicate-must-return

foo = n:"1" !{ n === "2"; }

👍 Examples of correct code for this rule:

// eslint @peggyjs/semantic-predicate-must-return

foo = n:"1" &{ return n === "1"; }
// eslint @peggyjs/semantic-predicate-must-return

foo = n:"1" !{ return n === "2"; }

🔎 Implementation