@@ -71,7 +71,7 @@ the app lifecycle), should be in `ALL_CAPS`. This means that things like global
7171functions would still be `camelCased`. See examples below.
7272
7373` ` ` javascript
74- // GOOD
74+ // GOOD: constant data
7575export const DEFAULT_NAME = 'Element'
7676
7777const STATE_CALLBACKS = {
@@ -80,34 +80,40 @@ const STATE_CALLBACKS = {
8080 archived: sendArchivedResponse
8181}
8282
83- // BAD
83+ // BAD: constant data should be ALL_CAPS
8484export const defaultName = 'Element'
8585
8686class 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
101101export 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
110105const 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