Skip to content

Commit 5c997b6

Browse files
committed
Merge pull request reduxjs#618 from mikekidder/fix.eslint.updates
updates for eslint cleanup
2 parents f6a2593 + c99b70d commit 5c997b6

File tree

18 files changed

+66
-99
lines changed

18 files changed

+66
-99
lines changed

.eslintignore

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
lib
2-
node_modules
3-
examples/todomvc/node_modules
4-
examples/todomvc/server.js
5-
examples/todomvc/webpack.config.js
6-
examples/counter/node_modules
7-
examples/counter/server.js
8-
examples/counter/webpack.config.js
1+
lib/*
2+
**/dist/*
3+
**/node_modules/*
4+
**/server.js
5+
**/webpack.config*.js

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ language: node_js
22
node_js:
33
- "iojs-2"
44
script:
5+
- npm run lint
56
- npm test
67
- npm run build:examples
78
- npm run test:examples

examples/async/actions/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,18 @@ function fetchPosts(reddit) {
4141
return fetch(`http://www.reddit.com/r/${reddit}.json`)
4242
.then(response => response.json())
4343
.then(json => dispatch(receivePosts(reddit, json)));
44-
}
44+
};
4545
}
4646

4747
function shouldFetchPosts(state, reddit) {
4848
const posts = state.postsByReddit[reddit];
4949
if (!posts) {
5050
return true;
51-
} else if (posts.isFetching) {
51+
}
52+
if (posts.isFetching) {
5253
return false;
53-
} else {
54-
return posts.didInvalidate;
5554
}
55+
return posts.didInvalidate;
5656
}
5757

5858
export function fetchPostsIfNeeded(reddit) {

examples/async/components/Picker.js

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

33
export default class Picker extends Component {
4-
render () {
4+
render() {
55
const { value, onChange, options } = this.props;
66

77
return (
@@ -26,4 +26,4 @@ Picker.propTypes = {
2626
).isRequired,
2727
value: PropTypes.string.isRequired,
2828
onChange: PropTypes.func.isRequired
29-
};
29+
};

examples/async/components/Posts.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { PropTypes, Component } from 'react';
22

33
export default class Posts extends Component {
4-
render () {
4+
render() {
55
return (
66
<ul>
77
{this.props.posts.map((post, i) =>

examples/async/containers/AsyncApp.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class AsyncApp extends Component {
3535
dispatch(fetchPostsIfNeeded(selectedReddit));
3636
}
3737

38-
render () {
38+
render() {
3939
const { selectedReddit, posts, isFetching, lastUpdated } = this.props;
4040
return (
4141
<div>

examples/async/reducers/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,4 @@ const rootReducer = combineReducers({
5858
selectedReddit
5959
});
6060

61-
export default rootReducer;
61+
export default rootReducer;

examples/counter/containers/CounterApp.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import * as CounterActions from '../actions/counter';
66
function mapStateToProps(state) {
77
return {
88
counter: state.counter
9-
}
9+
};
1010
}
1111

1212
function mapDispatchToProps(dispatch) {

examples/counter/reducers/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ const rootReducer = combineReducers({
55
counter
66
});
77

8-
export default rootReducer;
8+
export default rootReducer;

examples/real-world/actions/index.js

Lines changed: 28 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@ import { CALL_API, Schemas } from '../middleware/api';
33
export const USER_REQUEST = 'USER_REQUEST';
44
export const USER_SUCCESS = 'USER_SUCCESS';
55
export const USER_FAILURE = 'USER_FAILURE';
6-
/**
7-
* Fetches a single user from Github API.
8-
* Relies on the custom API middleware defined in ../middleware/api.js.
9-
*/
6+
7+
// Fetches a single user from Github API.
8+
// Relies on the custom API middleware defined in ../middleware/api.js.
109
function fetchUser(login) {
1110
return {
1211
[CALL_API]: {
@@ -16,10 +15,9 @@ function fetchUser(login) {
1615
}
1716
};
1817
}
19-
/**
20-
* Fetches a single user from Github API unless it is cached.
21-
* Relies on Redux Thunk middleware.
22-
*/
18+
19+
// Fetches a single user from Github API unless it is cached.
20+
// Relies on Redux Thunk middleware.
2321
export function loadUser(login, requiredFields = []) {
2422
return (dispatch, getState) => {
2523
const user = getState().entities.users[login];
@@ -34,10 +32,9 @@ export function loadUser(login, requiredFields = []) {
3432
export const REPO_REQUEST = 'REPO_REQUEST';
3533
export const REPO_SUCCESS = 'REPO_SUCCESS';
3634
export const REPO_FAILURE = 'REPO_FAILURE';
37-
/**
38-
* Fetches a single repository from Github API.
39-
* Relies on the custom API middleware defined in ../middleware/api.js.
40-
*/
35+
36+
// Fetches a single repository from Github API.
37+
// Relies on the custom API middleware defined in ../middleware/api.js.
4138
function fetchRepo(fullName) {
4239
return {
4340
[CALL_API]: {
@@ -47,10 +44,9 @@ function fetchRepo(fullName) {
4744
}
4845
};
4946
}
50-
/**
51-
* Fetches a single repository from Github API unless it is cached.
52-
* Relies on Redux Thunk middleware.
53-
*/
47+
48+
// Fetches a single repository from Github API unless it is cached.
49+
// Relies on Redux Thunk middleware.
5450
export function loadRepo(fullName, requiredFields = []) {
5551
return (dispatch, getState) => {
5652
const repo = getState().entities.repos[fullName];
@@ -65,10 +61,9 @@ export function loadRepo(fullName, requiredFields = []) {
6561
export const STARRED_REQUEST = 'STARRED_REQUEST';
6662
export const STARRED_SUCCESS = 'STARRED_SUCCESS';
6763
export const STARRED_FAILURE = 'STARRED_FAILURE';
68-
/**
69-
* Fetches a page of starred repos by a particular user.
70-
* Relies on the custom API middleware defined in ../middleware/api.js.
71-
*/
64+
65+
// Fetches a page of starred repos by a particular user.
66+
// Relies on the custom API middleware defined in ../middleware/api.js.
7267
function fetchStarred(login, nextPageUrl) {
7368
return {
7469
login,
@@ -79,11 +74,10 @@ function fetchStarred(login, nextPageUrl) {
7974
}
8075
};
8176
}
82-
/**
83-
* Fetches a page of starred repos by a particular user.
84-
* Bails out if page is cached and user didn’t specifically request next page.
85-
* Relies on Redux Thunk middleware.
86-
*/
77+
78+
// Fetches a page of starred repos by a particular user.
79+
// Bails out if page is cached and user didn’t specifically request next page.
80+
// Relies on Redux Thunk middleware.
8781
export function loadStarred(login, nextPage) {
8882
return (dispatch, getState) => {
8983
const {
@@ -99,14 +93,12 @@ export function loadStarred(login, nextPage) {
9993
};
10094
}
10195

102-
10396
export const STARGAZERS_REQUEST = 'STARGAZERS_REQUEST';
10497
export const STARGAZERS_SUCCESS = 'STARGAZERS_SUCCESS';
10598
export const STARGAZERS_FAILURE = 'STARGAZERS_FAILURE';
106-
/**
107-
* Fetches a page of stargazers for a particular repo.
108-
* Relies on the custom API middleware defined in ../middleware/api.js.
109-
*/
99+
100+
// Fetches a page of stargazers for a particular repo.
101+
// Relies on the custom API middleware defined in ../middleware/api.js.
110102
function fetchStargazers(fullName, nextPageUrl) {
111103
return {
112104
fullName,
@@ -117,11 +109,10 @@ function fetchStargazers(fullName, nextPageUrl) {
117109
}
118110
};
119111
}
120-
/**
121-
* Fetches a page of stargazers for a particular repo.
122-
* Bails out if page is cached and user didn’t specifically request next page.
123-
* Relies on Redux Thunk middleware.
124-
*/
112+
113+
// Fetches a page of stargazers for a particular repo.
114+
// Bails out if page is cached and user didn’t specifically request next page.
115+
// Relies on Redux Thunk middleware.
125116
export function loadStargazers(fullName, nextPage) {
126117
return (dispatch, getState) => {
127118
const {
@@ -138,9 +129,8 @@ export function loadStargazers(fullName, nextPage) {
138129
}
139130

140131
export const RESET_ERROR_MESSAGE = 'RESET_ERROR_MESSAGE';
141-
/**
142-
* Resets the currently visible error message.
143-
*/
132+
133+
// Resets the currently visible error message.
144134
export function resetErrorMessage() {
145135
return {
146136
type: RESET_ERROR_MESSAGE

examples/real-world/components/Explore.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export default class Explore extends Component {
5151
}
5252

5353
handleGoClick() {
54-
this.props.onChange(this.getInputValue())
54+
this.props.onChange(this.getInputValue());
5555
}
5656
}
5757

examples/real-world/middleware/api.js

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ import { Schema, arrayOf, normalize } from 'normalizr';
22
import { camelizeKeys } from 'humps';
33
import 'isomorphic-fetch';
44

5-
/**
6-
* Extracts the next page URL from Github API response.
7-
*/
5+
// Extracts the next page URL from Github API response.
86
function getNextPageUrl(response) {
97
const link = response.headers.get('link');
108
if (!link) {
@@ -21,16 +19,12 @@ function getNextPageUrl(response) {
2119

2220
const API_ROOT = 'https://api.github.com/';
2321

24-
/**
25-
* Fetches an API response and normalizes the result JSON according to schema.
26-
* This makes every API response have the same shape, regardless of how nested it was.
27-
*/
22+
// Fetches an API response and normalizes the result JSON according to schema.
23+
// This makes every API response have the same shape, regardless of how nested it was.
2824
function callApi(endpoint, schema) {
29-
if (endpoint.indexOf(API_ROOT) === -1) {
30-
endpoint = API_ROOT + endpoint;
31-
}
25+
const fullUrl = (endpoint.indexOf(API_ROOT) === -1) ? API_ROOT + endpoint : endpoint;
3226

33-
return fetch(endpoint)
27+
return fetch(fullUrl)
3428
.then(response =>
3529
response.json().then(json => ({ json, response }))
3630
).then(({ json, response }) => {
@@ -68,25 +62,19 @@ repoSchema.define({
6862
owner: userSchema
6963
});
7064

71-
/**
72-
* Schemas for Github API responses.
73-
*/
65+
// Schemas for Github API responses.
7466
export const Schemas = {
7567
USER: userSchema,
7668
USER_ARRAY: arrayOf(userSchema),
7769
REPO: repoSchema,
7870
REPO_ARRAY: arrayOf(repoSchema)
7971
};
8072

81-
/**
82-
* Action key that carries API call info interpreted by this Redux middleware.
83-
*/
73+
// Action key that carries API call info interpreted by this Redux middleware.
8474
export const CALL_API = Symbol('Call API');
8575

86-
/**
87-
* A Redux middleware that interprets actions with CALL_API info specified.
88-
* Performs the call and promises when such actions are dispatched.
89-
*/
76+
// A Redux middleware that interprets actions with CALL_API info specified.
77+
// Performs the call and promises when such actions are dispatched.
9078
export default store => next => action => {
9179
const callAPI = action[CALL_API];
9280
if (typeof callAPI === 'undefined') {

examples/real-world/reducers/index.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ import merge from 'lodash/object/merge';
33
import paginate from './paginate';
44
import { combineReducers } from 'redux';
55

6-
/**
7-
* Updates an entity cache in response to any action with response.entities.
8-
*/
6+
// Updates an entity cache in response to any action with response.entities.
97
export function entities(state = { users: {}, repos: {} }, action) {
108
if (action.response && action.response.entities) {
119
return merge({}, state, action.response.entities);
@@ -14,9 +12,7 @@ export function entities(state = { users: {}, repos: {} }, action) {
1412
return state;
1513
}
1614

17-
/**
18-
* Updates error message to notify about the failed fetches.
19-
*/
15+
// Updates error message to notify about the failed fetches.
2016
export function errorMessage(state = null, action) {
2117
const { type, error } = action;
2218

@@ -29,9 +25,7 @@ export function errorMessage(state = null, action) {
2925
return state;
3026
}
3127

32-
/**
33-
* Updates the pagination data for different actions.
34-
*/
28+
// Updates the pagination data for different actions.
3529
export const pagination = combineReducers({
3630
starredByUser: paginate({
3731
mapActionToKey: action => action.login,

examples/real-world/reducers/paginate.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import merge from 'lodash/object/merge';
22
import union from 'lodash/array/union';
33

4-
/**
5-
* Creates a reducer managing pagination, given the action types to handle,
6-
* and a function telling how to extract the key from an action.
7-
*/
4+
// Creates a reducer managing pagination, given the action types to handle,
5+
// and a function telling how to extract the key from an action.
86
export default function paginate({ types, mapActionToKey }) {
97
if (!Array.isArray(types) || types.length !== 3) {
108
throw new Error('Expected types to be an array of three elements.');

examples/real-world/store/configureStore.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ const createStoreWithMiddleware = applyMiddleware(
1111
loggerMiddleware
1212
)(createStore);
1313

14-
/**
15-
* Creates a preconfigured store for this example.
16-
*/
14+
// Creates a preconfigured store for this example.
1715
export default function configureStore(initialState) {
1816
return createStoreWithMiddleware(reducer, initialState);
1917
}

examples/todomvc/containers/Root.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { Component } from 'react';
22
import TodoApp from './TodoApp';
3-
import { createStore, combineReducers } from 'redux';
3+
import { createStore } from 'redux';
44
import { Provider } from 'react-redux';
55
import rootReducer from '../reducers';
66

src/utils/bindActionCreators.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export default function bindActionCreators(actionCreators, dispatch) {
3030
return bindActionCreator(actionCreators, dispatch);
3131
}
3232

33-
if (typeof actionCreators !== 'object' || actionCreators == null) {
33+
if (typeof actionCreators !== 'object' || actionCreators == null) { // eslint-disable-line no-eq-null
3434
throw new Error(
3535
`bindActionCreators expected an object or a function, instead received ${typeof actionCreators}. ` +
3636
`Did you write "import ActionCreators from" instead of "import * as ActionCreators from"?`
@@ -41,4 +41,3 @@ export default function bindActionCreators(actionCreators, dispatch) {
4141
bindActionCreator(actionCreator, dispatch)
4242
);
4343
}
44-

0 commit comments

Comments
 (0)