Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Commit d13700a

Browse files
authored
Adding a small section on naming
1 parent c006c6d commit d13700a

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

es6/README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,35 @@ globals:
5151
The boolean value indicates whether the global is to be treated as
5252
read-only (`false`) or read-write (`true`).
5353

54+
## Naming
55+
56+
Classes and constructor functions should be TitleCased
57+
58+
```javascript
59+
// GOOD
60+
class DatePicker { }
61+
62+
var LinkLabel = function() { }
63+
64+
// BAD
65+
class linkLabel { }
66+
```
67+
68+
All other symbols (methods, variables, even constants) should be camelCased!
69+
70+
```javascript
71+
// GOOD
72+
const defaultName = 'Element'
73+
74+
class MyClass {
75+
const name = 'Button'
76+
render() { ... }
77+
}
78+
79+
// BAD - ES6 has `const` now. The compiler/interpreter will warn you if you re-assign a const.
80+
const DEFAULT_NAME = 'Element'
81+
```
82+
5483
## Overriding Lint Rules
5584

5685
Some of the lint rules disallow uncommon but valid behaviour that is easily confused with/typoed from much more common behaviour. If you need to use the disallowed behaviour on purpose, use an explicit lint override in the source.

0 commit comments

Comments
 (0)