Rule Proposal: nonblock-body-position
See original GitHub issueFrom requireNewlineBeforeSingleStatementsInIf.
This rule will enforce the position of bare statements at the body of if
, else
, do-while',
while,
for,
for-in, or
for-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:
- Created 7 years ago
- Reactions:3
- Comments:13 (12 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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 thinknonblock-statement-body-position
would be clearer (hoping we can come up with a shorter/clearer name than that!).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.