Skip to content

Commit 25a849b

Browse files
committed
Merge branch 'master' of https://github.com/QbDVision-Inc/node-style-guide into rsshilli-patch-1
2 parents 38c9d04 + 7824b88 commit 25a849b

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

Readme.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ according to their preferences.
3232
* [Filenames](#filenames)
3333

3434
### Variables
35+
* [Use prefixes when naming booleans](#use-prefixes-when-naming-booleans)
3536
* [Never use var](#never-use-var)
3637
* [Object / Array creation](#object--array-creation)
3738

@@ -312,17 +313,24 @@ Directories are snake case (ex. `webapp/controlMethods`)
312313

313314
### Use prefixes when naming booleans
314315

315-
When naming booleans, use prefixes that give yes/no answers such as *is*, *has*, and *does*:
316+
When naming boolean variables (and functions that return booleans), use prefixes that give yes/no answers such as *is/are*, *has*, and *should*:
316317

317318
*Good:*
318319
```
319320
let isValid = true;
321+
let arePointersNull = false;
322+
let shouldRenderComponent = true;
323+
let hasLicense = true;
320324
```
321325

322326
*Bad:*
323327
```
324-
let valid = true; ← Bad
328+
let valid = true;
329+
let pointersNull = false;
330+
let renderComponent = true;
331+
let license = true;
325332
```
333+
Note: Avoid boolean variables that represent the negation of a condition unless necessary e.g., use isValid instead of isNotValid
326334

327335
### Never use var
328336

0 commit comments

Comments
 (0)