Skip to content

Commit 163e7fa

Browse files
committed
Merge pull request reduxjs#627 from mikekidder/eslint.npm.updates
latest eslint related packages; full linting for redux
2 parents 5c997b6 + 9e908ec commit 163e7fa

File tree

30 files changed

+233
-239
lines changed

30 files changed

+233
-239
lines changed

.eslintrc

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"extends": "eslint-config-airbnb",
2+
"extends": "airbnb",
33
"env": {
44
"browser": true,
55
"mocha": true,
@@ -16,10 +16,8 @@
1616
"no-var": 0,
1717
"vars-on-top": 0,
1818

19-
//Temporarirly disabled due to a possible bug in babel-eslint (todomvc example)
20-
"block-scoped-var": 0,
21-
// Temporarily disabled for test/* until babel/babel-eslint#33 is resolved
22-
"padded-blocks": 0
19+
// Disable comma-dangle unless need to support it
20+
"comma-dangle": 0
2321
},
2422
"plugins": [
2523
"react"

examples/async/containers/AsyncApp.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class AsyncApp extends Component {
5050
</span>
5151
}
5252
{!isFetching &&
53-
<a href='#'
53+
<a href="#"
5454
onClick={this.handleRefreshClick}>
5555
Refresh
5656
</a>

examples/buildAll.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,10 @@ var cmdArgs = [
1616
{ cmd: 'webpack', args: ['index.js'] }
1717
];
1818

19-
for (let dir of exampleDirs) {
20-
21-
for (let cmdArg of cmdArgs) {
19+
for (const dir of exampleDirs) {
20+
for (const cmdArg of cmdArgs) {
2221
// declare opts in this scope to avoid https://github.com/joyent/node/issues/9158
23-
let opts = {
22+
const opts = {
2423
cwd: path.join(__dirname, dir),
2524
stdio: 'inherit'
2625
};

examples/counter/test/actions/counter.spec.js

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import expect from 'expect';
22
import * as actions from '../../actions/counter';
33

44
describe('actions', () => {
5-
65
it('increment should create increment action', () => {
76
expect(actions.increment()).toEqual({ type: actions.INCREMENT_COUNTER });
87
});
@@ -12,32 +11,31 @@ describe('actions', () => {
1211
});
1312

1413
it('incrementIfOdd should create increment action', () => {
15-
let fn = actions.incrementIfOdd();
14+
const fn = actions.incrementIfOdd();
1615
expect(fn).toBeA('function');
17-
let dispatch = expect.createSpy();
18-
let getState = () => ({ counter: 1 });
16+
const dispatch = expect.createSpy();
17+
const getState = () => ({ counter: 1 });
1918
fn(dispatch, getState);
2019
expect(dispatch).toHaveBeenCalledWith({ type: actions.INCREMENT_COUNTER });
2120
});
2221

2322
it('incrementIfOdd shouldnt create increment action if counter is even', () => {
24-
let fn = actions.incrementIfOdd();
25-
let dispatch = expect.createSpy();
26-
let getState = () => ({ counter: 2 });
23+
const fn = actions.incrementIfOdd();
24+
const dispatch = expect.createSpy();
25+
const getState = () => ({ counter: 2 });
2726
fn(dispatch, getState);
2827
expect(dispatch.calls.length).toBe(0);
2928
});
3029

3130
// There's no nice way to test this at the moment...
3231
it('incrementAsync', (done) => {
33-
let fn = actions.incrementAsync(1);
32+
const fn = actions.incrementAsync(1);
3433
expect(fn).toBeA('function');
35-
let dispatch = expect.createSpy();
34+
const dispatch = expect.createSpy();
3635
fn(dispatch);
3736
setTimeout(() => {
3837
expect(dispatch).toHaveBeenCalledWith({ type: actions.INCREMENT_COUNTER });
3938
done();
4039
}, 5);
4140
});
4241
});
43-

examples/counter/test/containers/CounterApp.spec.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ describe('containers', () => {
2727
jsdomReact();
2828

2929
describe('App', () => {
30-
3130
it('should display initial count', () => {
3231
const { p } = setup();
3332
expect(p.textContent).toMatch(/^Clicked: 0 times/);

examples/counter/test/reducers/counter.spec.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { INCREMENT_COUNTER, DECREMENT_COUNTER } from '../../actions/counter';
44

55
describe('reducers', () => {
66
describe('counter', () => {
7-
87
it('should handle initial state', () => {
98
expect(counter(undefined, {})).toBe(0);
109
});

examples/real-world/components/Explore.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ export default class Explore extends Component {
99
this.handleGoClick = this.handleGoClick.bind(this);
1010
}
1111

12+
componentWillReceiveProps(nextProps) {
13+
if (nextProps.value !== this.props.value) {
14+
this.setInputValue(nextProps.value);
15+
}
16+
}
17+
1218
getInputValue() {
1319
return findDOMNode(this.refs.input).value;
1420
}
@@ -20,39 +26,33 @@ export default class Explore extends Component {
2026
findDOMNode(this.refs.input).value = val;
2127
}
2228

23-
componentWillReceiveProps(nextProps) {
24-
if (nextProps.value !== this.props.value) {
25-
this.setInputValue(nextProps.value);
29+
handleKeyUp(e) {
30+
if (e.keyCode === 13) {
31+
this.handleGoClick();
2632
}
2733
}
2834

35+
handleGoClick() {
36+
this.props.onChange(this.getInputValue());
37+
}
38+
2939
render() {
3040
return (
3141
<div>
3242
<p>Type a username or repo full name and hit 'Go':</p>
33-
<input size='45'
34-
ref='input'
43+
<input size="45"
44+
ref="input"
3545
defaultValue={this.props.value}
3646
onKeyUp={this.handleKeyUp} />
3747
<button onClick={this.handleGoClick}>
3848
Go!
3949
</button>
4050
<p>
41-
Code on <a href={GITHUB_REPO} target='_blank'>Github</a>.
51+
Code on <a href={GITHUB_REPO} target="_blank">Github</a>.
4252
</p>
4353
</div>
4454
);
4555
}
46-
47-
handleKeyUp(e) {
48-
if (e.keyCode === 13) {
49-
this.handleGoClick();
50-
}
51-
}
52-
53-
handleGoClick() {
54-
this.props.onChange(this.getInputValue());
55-
}
5656
}
5757

5858
Explore.propTypes = {

examples/real-world/components/List.js

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
import React, { Component, PropTypes } from 'react';
22

33
export default class List extends Component {
4+
renderLoadMore() {
5+
const { isFetching, onLoadMoreClick } = this.props;
6+
return (
7+
<button style={{ fontSize: '150%' }}
8+
onClick={onLoadMoreClick}
9+
disabled={isFetching}>
10+
{isFetching ? 'Loading...' : 'Load More'}
11+
</button>
12+
);
13+
}
14+
415
render() {
516
const {
617
isFetching, nextPageUrl, pageCount,
@@ -24,21 +35,13 @@ export default class List extends Component {
2435
</div>
2536
);
2637
}
27-
28-
renderLoadMore() {
29-
const { isFetching, onLoadMoreClick } = this.props;
30-
return (
31-
<button style={{ fontSize: '150%' }}
32-
onClick={onLoadMoreClick}
33-
disabled={isFetching}>
34-
{isFetching ? 'Loading...' : 'Load More'}
35-
</button>
36-
);
37-
}
3838
}
3939

4040
List.propTypes = {
4141
loadingLabel: PropTypes.string.isRequired,
42+
pageCount: PropTypes.number,
43+
renderItem: PropTypes.func.isRequired,
44+
items: PropTypes.array.isRequired,
4245
isFetching: PropTypes.bool.isRequired,
4346
onLoadMoreClick: PropTypes.func.isRequired,
4447
nextPageUrl: PropTypes.string

examples/real-world/components/Repo.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default class Repo extends Component {
99
const { name, description } = repo;
1010

1111
return (
12-
<div className='Repo'>
12+
<div className="Repo">
1313
<h3>
1414
<Link to={`/${login}/${name}`}>
1515
{name}

examples/real-world/components/User.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ export default class User extends Component {
66
const { login, avatarUrl, name } = this.props.user;
77

88
return (
9-
<div className='User'>
9+
<div className="User">
1010
<Link to={`/${login}`}>
11-
<img src={avatarUrl} width='72' height='72' />
11+
<img src={avatarUrl} width="72" height="72" />
1212
<h3>
1313
{login} {name && <span>({name})</span>}
1414
</h3>

examples/real-world/containers/App.js

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,15 @@ class App extends Component {
1010
this.handleDismissClick = this.handleDismissClick.bind(this);
1111
}
1212

13-
render() {
14-
// Injected by React Router
15-
const { location, children } = this.props;
16-
const { pathname } = location;
17-
const value = pathname.substring(1);
13+
handleDismissClick(e) {
14+
this.props.resetErrorMessage();
15+
e.preventDefault();
16+
}
1817

19-
return (
20-
<div>
21-
<Explore value={value}
22-
onChange={this.handleChange} />
23-
<hr />
24-
{this.renderErrorMessage()}
25-
{children}
26-
</div>
27-
);
18+
handleChange(nextValue) {
19+
// Available thanks to contextTypes below
20+
const { router } = this.context;
21+
router.transitionTo(`/${nextValue}`);
2822
}
2923

3024
renderErrorMessage() {
@@ -37,35 +31,43 @@ class App extends Component {
3731
<p style={{ backgroundColor: '#e99', padding: 10 }}>
3832
<b>{errorMessage}</b>
3933
{' '}
40-
(<a href='#'
34+
(<a href="#"
4135
onClick={this.handleDismissClick}>
4236
Dismiss
4337
</a>)
4438
</p>
4539
);
4640
}
4741

48-
handleDismissClick(e) {
49-
this.props.resetErrorMessage();
50-
e.preventDefault();
51-
}
42+
render() {
43+
// Injected by React Router
44+
const { location, children } = this.props;
45+
const { pathname } = location;
46+
const value = pathname.substring(1);
5247

53-
handleChange(nextValue) {
54-
// Available thanks to contextTypes below
55-
const { router } = this.context;
56-
router.transitionTo(`/${nextValue}`);
48+
return (
49+
<div>
50+
<Explore value={value}
51+
onChange={this.handleChange} />
52+
<hr />
53+
{this.renderErrorMessage()}
54+
{children}
55+
</div>
56+
);
5757
}
5858
}
5959

6060
App.propTypes = {
6161
errorMessage: PropTypes.string,
62+
resetErrorMessage: PropTypes.func.isRequired,
6263
location: PropTypes.shape({
6364
pathname: PropTypes.string.isRequired
6465
}),
6566
params: PropTypes.shape({
6667
userLogin: PropTypes.string,
6768
repoName: PropTypes.string
68-
}).isRequired
69+
}).isRequired,
70+
children: PropTypes.node
6971
};
7072

7173
App.contextTypes = {

examples/real-world/containers/RepoPage.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,17 @@ class RepoPage extends Component {
2828
}
2929
}
3030

31+
handleLoadMoreClick() {
32+
this.props.loadStargazers(this.props.fullName, true);
33+
}
34+
35+
renderUser(user) {
36+
return (
37+
<User user={user}
38+
key={user.login} />
39+
);
40+
}
41+
3142
render() {
3243
const { repo, owner, name } = this.props;
3344
if (!repo || !owner) {
@@ -48,23 +59,13 @@ class RepoPage extends Component {
4859
</div>
4960
);
5061
}
51-
52-
renderUser(user) {
53-
return (
54-
<User user={user}
55-
key={user.login} />
56-
);
57-
}
58-
59-
handleLoadMoreClick() {
60-
this.props.loadStargazers(this.props.fullName, true);
61-
}
6262
}
6363

6464
RepoPage.propTypes = {
6565
repo: PropTypes.object,
6666
fullName: PropTypes.string.isRequired,
6767
name: PropTypes.string.isRequired,
68+
owner: PropTypes.string.isRequired,
6869
stargazers: PropTypes.array.isRequired,
6970
stargazersPagination: PropTypes.object,
7071
loadRepo: PropTypes.func.isRequired,

examples/real-world/containers/Root.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { Component } from 'react';
1+
import React, { Component, PropTypes } from 'react';
22
import { Provider } from 'react-redux';
33
import { Router, Route } from 'react-router';
44
import configureStore from '../store/configureStore';
@@ -15,10 +15,10 @@ export default class Root extends Component {
1515
<Provider store={store}>
1616
{() =>
1717
<Router history={this.props.history}>
18-
<Route path='/' component={App}>
19-
<Route path='/:login/:name'
18+
<Route path="/" component={App}>
19+
<Route path="/:login/:name"
2020
component={RepoPage} />
21-
<Route path='/:login'
21+
<Route path="/:login"
2222
component={UserPage} />
2323
</Route>
2424
</Router>
@@ -28,3 +28,7 @@ export default class Root extends Component {
2828
);
2929
}
3030
}
31+
32+
Root.propTypes = {
33+
history: PropTypes.object.isRequired,
34+
};

0 commit comments

Comments
 (0)