Skip to content

Rule: then-after-if #8

@sjbarag

Description

@sjbarag

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

if foo then print "bar"
Option Allowed?
always
block-only 🚫
line-only
never 🚫
if foo print "bar"
Option Allowed?
always 🚫
block-only
line-only 🚫
never

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions