Skip to content

[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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2144,8 +2144,8 @@ Other Style Guides

## Blocks

<a name="blocks--braces"></a><a name="16.1"></a>
Copy link
Collaborator

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.

- [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)
Copy link
Collaborator

Choose a reason for hiding this comment

The 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, got the point.


```javascript
// bad
Expand All @@ -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();
}
```

Expand Down