Top-level and per-instance initializers should not be empty.
- ⭐️ This rule is included in
plugin:@peggyjs/recommended
preset.
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"; }