Some codebases require the optional then keyword at the end of an if/else if statement's condition; others forbid it! Some even require it only for the single-line or only for the block variants of if. An eslint rule means humans don't need to watch for that sort of thing during code reviews!
Schema
Name: then-after-if
Options:
- String (enum)
- Values:
"always" | "block-only" | "line-only" | "never"
Examples
Block if statements
if foo then
print "bar"
end if
| Option |
Allowed? |
always |
✅ |
block-only |
✅ |
line-only |
🚫 |
never |
🚫 |
if foo
print "bar"
end if
| Option |
Allowed? |
always |
🚫 |
block-only |
🚫 |
line-only |
✅ |
never |
✅ |
Line if statements
| Option |
Allowed? |
always |
✅ |
block-only |
🚫 |
line-only |
✅ |
never |
🚫 |
| Option |
Allowed? |
always |
🚫 |
block-only |
✅ |
line-only |
🚫 |
never |
✅ |
Some codebases require the optional
thenkeyword at the end of anif/else ifstatement's condition; others forbid it! Some even require it only for the single-line or only for the block variants ofif. Aneslintrule means humans don't need to watch for that sort of thing during code reviews!Schema
Name:
then-after-ifOptions:
"always" | "block-only" | "line-only" | "never"Examples
Block
ifstatementsalwaysblock-onlyline-onlyneveralwaysblock-onlyline-onlyneverLine
ifstatementsalwaysblock-onlyline-onlyneveralwaysblock-onlyline-onlynever