Skip to content

Commit 07504d5

Browse files
committed
Merge pull request #173 from rackt/rackt-eslint-config
Switch to rackt eslint config
2 parents eafe60f + 2c8f9a7 commit 07504d5

21 files changed

+804
-808
lines changed

.eslintrc

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
11
{
2-
"extends": "eslint-config-airbnb",
2+
"extends": "eslint-config-rackt",
33
"env": {
44
"browser": true,
55
"mocha": true,
66
"node": true
77
},
88
"rules": {
9-
"react/jsx-uses-react": 2,
10-
"react/jsx-uses-vars": 2,
11-
"react/react-in-jsx-scope": 2,
12-
13-
//Temporarirly disabled due to a possible bug in babel-eslint (todomvc example)
14-
"block-scoped-var": 0,
15-
// Temporarily disabled for test/* until babel/babel-eslint#33 is resolved
16-
"padded-blocks": 0
9+
"valid-jsdoc": 2,
10+
"react/jsx-uses-react": 1,
11+
"react/jsx-no-undef": 2,
12+
"react/wrap-multilines": 2
1713
},
1814
"plugins": [
1915
"react"

docs/api.md

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ ReactDOM.render(
2121
<MyRootComponent />
2222
</Provider>,
2323
rootEl
24-
);
24+
)
2525
```
2626

2727
##### React Router 0.13
@@ -34,8 +34,8 @@ Router.run(routes, Router.HistoryLocation, (Handler, routerState) => { // note "
3434
<Handler routerState={routerState} />
3535
</Provider>,
3636
document.getElementById('root')
37-
);
38-
});
37+
)
38+
})
3939
```
4040

4141
##### React Router 1.0
@@ -46,7 +46,7 @@ ReactDOM.render(
4646
<Router history={history}>...</Router>
4747
</Provider>,
4848
targetEl
49-
);
49+
)
5050
```
5151

5252
### `connect([mapStateToProps], [mapDispatchToProps], [mergeProps], [options])`
@@ -99,7 +99,7 @@ Returns the wrapped component instance. Only available if you pass `{ withRef: t
9999
##### Inject just `dispatch` and don't listen to store
100100

101101
```js
102-
export default connect()(TodoApp);
102+
export default connect()(TodoApp)
103103
```
104104

105105
##### Inject `dispatch` and every field in the global state
@@ -109,151 +109,151 @@ export default connect()(TodoApp);
109109
>listen to a relevant slice of the state.
110110
111111
```js
112-
export default connect(state => state)(TodoApp);
112+
export default connect(state => state)(TodoApp)
113113
```
114114

115115
##### Inject `dispatch` and `todos`
116116

117117
```js
118118
function mapStateToProps(state) {
119-
return { todos: state.todos };
119+
return { todos: state.todos }
120120
}
121121

122-
export default connect(mapStateToProps)(TodoApp);
122+
export default connect(mapStateToProps)(TodoApp)
123123
```
124124

125125
##### Inject `todos` and all action creators (`addTodo`, `completeTodo`, ...)
126126

127127
```js
128-
import * as actionCreators from './actionCreators';
128+
import * as actionCreators from './actionCreators'
129129

130130
function mapStateToProps(state) {
131-
return { todos: state.todos };
131+
return { todos: state.todos }
132132
}
133133

134-
export default connect(mapStateToProps, actionCreators)(TodoApp);
134+
export default connect(mapStateToProps, actionCreators)(TodoApp)
135135
```
136136

137137
##### Inject `todos` and all action creators (`addTodo`, `completeTodo`, ...) as `actions`
138138

139139
```js
140-
import * as actionCreators from './actionCreators';
141-
import { bindActionCreators } from 'redux';
140+
import * as actionCreators from './actionCreators'
141+
import { bindActionCreators } from 'redux'
142142

143143
function mapStateToProps(state) {
144-
return { todos: state.todos };
144+
return { todos: state.todos }
145145
}
146146

147147
function mapDispatchToProps(dispatch) {
148-
return { actions: bindActionCreators(actionCreators, dispatch) };
148+
return { actions: bindActionCreators(actionCreators, dispatch) }
149149
}
150150

151-
export default connect(mapStateToProps, mapDispatchToProps)(TodoApp);
151+
export default connect(mapStateToProps, mapDispatchToProps)(TodoApp)
152152
```
153153

154154
##### Inject `todos` and a specific action creator (`addTodo`)
155155

156156
```js
157-
import { addTodo } from './actionCreators';
158-
import { bindActionCreators } from 'redux';
157+
import { addTodo } from './actionCreators'
158+
import { bindActionCreators } from 'redux'
159159

160160
function mapStateToProps(state) {
161-
return { todos: state.todos };
161+
return { todos: state.todos }
162162
}
163163

164164
function mapDispatchToProps(dispatch) {
165-
return bindActionCreators({ addTodo }, dispatch);
165+
return bindActionCreators({ addTodo }, dispatch)
166166
}
167167

168-
export default connect(mapStateToProps, mapDispatchToProps)(TodoApp);
168+
export default connect(mapStateToProps, mapDispatchToProps)(TodoApp)
169169
```
170170

171171
##### Inject `todos`, todoActionCreators as `todoActions`, and counterActionCreators as `counterActions`
172172

173173
```js
174-
import * as todoActionCreators from './todoActionCreators';
175-
import * as counterActionCreators from './counterActionCreators';
176-
import { bindActionCreators } from 'redux';
174+
import * as todoActionCreators from './todoActionCreators'
175+
import * as counterActionCreators from './counterActionCreators'
176+
import { bindActionCreators } from 'redux'
177177

178178
function mapStateToProps(state) {
179-
return { todos: state.todos };
179+
return { todos: state.todos }
180180
}
181181

182182
function mapDispatchToProps(dispatch) {
183183
return {
184184
todoActions: bindActionCreators(todoActionCreators, dispatch),
185185
counterActions: bindActionCreators(counterActionCreators, dispatch)
186-
};
186+
}
187187
}
188188

189-
export default connect(mapStateToProps, mapDispatchToProps)(TodoApp);
189+
export default connect(mapStateToProps, mapDispatchToProps)(TodoApp)
190190
```
191191

192192
##### Inject `todos`, and todoActionCreators and counterActionCreators together as `actions`
193193

194194
```js
195-
import * as todoActionCreators from './todoActionCreators';
196-
import * as counterActionCreators from './counterActionCreators';
197-
import { bindActionCreators } from 'redux';
195+
import * as todoActionCreators from './todoActionCreators'
196+
import * as counterActionCreators from './counterActionCreators'
197+
import { bindActionCreators } from 'redux'
198198

199199
function mapStateToProps(state) {
200-
return { todos: state.todos };
200+
return { todos: state.todos }
201201
}
202202

203203
function mapDispatchToProps(dispatch) {
204204
return {
205205
actions: bindActionCreators(Object.assign({}, todoActionCreators, counterActionCreators), dispatch)
206-
};
206+
}
207207
}
208208

209-
export default connect(mapStateToProps, mapDispatchToProps)(TodoApp);
209+
export default connect(mapStateToProps, mapDispatchToProps)(TodoApp)
210210
```
211211

212212
##### Inject `todos`, and all todoActionCreators and counterActionCreators directly as props
213213

214214
```js
215-
import * as todoActionCreators from './todoActionCreators';
216-
import * as counterActionCreators from './counterActionCreators';
217-
import { bindActionCreators } from 'redux';
215+
import * as todoActionCreators from './todoActionCreators'
216+
import * as counterActionCreators from './counterActionCreators'
217+
import { bindActionCreators } from 'redux'
218218

219219
function mapStateToProps(state) {
220-
return { todos: state.todos };
220+
return { todos: state.todos }
221221
}
222222

223223
function mapDispatchToProps(dispatch) {
224-
return bindActionCreators(Object.assign({}, todoActionCreators, counterActionCreators), dispatch);
224+
return bindActionCreators(Object.assign({}, todoActionCreators, counterActionCreators), dispatch)
225225
}
226226

227-
export default connect(mapStateToProps, mapDispatchToProps)(TodoApp);
227+
export default connect(mapStateToProps, mapDispatchToProps)(TodoApp)
228228
```
229229

230230
##### Inject `todos` of a specific user depending on props
231231

232232
```js
233-
import * as actionCreators from './actionCreators';
233+
import * as actionCreators from './actionCreators'
234234

235235
function mapStateToProps(state, ownProps) {
236-
return { todos: state.todos[ownProps.userId] };
236+
return { todos: state.todos[ownProps.userId] }
237237
}
238238

239-
export default connect(mapStateToProps)(TodoApp);
239+
export default connect(mapStateToProps)(TodoApp)
240240
```
241241

242242
##### Inject `todos` of a specific user depending on props, and inject `props.userId` into the action
243243

244244
```js
245-
import * as actionCreators from './actionCreators';
245+
import * as actionCreators from './actionCreators'
246246

247247
function mapStateToProps(state) {
248-
return { todos: state.todos };
248+
return { todos: state.todos }
249249
}
250250

251251
function mergeProps(stateProps, dispatchProps, ownProps) {
252252
return Object.assign({}, ownProps, {
253253
todos: stateProps.todos[ownProps.userId],
254254
addTodo: (text) => dispatchProps.addTodo(ownProps.userId, text)
255-
});
255+
})
256256
}
257257

258-
export default connect(mapStateToProps, actionCreators, mergeProps)(TodoApp);
258+
export default connect(mapStateToProps, actionCreators, mergeProps)(TodoApp)
259259
```

docs/quick-start.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export default class Counter extends Component {
5050
<button onClick={this.props.onIncrement}>
5151
{this.props.value}
5252
</button>
53-
);
53+
)
5454
}
5555
}
5656
```
@@ -64,30 +64,30 @@ We will use the `connect()` function provided by `react-redux` to turn a “dumb
6464
##### `containers/CounterContainer.js`
6565

6666
```js
67-
import { Component } from 'react';
68-
import { connect } from 'react-redux';
67+
import { Component } from 'react'
68+
import { connect } from 'react-redux'
6969

70-
import Counter from '../components/Counter';
71-
import { increment } from '../actionsCreators';
70+
import Counter from '../components/Counter'
71+
import { increment } from '../actionsCreators'
7272

7373
// Which part of the Redux global state does our component want to receive as props?
7474
function mapStateToProps(state) {
7575
return {
7676
value: state.counter
77-
};
77+
}
7878
}
7979

8080
// Which action creators does it want to receive by props?
8181
function mapDispatchToProps(dispatch) {
8282
return {
8383
onIncrement: () => dispatch(increment())
84-
};
84+
}
8585
}
8686

8787
export default connect(
8888
mapStateToProps,
8989
mapDispatchToProps
90-
)(Counter);
90+
)(Counter)
9191

9292
// You can also pass an object instead of defining `mapDispatchToProps`:
9393
// export default connect(mapStateToProps, CounterActionCreators)(Counter);
@@ -129,22 +129,22 @@ Finally, how do we actually hook it up to the Redux store? We need to create the
129129
The trick is to wrap the whole view hierarchy into a `<Provider>` from React Redux.
130130

131131
```js
132-
import ReactDOM from 'react-dom';
133-
import { Component } from 'react';
134-
import { Provider } from 'react-redux';
132+
import ReactDOM from 'react-dom'
133+
import { Component } from 'react'
134+
import { Provider } from 'react-redux'
135135

136136
class App extends Component {
137137
render() {
138138
// ...
139139
}
140140
}
141141

142-
const targetEl = document.getElementById('root');
142+
const targetEl = document.getElementById('root')
143143

144144
ReactDOM.render(
145145
<Provider store={store}>
146146
<App />
147147
</Provider>,
148148
targetEl
149-
);
149+
)
150150
```

docs/troubleshooting.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,16 @@ Router.run(routes, Router.HistoryLocation, (Handler, routerState) => { // note "
2424
<Handler routerState={routerState} />
2525
</Provider>,
2626
document.getElementById('root')
27-
);
28-
});
27+
)
28+
})
2929
```
3030

3131
Nested view:
3232

3333
```js
3434
render() {
3535
// Keep passing it down
36-
return <RouteHandler routerState={this.props.routerState} />;
36+
return <RouteHandler routerState={this.props.routerState} />
3737
}
3838
```
3939

@@ -52,12 +52,12 @@ If that’s not practical for whatever reason (for example, if you’re using a
5252

5353
```
5454
function mapStateToProps(state) {
55-
return { todos: state.todos };
55+
return { todos: state.todos }
5656
}
5757
5858
export default connect(mapStateToProps, null, null, {
5959
pure: false
60-
})(TodoApp);
60+
})(TodoApp)
6161
```
6262

6363
This will remove the assumption that `TodoApp` is pure and cause it to update whenever its parent component renders. Note that this will make your application less performant, so only do this if you have no other option.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@
4141
"babel-core": "^5.8.22",
4242
"babel-eslint": "^3.1.15",
4343
"babel-loader": "^5.3.2",
44-
"eslint": "^0.23",
45-
"eslint-config-airbnb": "0.0.6",
46-
"eslint-plugin-react": "^2.3.0",
44+
"eslint": "^1.7.1",
45+
"eslint-config-rackt": "1.1.0",
46+
"eslint-plugin-react": "^3.6.3",
4747
"expect": "^1.8.0",
4848
"isparta": "^3.0.3",
4949
"istanbul": "^0.3.17",

0 commit comments

Comments
 (0)