question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Rule to enforce consistent spacing after if statement parens when no braces are present

See original GitHub issue

Please describe what the rule should do: Enforce consistent spacing after if statement parens when no braces are present.

What category of rule is this? [ ] Warns about a potential error (problem) [ ] Suggests an alternate way of doing something (suggestion) [X] Enforces code style (layout) [ ] Other (please specify:)

Provide 2-3 code examples that this rule will warn about:

if (something)doStuff(); // "warns"
if (something) doStuff(); // "correct usage"

Why should this rule be included in ESLint (instead of a plugin)? Because it’s not specific to a framework/runtime, it’s a general JS styling preference.

Are you willing to submit a pull request to implement this rule? I haven’t contributed in ESLint before, and quite unfamiliar with the codebase. I don’t mind trying, though.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:9 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
kaicataldocommented, Mar 30, 2020

I would be in favor of updating space-before-blocks rather than creating a separate rule.

1reaction
mdjermanoviccommented, Apr 10, 2020

@anikethsaha this rule change isn’t accepted yet, let’s see if it will reach the consensus first.

Read more comments on GitHub >

github_iconTop Results From Across the Web

object-curly-spacing - ESLint - Pluggable JavaScript Linter
Rule Details​​ This rule enforces consistent spacing inside braces of object literals, destructuring assignments, and import/export specifiers.
Read more >
Is it a bad practice to use an if-statement without curly braces?
If there's an else clause, or if the code I want to execute on true is of significant length, braces all the way:...
Read more >
space between parens () and brakets []? · Issue #1303 - GitHub
Basically adding spaces between parens and brackets. Function arguments: So: function foo( one, two, ...
Read more >
coding style - Single statement if block - braces or no?
The first is better because the second is error-prone. For example, let's say you are temporarily commenting out code to debug something:
Read more >
Optional Braces - Scala 3 - EPFL
In a brace-delimited region, no statement is allowed to start to the left of the first statement after the opening brace that starts...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found