Skip to content

Commit

Permalink
Fix lint errors for examples/real-world/
Browse files Browse the repository at this point in the history
  • Loading branch information
ellbee committed Oct 27, 2015
1 parent deafee9 commit 095688e
Show file tree
Hide file tree
Showing 22 changed files with 320 additions and 320 deletions.
78 changes: 39 additions & 39 deletions examples/real-world/actions/index.js
Original file line number Diff line number Diff line change
@@ -1,78 +1,78 @@
import { CALL_API, Schemas } from '../middleware/api';
import { CALL_API, Schemas } from '../middleware/api'

export const USER_REQUEST = 'USER_REQUEST';
export const USER_SUCCESS = 'USER_SUCCESS';
export const USER_FAILURE = 'USER_FAILURE';
export const USER_REQUEST = 'USER_REQUEST'
export const USER_SUCCESS = 'USER_SUCCESS'
export const USER_FAILURE = 'USER_FAILURE'

// Fetches a single user from Github API.
// Relies on the custom API middleware defined in ../middleware/api.js.
function fetchUser(login) {
return {
[CALL_API]: {
types: [USER_REQUEST, USER_SUCCESS, USER_FAILURE],
types: [ USER_REQUEST, USER_SUCCESS, USER_FAILURE ],
endpoint: `users/${login}`,
schema: Schemas.USER
}
};
}
}

// Fetches a single user from Github API unless it is cached.
// Relies on Redux Thunk middleware.
export function loadUser(login, requiredFields = []) {
return (dispatch, getState) => {
const user = getState().entities.users[login];
const user = getState().entities.users[login]
if (user && requiredFields.every(key => user.hasOwnProperty(key))) {
return null;
return null
}

return dispatch(fetchUser(login));
};
return dispatch(fetchUser(login))
}
}

export const REPO_REQUEST = 'REPO_REQUEST';
export const REPO_SUCCESS = 'REPO_SUCCESS';
export const REPO_FAILURE = 'REPO_FAILURE';
export const REPO_REQUEST = 'REPO_REQUEST'
export const REPO_SUCCESS = 'REPO_SUCCESS'
export const REPO_FAILURE = 'REPO_FAILURE'

// Fetches a single repository from Github API.
// Relies on the custom API middleware defined in ../middleware/api.js.
function fetchRepo(fullName) {
return {
[CALL_API]: {
types: [REPO_REQUEST, REPO_SUCCESS, REPO_FAILURE],
types: [ REPO_REQUEST, REPO_SUCCESS, REPO_FAILURE ],
endpoint: `repos/${fullName}`,
schema: Schemas.REPO
}
};
}
}

// Fetches a single repository from Github API unless it is cached.
// Relies on Redux Thunk middleware.
export function loadRepo(fullName, requiredFields = []) {
return (dispatch, getState) => {
const repo = getState().entities.repos[fullName];
const repo = getState().entities.repos[fullName]
if (repo && requiredFields.every(key => repo.hasOwnProperty(key))) {
return null;
return null
}

return dispatch(fetchRepo(fullName));
};
return dispatch(fetchRepo(fullName))
}
}

export const STARRED_REQUEST = 'STARRED_REQUEST';
export const STARRED_SUCCESS = 'STARRED_SUCCESS';
export const STARRED_FAILURE = 'STARRED_FAILURE';
export const STARRED_REQUEST = 'STARRED_REQUEST'
export const STARRED_SUCCESS = 'STARRED_SUCCESS'
export const STARRED_FAILURE = 'STARRED_FAILURE'

// Fetches a page of starred repos by a particular user.
// Relies on the custom API middleware defined in ../middleware/api.js.
function fetchStarred(login, nextPageUrl) {
return {
login,
[CALL_API]: {
types: [STARRED_REQUEST, STARRED_SUCCESS, STARRED_FAILURE],
types: [ STARRED_REQUEST, STARRED_SUCCESS, STARRED_FAILURE ],
endpoint: nextPageUrl,
schema: Schemas.REPO_ARRAY
}
};
}
}

// Fetches a page of starred repos by a particular user.
Expand All @@ -83,31 +83,31 @@ export function loadStarred(login, nextPage) {
const {
nextPageUrl = `users/${login}/starred`,
pageCount = 0
} = getState().pagination.starredByUser[login] || {};
} = getState().pagination.starredByUser[login] || {}

if (pageCount > 0 && !nextPage) {
return null;
return null
}

return dispatch(fetchStarred(login, nextPageUrl));
};
return dispatch(fetchStarred(login, nextPageUrl))
}
}

export const STARGAZERS_REQUEST = 'STARGAZERS_REQUEST';
export const STARGAZERS_SUCCESS = 'STARGAZERS_SUCCESS';
export const STARGAZERS_FAILURE = 'STARGAZERS_FAILURE';
export const STARGAZERS_REQUEST = 'STARGAZERS_REQUEST'
export const STARGAZERS_SUCCESS = 'STARGAZERS_SUCCESS'
export const STARGAZERS_FAILURE = 'STARGAZERS_FAILURE'

// Fetches a page of stargazers for a particular repo.
// Relies on the custom API middleware defined in ../middleware/api.js.
function fetchStargazers(fullName, nextPageUrl) {
return {
fullName,
[CALL_API]: {
types: [STARGAZERS_REQUEST, STARGAZERS_SUCCESS, STARGAZERS_FAILURE],
types: [ STARGAZERS_REQUEST, STARGAZERS_SUCCESS, STARGAZERS_FAILURE ],
endpoint: nextPageUrl,
schema: Schemas.USER_ARRAY
}
};
}
}

// Fetches a page of stargazers for a particular repo.
Expand All @@ -118,21 +118,21 @@ export function loadStargazers(fullName, nextPage) {
const {
nextPageUrl = `repos/${fullName}/stargazers`,
pageCount = 0
} = getState().pagination.stargazersByRepo[fullName] || {};
} = getState().pagination.stargazersByRepo[fullName] || {}

if (pageCount > 0 && !nextPage) {
return null;
return null
}

return dispatch(fetchStargazers(fullName, nextPageUrl));
};
return dispatch(fetchStargazers(fullName, nextPageUrl))
}
}

export const RESET_ERROR_MESSAGE = 'RESET_ERROR_MESSAGE';
export const RESET_ERROR_MESSAGE = 'RESET_ERROR_MESSAGE'

// Resets the currently visible error message.
export function resetErrorMessage() {
return {
type: RESET_ERROR_MESSAGE
};
}
}
24 changes: 12 additions & 12 deletions examples/real-world/components/Explore.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
import React, { Component, PropTypes } from 'react';
import React, { Component, PropTypes } from 'react'

const GITHUB_REPO = 'https://github.com/rackt/redux';
const GITHUB_REPO = 'https://github.com/rackt/redux'

export default class Explore extends Component {
constructor(props) {
super(props);
this.handleKeyUp = this.handleKeyUp.bind(this);
this.handleGoClick = this.handleGoClick.bind(this);
super(props)
this.handleKeyUp = this.handleKeyUp.bind(this)
this.handleGoClick = this.handleGoClick.bind(this)
}

componentWillReceiveProps(nextProps) {
if (nextProps.value !== this.props.value) {
this.setInputValue(nextProps.value);
this.setInputValue(nextProps.value)
}
}

getInputValue() {
return this.refs.input.value;
return this.refs.input.value
}

setInputValue(val) {
// Generally mutating DOM is a bad idea in React components,
// but doing this for a single uncontrolled field is less fuss
// than making it controlled and maintaining a state for it.
this.refs.input.value = val;
this.refs.input.value = val
}

handleKeyUp(e) {
if (e.keyCode === 13) {
this.handleGoClick();
this.handleGoClick()
}
}

handleGoClick() {
this.props.onChange(this.getInputValue());
this.props.onChange(this.getInputValue())
}

render() {
Expand All @@ -54,11 +54,11 @@ export default class Explore extends Component {
Move the DevTools with Ctrl+W or hide them with Ctrl+H.
</p>
</div>
);
)
}
}

Explore.propTypes = {
value: PropTypes.string.isRequired,
onChange: PropTypes.func.isRequired
};
}
22 changes: 11 additions & 11 deletions examples/real-world/components/List.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
import React, { Component, PropTypes } from 'react';
import React, { Component, PropTypes } from 'react'

export default class List extends Component {
renderLoadMore() {
const { isFetching, onLoadMoreClick } = this.props;
const { isFetching, onLoadMoreClick } = this.props
return (
<button style={{ fontSize: '150%' }}
onClick={onLoadMoreClick}
disabled={isFetching}>
{isFetching ? 'Loading...' : 'Load More'}
</button>
);
)
}

render() {
const {
isFetching, nextPageUrl, pageCount,
items, renderItem, loadingLabel
} = this.props;
} = this.props

const isEmpty = items.length === 0;
const isEmpty = items.length === 0
if (isEmpty && isFetching) {
return <h2><i>{loadingLabel}</i></h2>;
return <h2><i>{loadingLabel}</i></h2>
}

const isLastPage = !nextPageUrl;
const isLastPage = !nextPageUrl
if (isEmpty && isLastPage) {
return <h1><i>Nothing here!</i></h1>;
return <h1><i>Nothing here!</i></h1>
}

return (
<div>
{items.map(renderItem)}
{pageCount > 0 && !isLastPage && this.renderLoadMore()}
</div>
);
)
}
}

Expand All @@ -45,9 +45,9 @@ List.propTypes = {
isFetching: PropTypes.bool.isRequired,
onLoadMoreClick: PropTypes.func.isRequired,
nextPageUrl: PropTypes.string
};
}

List.defaultProps = {
isFetching: true,
loadingLabel: 'Loading...'
};
}
14 changes: 7 additions & 7 deletions examples/real-world/components/Repo.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React, { Component, PropTypes } from 'react';
import { Link } from 'react-router';
import React, { Component, PropTypes } from 'react'
import { Link } from 'react-router'

export default class Repo extends Component {

render() {
const { repo, owner } = this.props;
const { login } = owner;
const { name, description } = repo;
const { repo, owner } = this.props
const { login } = owner
const { name, description } = repo

return (
<div className="Repo">
Expand All @@ -23,7 +23,7 @@ export default class Repo extends Component {
<p>{description}</p>
}
</div>
);
)
}
}

Expand All @@ -35,4 +35,4 @@ Repo.propTypes = {
owner: PropTypes.shape({
login: PropTypes.string.isRequired
}).isRequired
};
}
10 changes: 5 additions & 5 deletions examples/real-world/components/User.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React, { Component, PropTypes } from 'react';
import { Link } from 'react-router';
import React, { Component, PropTypes } from 'react'
import { Link } from 'react-router'

export default class User extends Component {
render() {
const { login, avatarUrl, name } = this.props.user;
const { login, avatarUrl, name } = this.props.user

return (
<div className="User">
Expand All @@ -14,7 +14,7 @@ export default class User extends Component {
</h3>
</Link>
</div>
);
)
}
}

Expand All @@ -24,4 +24,4 @@ User.propTypes = {
avatarUrl: PropTypes.string.isRequired,
name: PropTypes.string
}).isRequired
};
}
Loading

0 comments on commit 095688e

Please sign in to comment.