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 Proposal: nonblock-body-position

See original GitHub issue

From requireNewlineBeforeSingleStatementsInIf.

This rule will enforce the position of bare statements at the body of if, else, do-while',while,for,for-in, orfor-of`.

{
    "nonblock-body-position": ["error",  "below" or "beside" or "any"],
    // or
    "nonblock-body-position": ["error", {
        "position": "below" or "beside" or "any",
        "overrides": {
            "if": null,
            "else": null,
            "do-while": null,
            "while": null,
            "for": null,
            "for-in": null,
            "for-of": null
        }
    }]
}
  • position
    • "below" (default) - Requires newline before the body’s statement.
    • "beside" - Disallow newline before the body’s statement.
    • "any" - Does not enforce the position.
  • overrides - People can override setting for each kind.

Valid:

/*eslint nonblock-body-position: ["error", "below"]*/

if (a)
    foo();
else
    foo();

while (a)
    foo();

// ignore block statements (those are waned by brace-style)
if (a) { foo(); }
if (a) {
    foo();
}
/*eslint nonblock-body-position: ["error", "beside"]*/

if (a) foo();
else foo();

while (a) foo();

// ignore block statements (those are waned by brace-style)
if (a) { foo(); }
if (a) {
    foo();
}
/*eslint nonblock-body-position: ["error", {"position": "beside", "overrides": {"while": {"position": "below"}}}]*/

if (a) foo();
else foo();

while (a) 
    foo();

Invalid:

/*eslint nonblock-body-position: ["error", "below"]*/

if (a) foo();
else foo();

while (a) foo();
/*eslint nonblock-body-position: ["error", "beside"]*/

if (a)
    foo();
else
    foo();

while (a)
    foo();
/*eslint nonblock-body-position: ["error", {"position": "beside", "overrides": {"while": {"position": "below"}}}]*/

if (a)
    foo();
else
    foo();

while (a) foo();

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:3
  • Comments:13 (12 by maintainers)

github_iconTop GitHub Comments

2reactions
kaicataldocommented, Feb 20, 2017

Sorry to respond to this so late in the game, but I also wonder if we can decide on a name that more clearly describes what this rule is checking. nonblock-body-position wasn’t immediately clear to me, so I can imagine it would be confusing to someone who’s not a project maintainer. I know it’s long, but I think nonblock-statement-body-position would be clearer (hoping we can come up with a shorter/clearer name than that!).

1reaction
mysticateacommented, Feb 20, 2017

nonblock-statement-body-position makes sense to me.

I look at this again, I wonder if nonblock-statement-body-position should include the body of arrow expression as well, or not.

() => foo()
// or
() =>
    foo()
Read more comments on GitHub >

github_iconTop Results From Across the Web

SEC Proposed Rules
SEC Proposed Rules · Regulation NMS: Minimum Pricing Increments, Access Fees, and Transparency of Better Priced Orders · File No: S7-30-22 · Comments...
Read more >
How Companies Should Approach Shareholder Proposals ...
Rule 14a-8 requires that a company include a shareholder proposal in its proxy statement unless a specific basis for exclusion in the rule...
Read more >
SEC Proposes Amendments to the Shareholder Proposal Rules
The SEC proposed modifying certain bases for excluding shareholder proposals from company proxy statements. If adopted, these amendments are ...
Read more >
SEC Proposes Revisions to Shareholder Proposal Rules
The Securities and Exchange Commission (SEC) last month proposed revisions to Rule 14a-8 under the Securities Exchange Act of 1934, ...
Read more >
SEC Revisits Shareholder Proposal Rule | WilmerHale
... amendments to the proxy rules governing proxy voting advice and (b) proposing amendments to the shareholder proposal rule in Rule 14a-8.
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