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.

New rule: newline-before-if

See original GitHub issue
  1. This rule will warn when no newline before if statement.

Correct:

const a = 10;

if (a === 10) {
}

Incorrect:

const a = 10;
if (a === 10) {
}
  1. This rule is stylistic only.
  2. This rule is can be widely used as it increases code readability.
  3. Yes. I can create rule by myself.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:6
  • Comments:15 (11 by maintainers)

github_iconTop GitHub Comments

10reactions
nzakascommented, Apr 27, 2016

JSCS has requireNewlineBeforeBlockStatements. I’m guessing we’d need the equivalent rather than one that is just specific to if.

6reactions
sindresorhuscommented, Apr 27, 2016

Would be useful to be able to enforce newline after a block too. Like requirePaddingNewLinesAfterBlocks. Maybe space-around-block.

Similar to http://eslint.org/docs/rules/padded-blocks, but outside blocks.

Related issue: https://github.com/eslint/eslint/issues/3092

Read more comments on GitHub >

github_iconTop Results From Across the Web

newline-before-return - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
proposed revisions to - Supreme Court
An amendment to Rule 37.4 sets forth requirements concerning amicus curiae briefs in connection with emergency applications. The new provision discourages these ...
Read more >
Proposed Rules - GovInfo
The revised. Common Rule includes provisions intended to strengthen the effectiveness of the human subject protection regulations, and FDA is ...
Read more >
Sass Guidelines
Always an empty new line before @if ;; Always a line break after the opening brace ( { );; @else statements on the...
Read more >
JavaScript packages index - Page 933 | Snyk Advisor - Snyk
... eslint-plugin-my-custom-plugin · eslint-plugin-my-custom-rules ... eslint-plugin-new-line-before-if · eslint-plugin-newline-before-paren ...
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