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

Commit 3018502

Browse files
author
Jeremy Wiebe
committed
Tweak constant naming rules
1 parent bdbd247 commit 3018502

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

es6/README.md

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,19 +65,38 @@ var LinkLabel = function() { }
6565
class linkLabel { }
6666
```
6767

68-
All other symbols (methods, variables, even constants) should be camelCased!
68+
Constant values that appear outside of a method scope should be in ALL_CAPS
6969

7070
```javascript
7171
// GOOD
72-
const defaultName = 'Element'
72+
export DEFAULT_NAME = 'Element'
73+
74+
const STATE_CALLBACKS {
75+
pending: sendPendingResponse,
76+
completed: sendCompletedResponse,
77+
archived: sendArchivedResponse
78+
}
7379
80+
// BAD
81+
class DatePicker {
82+
render() {
83+
// WRONG: constant is within a method
84+
const DEFAULT_VALUE = 0
85+
}
86+
}
87+
```
88+
89+
All other symbols (methods, variables, constants within a method) should be camelCased!
90+
91+
```javascript
92+
// GOOD
7493
class MyClass {
7594
const name = 'Button'
7695
render() { ... }
7796
}
7897
79-
// BAD - ES6 has `const` now. The compiler/interpreter will warn you if you re-assign a const.
80-
const DEFAULT_NAME = 'Element'
98+
// BAD - `const` outside of a method should be ALL_CAPS
99+
const defaultName = 'Element'
81100
```
82101

83102
## Overriding Lint Rules

0 commit comments

Comments
 (0)