airbnb / airbnb/javascript

Braces with single-line if blocks

Open
#1,211 1 comment 0 reactions 0 assignees View on GitHub
question
Dominant language
JavaScript
Stars
148k
Forks
26.6k
PR merge metrics
No merged PRs in 30d

Description

In point [16.1](https://github.com/airbnb/javascript/tree/master/#functions) you state the two block possibilities when it comes to in-line if blocks. These are:

```
if (test) return false;

if (test) {
return false;
}
```

Is there any preference to use one or the other?

Personally, I use the first one only at the top of a function, when I have to verify trivial preconditions. (i.e. `if (!name) return 'Name is required';`.

Contributor guide

No contributing guide indexed for this repository

Research direction

Review point 16.1 in the linked Functions section and the existing examples for single-line if blocks. Determine whether the guide should express a preference between the two forms, then update that guidance if a maintainer decision is reached. Done means the style guide gives an unambiguous answer to this question.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
documentation
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.