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

Commit 87cfab1

Browse files
authored
Tweak good/bad examples
1 parent 931c205 commit 87cfab1

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

es6/README.md

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ the app lifecycle), should be in `ALL_CAPS`. This means that things like global
7171
functions would still be `camelCased`. See examples below.
7272

7373
```javascript
74-
// GOOD
74+
// GOOD: constant data
7575
export const DEFAULT_NAME = 'Element'
7676
7777
const STATE_CALLBACKS = {
@@ -80,34 +80,40 @@ const STATE_CALLBACKS = {
8080
archived: sendArchivedResponse
8181
}
8282
83-
// BAD
83+
// BAD: constant data should be ALL_CAPS
8484
export const defaultName = 'Element'
8585
8686
class DatePicker {
8787
render() {
88-
// WRONG: constant is within a method
88+
// BAD: constant is within a method and should be camelCased
8989
const DEFAULT_VALUE = 0
9090
}
9191
}
9292
```
9393

94-
All other symbols (methods, variables, constants within a method) should be `camelCased`!
94+
All other symbols (methods, variables, and constants within a method) should be `camelCased`!
9595

9696
```javascript
97-
// GOOD - importing a function
98-
import {addToCart} from './actions'
97+
// BAD - functions aren't "data" or a "class" and so shouldn't be TitleCase
98+
export const ReceiveProductData = createAction('Receive Product Data')
9999
100-
// GOOD - exporting a function
100+
// GOOD - exporting a function with camelCase name
101101
export const receiveProductData = createAction('Receive Product Data')
102102
103-
class MyClass {
104-
// GOOD - local constant within class
105-
const name = 'Button'
106-
render() { ... }
107-
}
108103
109104
// BAD - `const` outside of a method should be ALL_CAPS
110105
const defaultName = 'Element'
106+
107+
// BAD - Not a constructor function and so should be camelCase
108+
const AddToCart = () => { console.log('Adding to cart') }
109+
110+
// GOOD - local constants within class or function
111+
class MyClass {
112+
const name = 'Button'
113+
render() {
114+
const button = <Button name={name} />
115+
}
116+
}
111117
```
112118

113119
## Overriding Lint Rules

0 commit comments

Comments
 (0)