You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CODING_STANDARDS.md
+25Lines changed: 25 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,6 +8,31 @@ New code should follow these rules, and old code should be changed over time to
8
8
- Each file should have a well-defined purpose and be concerned with a single narrow concept.
9
9
- Add unit tests for new code. As far as possible, one test per source file or logical group of files.
10
10
- Names should be as clear and concise as possible, avoiding opaque abbreviations.
11
+
- In conditions, the tested variable must appear on the left of the operator. This is to stay consistent with English, which writes/reads from left to right.
12
+
```
13
+
// GOOD:
14
+
// The test below reads "If age is above 18"
15
+
// (the test is on the value of `age` here, so it appears first)
16
+
if (age >= 18) {
17
+
drive();
18
+
}
19
+
```
20
+
instead of:
21
+
```
22
+
// BAD:
23
+
// The test below reads "If 18 is below age"
24
+
// (the test is on the value `age` yet it appears last, which doesn't read naturally)
25
+
if (18 <= age) {
26
+
drive();
27
+
}
28
+
```
29
+
- Executables (bash scripts, CLIs etc.) and their flags are named using `kebab-case` (e.g. `foo-bar --baz`).
30
+
31
+
## Bash
32
+
33
+
Only executable bash scripts must be set to be executable (e.g. via `chmod +x <file>`).
34
+
Executable bash scripts are named using `kebab-case` and do not have file extension (e.g. `my-bash-command` and **not**`my-bash-command.sh` or `my_bash_command`). Non-executable bash scripts are named in `snake_case` and have an `.sh` extension.
35
+
Use the `env` functionality by default in shebangs except if the context suggests otherwise (e.g. `#!/usr/bin/env bash` instead of `#!/bin/bash`).
0 commit comments