|
1 | 1 | # Javascript Best Practices |
2 | 2 |
|
| 3 | +This is a guide to work with Javascript on IcaliaLabs projects. |
| 4 | + |
| 5 | +## General Guidelines |
| 6 | + |
| 7 | +When working with javascript try to follow this simple rules: |
| 8 | + |
| 9 | +* Use camelcase for method/variable naming |
| 10 | +* Never use global variables |
| 11 | +* Encapsulate logic in classes, as they are easier to test. Use syntax transpiler for this, such as [babel](http://babeljs.io/). |
| 12 | +* Use underscore at the beginning for private methods naming |
| 13 | +* Prefer to isolate javascript code on individual files |
| 14 | +* Prefer not to use the script tag on HTML for inline javascript code |
| 15 | + |
3 | 16 | ## Package management |
4 | 17 |
|
5 | | -Always use `yarn` instead of plain `npm`: |
6 | | - - Yarn package resolution performance is better |
7 | | - - Yarn selective dependency resolution is required to [deal with vulnerable sub-dependencies](#dealing-with-vulnerable-sub-dependencies) |
8 | | - - Yarn workspaces feature may become commonly required |
| 18 | +* Always use `yarn` instead of plain `npm`: |
| 19 | + * Yarn package resolution performance is better |
| 20 | + * Yarn selective dependency resolution is required to [deal with vulnerable sub-dependencies](#dealing-with-vulnerable-sub-dependencies) |
| 21 | + * Yarn workspaces feature may become commonly required |
| 22 | + |
| 23 | +## Code Review |
| 24 | + |
| 25 | +There are simple guidelines when providing code review to a teammate. The most particular are: |
| 26 | + |
| 27 | +* Review for bad variable names |
| 28 | +* Review bad class definition |
| 29 | +* Review for class names |
| 30 | +* Review for correct dependencies invocation |
| 31 | +* Review for specs |
9 | 32 |
|
10 | 33 | ## Dealing with vulnerable sub-dependencies |
11 | 34 |
|
|
0 commit comments