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

JS: Require curly braces in switch cases #1268

Merged
merged 3 commits into from
Dec 18, 2023

Conversation

ibc
Copy link
Member

@ibc ibc commented Dec 15, 2023

Details

  • Require { } in each case block.
  • There is no real ESLint rule for it so we must use this:
    'no-restricted-syntax'      : [ 2,
      {
        'selector' : 'SwitchCase > *.consequent[type!="BlockStatement"]'
        'message'  : 'Switch cases without blocks are disallowed'
      }
    ]

@ibc ibc requested a review from jmillan December 15, 2023 14:16
@jmillan
Copy link
Member

jmillan commented Dec 18, 2023

@ibc, this rule is working fine: 'selector' : 'SwitchCase > *.consequent[type!="BlockStatement"]',

NOTE: It does not give those false positives.

@ibc
Copy link
Member Author

ibc commented Dec 18, 2023

'selector' : 'SwitchCase > *.consequent[type!="BlockStatement"]'

AMAZING, applied.

@ibc ibc merged commit 553ef36 into v3 Dec 18, 2023
35 checks passed
@ibc ibc deleted the js-require-curly-braces-in-switch-cases branch December 18, 2023 11:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants