-
Notifications
You must be signed in to change notification settings - Fork 26.8k
[readme] update blocks 16.1 #2513
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2144,8 +2144,8 @@ Other Style Guides | |
|
||
## Blocks | ||
|
||
<a name="blocks--braces"></a><a name="16.1"></a> | ||
- [16.1](#blocks--braces) Use braces with all multiline blocks. eslint: [`nonblock-statement-body-position`](https://eslint.org/docs/rules/nonblock-statement-body-position) | ||
<a name="blocks--braces"></a> | ||
- [16.1](#blocks--braces) Use braces with `if`, `else`, `while`, `do-while`, and `for` statements when writing multiline blocks. eslint: [`nonblock-statement-body-position`](https://eslint.org/docs/rules/nonblock-statement-body-position) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's because function bodies aren't a block, they're a function body. The eslint rule doesn't ever have to cover the entirety of the guide section - the guide is the source of truth, and the guide applies to all blocks. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok, got the point. |
||
|
||
```javascript | ||
// bad | ||
|
@@ -2161,11 +2161,15 @@ Other Style Guides | |
} | ||
|
||
// bad | ||
function foo() { return false; } | ||
while (foo) | ||
bar(); | ||
|
||
// good | ||
function bar() { | ||
return false; | ||
while (foo) bar(); | ||
|
||
// good | ||
while (foo) { | ||
bar(); | ||
} | ||
``` | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
existing numbered links must never be removed; URLs must work forever.