Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rule: then-after-if #8

Open
sjbarag opened this issue Jun 15, 2021 · 2 comments
Open

Rule: then-after-if #8

sjbarag opened this issue Jun 15, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@sjbarag
Copy link
Contributor

sjbarag commented Jun 15, 2021

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
@sjbarag sjbarag added the enhancement New feature or request label Jun 15, 2021
@heftyfunseeker
Copy link
Contributor

This is a good one. Thanks for the examples too!

@sjbarag
Copy link
Contributor Author

sjbarag commented Jun 22, 2021

This is a good one. Thanks for the examples too!

Thanks! I should probably just make this a "new issue" template to make proposing new rules easier 🤷

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants