Skip to content
This repository has been archived by the owner on Mar 22, 2020. It is now read-only.

Commit

Permalink
FIX: Lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
flexdinesh committed Feb 3, 2019
1 parent 55fad53 commit 1fcb9db
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 62 deletions.
3 changes: 2 additions & 1 deletion .eslintrc
Expand Up @@ -56,7 +56,8 @@
"react/self-closing-comp": 0,
"redux-saga/no-yield-in-race": 2,
"redux-saga/yield-effects": 2,
"jsx-a11y/anchor-is-valid": 0
"jsx-a11y/anchor-is-valid": 0,
"react/jsx-one-expression-per-line": 0
},
"settings": {
"import/resolver": {
Expand Down
8 changes: 4 additions & 4 deletions app/components/List/List.js
Expand Up @@ -2,13 +2,13 @@ import React from 'react';
import PropTypes from 'prop-types';
import './style.scss';

const List = (props) => {
const ComponentToRender = props.component;
const List = ({ component, items }) => {
const ComponentToRender = component;
let content = (<div></div>);

// If we have items, render them
if (props.items) {
content = props.items.map((item) => (
if (items) {
content = items.map((item) => (
<ComponentToRender key={`item-${item.id}`} item={item} />
));
} else {
Expand Down
4 changes: 2 additions & 2 deletions app/components/ListItem/ListItem.js
Expand Up @@ -2,9 +2,9 @@ import React from 'react';
import PropTypes from 'prop-types';
import './style.scss';

const ListItem = (props) => (
const ListItem = ({ item }) => (
<div className="list-item-wrapper">
<li className="list-item">{props.item}</li>
<li className="list-item">{item}</li>
</div>
);

Expand Down
32 changes: 10 additions & 22 deletions app/configureStore.js
Expand Up @@ -14,34 +14,22 @@ export default function configureStore(initialState = {}, history) {
// Create the store with two middlewares
// 1. sagaMiddleware: Makes redux-sagas work
// 2. routerMiddleware: Syncs the location/URL path to the state
const middlewares = [
sagaMiddleware,
routerMiddleware(history),
];
const middlewares = [sagaMiddleware, routerMiddleware(history)];

const enhancers = [
applyMiddleware(...middlewares),
];
const enhancers = [applyMiddleware(...middlewares)];

// If Redux DevTools Extension is installed use it, otherwise use Redux compose
/* eslint-disable no-underscore-dangle */
const composeEnhancers =
process.env.NODE_ENV !== 'production' &&
typeof window === 'object' &&
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({
// TODO Try to remove when `react-router-redux` is out of beta, LOCATION_CHANGE should not be fired more than once after hot reloading
// Prevent recomputing reducers for `replaceReducer`
shouldHotReload: false,
})
: compose;
const composeEnhancers = process.env.NODE_ENV !== 'production' && typeof window === 'object' && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({
// TODO Try to remove when `react-router-redux` is out of beta, LOCATION_CHANGE should not be fired more than once after hot reloading
// Prevent recomputing reducers for `replaceReducer`
shouldHotReload: false
})
: compose;
/* eslint-enable */

const store = createStore(
createReducer(),
fromJS(initialState),
composeEnhancers(...enhancers)
);
const store = createStore(createReducer(), fromJS(initialState), composeEnhancers(...enhancers));

// Extensions
store.runSaga = sagaMiddleware.run;
Expand Down
35 changes: 17 additions & 18 deletions app/containers/HomePage/HomePage.js
Expand Up @@ -15,17 +15,20 @@ export default class HomePage extends React.PureComponent { // eslint-disable-li
* when initial state username is not null, submit the form to load repos
*/
componentDidMount() {
if (this.props.username && this.props.username.trim().length > 0) {
this.props.onSubmitForm();
const { username, onSubmitForm } = this.props;
if (username && username.trim().length > 0) {
onSubmitForm();
}
}

render() {
const { loading, error, repos } = this.props;
const {
loading, error, repos, username, onChangeUsername, onSubmitForm
} = this.props;
const reposListProps = {
loading,
error,
repos,
repos
};

return (
Expand All @@ -37,20 +40,22 @@ export default class HomePage extends React.PureComponent { // eslint-disable-li
<div className="home-page">
<section className="centered">
<h2>Start your next react project in seconds</h2>
<p>A minimal <i>React-Redux</i> boilerplate with all the best practices</p>
<p>
A minimal <i>React-Redux</i> boilerplate with all the best practices
</p>
</section>
<section>
<h2>Try me!</h2>
<form onSubmit={this.props.onSubmitForm}>
<form onSubmit={onSubmitForm}>
<label htmlFor="username">
Show Github repositories by
Show Github repositories by
<span className="at-prefix">@</span>
<input
id="username"
type="text"
placeholder="flexdinesh"
value={this.props.username}
onChange={this.props.onChangeUsername}
value={username}
onChange={onChangeUsername}
/>
</label>
</form>
Expand All @@ -64,15 +69,9 @@ export default class HomePage extends React.PureComponent { // eslint-disable-li

HomePage.propTypes = {
loading: PropTypes.bool,
error: PropTypes.oneOfType([
PropTypes.object,
PropTypes.bool,
]),
repos: PropTypes.oneOfType([
PropTypes.array,
PropTypes.bool,
]),
error: PropTypes.oneOfType([PropTypes.object, PropTypes.bool]),
repos: PropTypes.oneOfType([PropTypes.array, PropTypes.bool]),
onSubmitForm: PropTypes.func,
username: PropTypes.string,
onChangeUsername: PropTypes.func,
onChangeUsername: PropTypes.func
};
4 changes: 3 additions & 1 deletion app/containers/HomePage/saga.js
Expand Up @@ -2,7 +2,9 @@
* Gets the repositories of the user from Github
*/

import { call, put, select, takeLatest } from 'redux-saga/effects';
import {
call, put, select, takeLatest
} from 'redux-saga/effects';
import { LOAD_REPOS } from 'containers/App/constants';
import { reposLoaded, repoLoadingError } from 'containers/App/actions';

Expand Down
4 changes: 2 additions & 2 deletions app/containers/RepoListItem/RepoListItem.js
Expand Up @@ -12,12 +12,12 @@ import './style.scss';

export default class RepoListItem extends React.PureComponent { // eslint-disable-line react/prefer-stateless-function
render() {
const { item } = this.props;
const { item, currentUser } = this.props;
let nameprefix = '';

// If the repository is owned by a different person than we got the data for
// it's a fork and we should show the name of the owner
if (item.owner.login !== this.props.currentUser) {
if (item.owner.login !== currentUser) {
nameprefix = `${item.owner.login}/`;
}

Expand Down
11 changes: 6 additions & 5 deletions app/utils/injectReducer.js
Expand Up @@ -14,19 +14,20 @@ import getInjectors from './reducerInjectors';
export default ({ key, reducer }) => (WrappedComponent) => {
class ReducerInjector extends React.Component {
static WrappedComponent = WrappedComponent;
static displayName = `withReducer(${(WrappedComponent.displayName || WrappedComponent.name || 'Component')})`;

static displayName = `withReducer(${WrappedComponent.displayName || WrappedComponent.name || 'Component'})`;

static contextTypes = {
store: PropTypes.object.isRequired,
store: PropTypes.object.isRequired
};

injectors = getInjectors(this.context.store); // eslint-disable-line react/destructuring-assignment

componentWillMount() {
const { injectReducer } = this.injectors;

injectReducer(key, reducer);
}

injectors = getInjectors(this.context.store);

render() {
return <WrappedComponent {...this.props} />;
}
Expand Down
12 changes: 6 additions & 6 deletions app/utils/injectSaga.js
Expand Up @@ -18,25 +18,25 @@ import getInjectors from './sagaInjectors';
export default ({ key, saga, mode }) => (WrappedComponent) => {
class InjectSaga extends React.Component {
static WrappedComponent = WrappedComponent;
static displayName = `withSaga(${(WrappedComponent.displayName || WrappedComponent.name || 'Component')})`;

static displayName = `withSaga(${WrappedComponent.displayName || WrappedComponent.name || 'Component'})`;

static contextTypes = {
store: PropTypes.object.isRequired,
store: PropTypes.object.isRequired
};

injectors = getInjectors(this.context.store); // eslint-disable-line react/destructuring-assignment

componentWillMount() {
const { injectSaga } = this.injectors;

injectSaga(key, { saga, mode }, this.props);
}

componentWillUnmount() {
const { ejectSaga } = this.injectors;

ejectSaga(key);
}

injectors = getInjectors(this.context.store);

render() {
return <WrappedComponent {...this.props} />;
}
Expand Down
2 changes: 1 addition & 1 deletion server/index.js
@@ -1,12 +1,12 @@
/* eslint consistent-return:0 */

const express = require('express');
const { resolve } = require('path');
const logger = require('./util//logger');

const argv = require('./util/argv');
const port = require('./util//port');
const setup = require('./middlewares/frontendMiddleware');
const { resolve } = require('path');

const app = express();

Expand Down

0 comments on commit 1fcb9db

Please sign in to comment.