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

feat: disable curly rule #20

Merged
merged 2 commits into from
May 18, 2024
Merged

feat: disable curly rule #20

merged 2 commits into from
May 18, 2024

Conversation

stefvw93
Copy link
Collaborator

Disable curly

  • current setup disallows single line control flow; subjective, but annoying imo, I want to if (statement) return

@stefvw93 stefvw93 requested a review from barisbora January 12, 2024 11:05
Copy link
Member

@thomasowow thomasowow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JavaScript allows the omission of curly braces when a block contains only one statement. However, it is considered by many to be best practice to never omit curly braces around blocks, even when they are optional, because it can lead to bugs and reduces code clarity.

Kind of agree with this, mostly for consistency. Inconsistency sometimes is less readable in my opinion.

@stefvw93
Copy link
Collaborator Author

stefvw93 commented Jan 12, 2024

@thomasowow @bb441db I added multi-or-nest

Incorrect

/*eslint curly: ["error", "multi-or-nest"]*/

if (!foo)
    foo = {
        bar: baz,
        qux: foo
    };

while (true)
  if(foo)
      doSomething();
  else
      doSomethingElse();

if (foo) {
    foo++;
}

while (true) {
    doSomething();
}

for (var i = 0; foo; i++) {
    doSomething();
}

correct

/*eslint curly: ["error", "multi-or-nest"]*/

if (!foo) {
    foo = {
        bar: baz,
        qux: foo
    };
}

while (true) {
  if (foo) doSomething();
  else doSomethingElse();
}

if (foo) foo++;

while (true) doSomething();

for (var i = 0; foo; i++) doSomething();

@stefvw93 stefvw93 requested a review from bb441db January 12, 2024 13:05
@thomasowow thomasowow self-requested a review February 21, 2024 10:50
@thomasowow thomasowow removed their request for review May 15, 2024 11:26
{ blankLine: 'always', prev: 'multiline-const', next: '*' },
{ blankLine: 'always', prev: '*', next: 'multiline-const' },
{ blankLine: 'always', prev: 'multiline-let', next: '*' },
{ blankLine: 'always', prev: '*', next: 'multiline-let' },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just question it covers return?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2024-05-17 at 15 32 51

I think we should keep return at least, I also really like if and for too

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, though: Could you create a separate PR for this? 🙏🏻

@stefvw93 stefvw93 merged commit 5324f7b into master May 18, 2024
1 check passed
@stefvw93 stefvw93 deleted the feature/disable-curly branch May 18, 2024 07:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants