Skip to content

Commit 5c1e939

Browse files
committed
Update ESLint config and fix errors
1 parent 06ff577 commit 5c1e939

14 files changed

+71
-60
lines changed

.eslintrc

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,18 @@
1111
},
1212
"parser": "babel-eslint",
1313
"rules": {
14+
"array-bracket-spacing": [2, "always"],
15+
"comma-dangle": [2, "never"],
16+
"object-curly-spacing": [2, "always"],
17+
"quotes": [2, "single", "avoid-escape"],
18+
"semi": [2, "never"],
1419
"strict": 0,
15-
"react/prop-types": 2,
16-
"react/jsx-uses-react": 1
20+
"space-before-blocks": [2, "always"],
21+
"space-before-function-paren": [2, {"anonymous":"always","named":"never"}],
22+
"react/jsx-uses-react": 1,
23+
"react/jsx-quotes": 2,
24+
"react/jsx-no-undef": 2,
25+
"react/wrap-multilines": 2
1726
},
1827
"plugins": [
1928
"react"

modules/History.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const History = {
44

55
contextTypes: { history },
66

7-
componentWillMount () {
7+
componentWillMount() {
88
this.history = this.context.history
99
}
1010

modules/PatternUtils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import invariant from 'invariant'
22

33
function escapeRegExp(string) {
4-
return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")
4+
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
55
}
66

77
function escapeSource(string) {

modules/Router.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ const Router = React.createClass({
6666
componentWillReceiveProps(nextProps) {
6767
warning(
6868
nextProps.history === this.props.history,
69-
"The `history` provided to <Router/> has changed, it will be ignored."
69+
'You cannot change <Router history>; it will be ignored'
7070
)
7171
},
7272

modules/__tests__/History-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ describe('History Mixin', function () {
2727
let Component = React.createClass({
2828
mixins: [ History ],
2929
componentWillMount: assertHistory,
30-
render () { return null }
30+
render() { return null }
3131
})
3232

3333
React.render((

modules/__tests__/IndexRoute-test.js

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,27 @@ import Route from '../Route'
99

1010
describe('an <IndexRoute/>', function () {
1111

12-
var node
13-
beforeEach(function () {
14-
node = document.createElement('div')
15-
})
16-
17-
afterEach(function () {
18-
React.unmountComponentAtNode(node)
19-
})
20-
21-
var Parent = React.createClass({
22-
render () {
12+
const Parent = React.createClass({
13+
render() {
2314
return <div>parent {this.props.children}</div>
2415
}
2516
})
2617

27-
var Child = React.createClass({
28-
render () {
18+
const Child = React.createClass({
19+
render() {
2920
return <div>child </div>
3021
}
3122
})
3223

24+
let node
25+
beforeEach(function () {
26+
node = document.createElement('div')
27+
})
28+
29+
afterEach(function () {
30+
React.unmountComponentAtNode(node)
31+
})
32+
3333
it('renders when its parent’s url matches exactly', function (done) {
3434
React.render((
3535
<Router history={createHistory('/')}>
@@ -60,4 +60,5 @@ describe('an <IndexRoute/>', function () {
6060
})
6161
})
6262
})
63+
6364
})

modules/__tests__/Link-test.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@ const { click } = React.addons.TestUtils.Simulate
1313

1414
describe('A <Link>', function () {
1515

16-
let node
17-
beforeEach(function () {
18-
node = document.createElement('div')
19-
})
20-
2116
const Hello = React.createClass({
2217
render() {
2318
return <div>Hello {this.props.params.name}!</div>
@@ -30,10 +25,15 @@ describe('A <Link>', function () {
3025
}
3126
})
3227

28+
let node
29+
beforeEach(function () {
30+
node = document.createElement('div')
31+
})
32+
3333
it('knows how to make its href', function () {
3434
const LinkWrapper = React.createClass({
3535
render() {
36-
return <Link to="/hello/michael" query={{the: 'query'}}>Link</Link>
36+
return <Link to="/hello/michael" query={{ the: 'query' }}>Link</Link>
3737
}
3838
})
3939

@@ -209,7 +209,7 @@ describe('A <Link>', function () {
209209
const execNextStep = execSteps(steps, done)
210210

211211
React.render((
212-
<Router history={createHistory("/goodbye")} onUpdate={execNextStep}>
212+
<Router history={createHistory('/goodbye')} onUpdate={execNextStep}>
213213
<Route path="/" component={LinkWrapper}>
214214
<Route path="hello" component={Hello} />
215215
<Route path="goodbye" component={Goodbye} />
@@ -219,8 +219,8 @@ describe('A <Link>', function () {
219219
})
220220
})
221221

222-
describe('when route changes', function() {
223-
it.skip('changes active state', function(done) {
222+
describe('when route changes', function () {
223+
it.skip('changes active state', function (done) {
224224
const LinkWrapper = React.createClass({
225225
shouldComponentUpdate() {
226226
return false

modules/__tests__/RouteComponent-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ describe('a Route Component', function () {
3232

3333
function assertProps(props) {
3434
expect(props.route).toEqual(parent)
35-
expect(props.routes).toEqual([parent, child])
35+
expect(props.routes).toEqual([ parent, child ])
3636
}
3737

3838
React.render((

modules/__tests__/Router-test.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ describe('Router', function () {
8282
})
8383
})
8484

85-
it('renders with a custom `createElement` prop', function(done) {
85+
it('renders with a custom `createElement` prop', function (done) {
8686
const Wrapper = React.createClass({
8787
render() {
8888
const { Component } = this.props
@@ -106,8 +106,8 @@ describe('Router', function () {
106106
})
107107
})
108108

109-
describe('with named components', function() {
110-
it('renders the named components', function(done) {
109+
describe('with named components', function () {
110+
it('renders the named components', function (done) {
111111
const Parent = React.createClass({
112112
render() {
113113
return (
@@ -133,7 +133,7 @@ describe('Router', function () {
133133
React.render((
134134
<Router history={createHistory('/')}>
135135
<Route component={Parent}>
136-
<Route path="/" components={{sidebar: Sidebar, content: Content}} />
136+
<Route path="/" components={{ sidebar: Sidebar, content: Content }} />
137137
</Route>
138138
</Router>
139139
), node, function () {
@@ -144,10 +144,10 @@ describe('Router', function () {
144144
})
145145

146146
describe('at a route with special characters', function () {
147-
it('does not double escape', function(done) {
147+
it('does not double escape', function (done) {
148148
// https://github.com/rackt/react-router/issues/1574
149149
let MyComponent = React.createClass({
150-
render () { return <div>{this.props.params.some_token}</div> }
150+
render() { return <div>{this.props.params.some_token}</div> }
151151
})
152152

153153
React.render((
@@ -160,13 +160,13 @@ describe('Router', function () {
160160
})
161161
})
162162

163-
it('does not double escape when nested', function(done) {
163+
it('does not double escape when nested', function (done) {
164164
// https://github.com/rackt/react-router/issues/1574
165165
let MyWrapperComponent = React.createClass({
166-
render () { return this.props.children }
166+
render() { return this.props.children }
167167
})
168168
let MyComponent = React.createClass({
169-
render () { return <div>{this.props.params.some_token}</div> }
169+
render() { return <div>{this.props.params.some_token}</div> }
170170
})
171171

172172
React.render((
@@ -181,10 +181,10 @@ describe('Router', function () {
181181
})
182182
})
183183

184-
it('is happy to have colons in parameter values', function(done) {
184+
it('is happy to have colons in parameter values', function (done) {
185185
// https://github.com/rackt/react-router/issues/1759
186186
let MyComponent = React.createClass({
187-
render () { return <div>{this.props.params.foo}</div> }
187+
render() { return <div>{this.props.params.foo}</div> }
188188
})
189189

190190
React.render((
@@ -197,10 +197,10 @@ describe('Router', function () {
197197
})
198198
})
199199

200-
it('handles % in parameters', function(done) {
200+
it('handles % in parameters', function (done) {
201201
// https://github.com/rackt/react-router/issues/1766
202202
let MyComponent = React.createClass({
203-
render () { return <div>{this.props.params.name}</div> }
203+
render() { return <div>{this.props.params.name}</div> }
204204
})
205205

206206
React.render((
@@ -213,7 +213,7 @@ describe('Router', function () {
213213
})
214214
})
215215

216-
it('handles forward slashes', function(done) {
216+
it('handles forward slashes', function (done) {
217217
// https://github.com/rackt/react-router/issues/1865
218218
class Parent extends React.Component {
219219
render() {
@@ -223,7 +223,7 @@ describe('Router', function () {
223223

224224
class Child extends React.Component {
225225
render() {
226-
const {params} = this.props
226+
const { params } = this.props
227227
return <h1>{params.name}</h1>
228228
}
229229
}

modules/__tests__/matchRoutes-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ describe('matchRoutes', function () {
233233
])
234234
})
235235

236-
it('when getChildRoutes callback returns reactElements', function(done) {
236+
it('when getChildRoutes callback returns reactElements', function (done) {
237237
matchRoutes(jsxRoutes, createLocation('/users/5'), function (error, match) {
238238
assert(match)
239239
expect(match.routes.map(r => r.path)).toEqual([ 'users', ':userID' ])
@@ -242,7 +242,7 @@ describe('matchRoutes', function () {
242242
})
243243
})
244244

245-
it('when getIndexRoute callback returns reactElements', function(done) {
245+
it('when getIndexRoute callback returns reactElements', function (done) {
246246
matchRoutes(jsxRoutes, createLocation('/users'), function (error, match) {
247247
assert(match)
248248
expect(match.routes.map(r => r.name)).toEqual([ 'users', 'jsx' ])

0 commit comments

Comments
 (0)