Skip to content

Commit 15b05b4

Browse files
committed
Run ESLint on examples too
1 parent 5c1e939 commit 15b05b4

File tree

41 files changed

+277
-323
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+277
-323
lines changed

.eslintrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
"rules": {
1414
"array-bracket-spacing": [2, "always"],
1515
"comma-dangle": [2, "never"],
16+
"eol-last": 2,
17+
"no-multiple-empty-lines": 2,
1618
"object-curly-spacing": [2, "always"],
1719
"quotes": [2, "single", "avoid-escape"],
1820
"semi": [2, "never"],

examples/animations/app.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ class App extends React.Component {
1414
render() {
1515
const { pathname } = this.props.location
1616

17-
console.log(pathname)
18-
1917
return (
2018
<div>
2119
<ul>

examples/auth-flow/app.js

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import React, { findDOMNode } from 'react';
2-
import { Router, Route, Link, History } from 'react-router';
1+
import React, { findDOMNode } from 'react'
2+
import { Router, Route, Link, History } from 'react-router'
33
import { createHistory, useBasename } from 'history'
4-
import auth from './auth';
4+
import auth from './auth'
55

66
const history = useBasename(createHistory)({
77
basename: '/auth-flow'
@@ -11,18 +11,18 @@ var App = React.createClass({
1111
getInitialState() {
1212
return {
1313
loggedIn: auth.loggedIn()
14-
};
14+
}
1515
},
1616

1717
updateAuth(loggedIn) {
1818
this.setState({
1919
loggedIn: loggedIn
20-
});
20+
})
2121
},
2222

2323
componentWillMount() {
24-
auth.onChange = this.updateAuth;
25-
auth.login();
24+
auth.onChange = this.updateAuth
25+
auth.login()
2626
},
2727

2828
render() {
@@ -41,51 +41,51 @@ var App = React.createClass({
4141
</ul>
4242
{this.props.children}
4343
</div>
44-
);
44+
)
4545
}
46-
});
46+
})
4747

4848
var Dashboard = React.createClass({
4949
render() {
50-
var token = auth.getToken();
50+
var token = auth.getToken()
5151

5252
return (
5353
<div>
5454
<h1>Dashboard</h1>
5555
<p>You made it!</p>
5656
<p>{token}</p>
5757
</div>
58-
);
58+
)
5959
}
60-
});
60+
})
6161

6262
var Login = React.createClass({
6363
mixins: [ History ],
6464

6565
getInitialState() {
6666
return {
6767
error: false
68-
};
68+
}
6969
},
7070

7171
handleSubmit(event) {
72-
event.preventDefault();
72+
event.preventDefault()
7373

74-
var email = findDOMNode(this.refs.email).value;
75-
var pass = findDOMNode(this.refs.pass).value;
74+
var email = findDOMNode(this.refs.email).value
75+
var pass = findDOMNode(this.refs.pass).value
7676

7777
auth.login(email, pass, (loggedIn) => {
7878
if (!loggedIn)
79-
return this.setState({ error: true });
79+
return this.setState({ error: true })
8080

81-
var { location } = this.props;
81+
var { location } = this.props
8282

8383
if (location.state && location.state.nextPathname) {
84-
this.history.replaceState(null, location.state.nextPathname);
84+
this.history.replaceState(null, location.state.nextPathname)
8585
} else {
86-
this.history.replaceState(null, '/about');
86+
this.history.replaceState(null, '/about')
8787
}
88-
});
88+
})
8989
},
9090

9191
render() {
@@ -98,29 +98,29 @@ var Login = React.createClass({
9898
<p>Bad login information</p>
9999
)}
100100
</form>
101-
);
101+
)
102102
}
103-
});
103+
})
104104

105105
var About = React.createClass({
106106
render() {
107-
return <h1>About</h1>;
107+
return <h1>About</h1>
108108
}
109-
});
109+
})
110110

111111
var Logout = React.createClass({
112112
componentDidMount() {
113-
auth.logout();
113+
auth.logout()
114114
},
115115

116116
render() {
117-
return <p>You are now logged out</p>;
117+
return <p>You are now logged out</p>
118118
}
119-
});
119+
})
120120

121121
function requireAuth(nextState, replaceState) {
122122
if (!auth.loggedIn())
123-
replaceState({ nextPathname: nextState.location.pathname }, '/login');
123+
replaceState({ nextPathname: nextState.location.pathname }, '/login')
124124
}
125125

126126
React.render((
@@ -132,4 +132,4 @@ React.render((
132132
<Route path="dashboard" component={Dashboard} onEnter={requireAuth} />
133133
</Route>
134134
</Router>
135-
), document.getElementById('example'));
135+
), document.getElementById('example'))

examples/auth-flow/auth.js

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,49 @@
11
module.exports = {
2-
login (email, pass, cb) {
3-
cb = arguments[arguments.length - 1];
2+
login(email, pass, cb) {
3+
cb = arguments[arguments.length - 1]
44
if (localStorage.token) {
5-
if (cb) cb(true);
6-
this.onChange(true);
7-
return;
5+
if (cb) cb(true)
6+
this.onChange(true)
7+
return
88
}
99
pretendRequest(email, pass, (res) => {
1010
if (res.authenticated) {
11-
localStorage.token = res.token;
12-
if (cb) cb(true);
13-
this.onChange(true);
11+
localStorage.token = res.token
12+
if (cb) cb(true)
13+
this.onChange(true)
1414
} else {
15-
if (cb) cb(false);
16-
this.onChange(false);
15+
if (cb) cb(false)
16+
this.onChange(false)
1717
}
18-
});
18+
})
1919
},
2020

21-
getToken: function () {
22-
return localStorage.token;
21+
getToken() {
22+
return localStorage.token
2323
},
2424

25-
logout: function (cb) {
26-
delete localStorage.token;
27-
if (cb) cb();
28-
this.onChange(false);
25+
logout(cb) {
26+
delete localStorage.token
27+
if (cb) cb()
28+
this.onChange(false)
2929
},
3030

31-
loggedIn: function () {
32-
return !!localStorage.token;
31+
loggedIn() {
32+
return !!localStorage.token
3333
},
3434

35-
onChange: function () {}
36-
};
35+
onChange() {}
36+
}
3737

3838
function pretendRequest(email, pass, cb) {
3939
setTimeout(() => {
4040
if (email === '[email protected]' && pass === 'password1') {
4141
cb({
4242
authenticated: true,
4343
token: Math.random().toString(36).substring(7)
44-
});
44+
})
4545
} else {
46-
cb({authenticated: false});
46+
cb({ authenticated: false })
4747
}
48-
}, 0);
48+
}, 0)
4949
}
50-
51-

examples/huge-apps/app.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/*eslint-disable no-unused-vars */
12
import React from 'react'
23
import { createHistory, useBasename } from 'history'
34
import { Router } from 'react-router'
@@ -9,17 +10,17 @@ const history = useBasename(createHistory)({
910

1011
const rootRoute = {
1112
component: 'div',
12-
childRoutes: [{
13+
childRoutes: [ {
1314
path: '/',
1415
component: require('./components/App'),
1516
childRoutes: [
1617
require('./routes/Calendar'),
1718
require('./routes/Course'),
1819
require('./routes/Grades'),
1920
require('./routes/Messages'),
20-
require('./routes/Profile'),
21+
require('./routes/Profile')
2122
]
22-
}]
23+
} ]
2324
}
2425

2526
React.render(
Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
1-
import React from 'react';
2-
import Dashboard from './Dashboard';
3-
import GlobalNav from './GlobalNav';
1+
/*globals COURSES:true */
2+
import React from 'react'
3+
import Dashboard from './Dashboard'
4+
import GlobalNav from './GlobalNav'
45

56
class App extends React.Component {
67
render() {
7-
var courses = COURSES;
8-
98
return (
109
<div>
1110
<GlobalNav />
1211
<div style={{ padding: 20 }}>
13-
{this.props.children || <Dashboard courses={courses} />}
12+
{this.props.children || <Dashboard courses={COURSES} />}
1413
</div>
1514
</div>
16-
);
15+
)
1716
}
1817
}
1918

20-
export default App;
19+
export default App
Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
1-
import React from 'react';
2-
import { Link } from 'react-router';
1+
import React from 'react'
2+
import { Link } from 'react-router'
33

44
class Dashboard extends React.Component {
5-
render () {
6-
let { courses } = this.props;
5+
render() {
6+
const { courses } = this.props
77

88
return (
99
<div>
1010
<h2>Super Scalable Apps</h2>
11-
1211
<p>
1312
Open the network tab as you navigate. Notice that only the amount of
1413
your app that is required is actually downloaded as you navigate
1514
around. Even the route configuration objects are loaded on the fly.
1615
This way, a new route added deep in your app will not affect the
1716
initial bundle of your application.
1817
</p>
19-
2018
<h2>Courses</h2>{' '}
2119
<ul>
2220
{courses.map(course => (
@@ -26,8 +24,8 @@ class Dashboard extends React.Component {
2624
))}
2725
</ul>
2826
</div>
29-
);
27+
)
3028
}
3129
}
3230

33-
export default Dashboard;
31+
export default Dashboard

examples/huge-apps/components/GlobalNav.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@ class GlobalNav extends React.Component {
4646
var { user } = this.props
4747
return (
4848
<div style={styles.wrapper}>
49-
<div style={{float: 'left'}}>
49+
<div style={{ float: 'left' }}>
5050
<Link to="/" style={styles.link}>Home</Link>{' '}
5151
<Link to="/calendar" style={styles.link} activeStyle={styles.activeLink}>Calendar</Link>{' '}
5252
<Link to="/grades" style={styles.link} activeStyle={styles.activeLink}>Grades</Link>{' '}
5353
<Link to="/messages" style={styles.link} activeStyle={styles.activeLink}>Messages</Link>{' '}
5454
</div>
55-
<div style={{float: 'right'}}>
55+
<div style={{ float: 'right' }}>
5656
<Link style={styles.link} to="/profile">{user.name}</Link> <button onClick={this.logOut}>log out</button>
5757
</div>
5858
</div>
Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import React from 'react';
1+
import React from 'react'
22

33
class Calendar extends React.Component {
4+
render() {
5+
const events = [
6+
{ id: 0, title: 'essay due' }
7+
]
48

5-
render () {
6-
var events = [{
7-
id: 0, title: 'essay due'
8-
}];
99
return (
1010
<div>
1111
<h2>Calendar</h2>
@@ -15,10 +15,8 @@ class Calendar extends React.Component {
1515
))}
1616
</ul>
1717
</div>
18-
);
18+
)
1919
}
20-
2120
}
2221

23-
export default Calendar;
24-
22+
export default Calendar
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
module.exports = {
22
path: 'calendar',
3-
4-
getComponent (location, cb) {
3+
getComponent(location, cb) {
54
require.ensure([], (require) => {
65
cb(null, require('./components/Calendar'))
76
})
87
}
98
}
10-

0 commit comments

Comments
 (0)