Skip to content

Commit

Permalink
reformat stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Roy Yu committed May 3, 2019
1 parent 6dcd240 commit e3d78ba
Show file tree
Hide file tree
Showing 29 changed files with 274 additions and 275 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ webpack.config.prod.js
/dist
/dist-server
/config/webpack/dist
*.md
3 changes: 1 addition & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"__CONFIG__": true,
"__ENV__": true
},
"extends": ["airbnb", "plugin:prettier/recommended"],
"extends": ["airbnb"],
"plugins": ["flowtype", "react"],
"parser": "babel-eslint",
"parserOptions": {
Expand All @@ -19,7 +19,6 @@
},
// Rule changes from Airbnb's eslint config
"rules": {
"prettier/prettier": "error",
"import/no-unresolved": 0,
"new-cap": 0,
"semi": 0,
Expand Down
4 changes: 4 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"trailingComma": "es5",
"semi": false
}
4 changes: 2 additions & 2 deletions __fixtures__/store.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { createStore } from "redux";
import { createStore } from 'redux'

export const getStore = (obj = {}) => createStore((state) => state, obj);
export const getStore = (obj = {}) => createStore((state) => state, obj)
2 changes: 1 addition & 1 deletion __mocks__/fileMock.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = "test-file-stub";
module.exports = 'test-file-stub';
20 changes: 10 additions & 10 deletions src/js/Root.jsx
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
import React, { Component } from "react";
import PropTypes from "prop-types";
import { Provider } from "react-redux";
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import { Provider } from 'react-redux'
// You could use BrowserRoute or HashRoute
// But passing in history directly to Route will
// give your app more flexibility on deeper integration of `history`
import { Router } from "react-router-dom";
import { IntlProvider } from "react-intl";
import { Router } from 'react-router-dom'
import { IntlProvider } from 'react-intl'

export default class Root extends Component {
get content() {
const { routes, history } = this.props;
const { routes, history } = this.props

return <Router history={history}>{routes}</Router>;
return <Router history={history}>{routes}</Router>
}

render() {
const { store } = this.props;
const { store } = this.props

return (
<IntlProvider locale="en">
<Provider store={store}>{this.content}</Provider>
</IntlProvider>
);
)
}
}

Root.propTypes = {
history: PropTypes.object.isRequired,
routes: PropTypes.element.isRequired,
store: PropTypes.object.isRequired,
};
}
2 changes: 1 addition & 1 deletion src/js/app-history.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
// don't make changes in here.
// import createHistory from 'history/createBrowserHistory'

import { createHashHistory } from "history";
import { createHashHistory } from 'history';

const history = createHashHistory();

Expand Down
4 changes: 2 additions & 2 deletions src/js/common/components/Example/Example.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { PureComponent } from "react";
import React, { PureComponent } from 'react';

import styles from "./Example.css";
import styles from './Example.css';

/**
* Example
Expand Down
6 changes: 3 additions & 3 deletions src/js/common/components/Example/ExampleWithError.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { PureComponent } from "react";
import React, { PureComponent } from 'react';

import styles from "./Example.css";
import styles from './Example.css';

class ExampleWithError extends PureComponent {
render() {
Expand All @@ -11,7 +11,7 @@ class ExampleWithError extends PureComponent {
return (
<div className={styles.exampleOutput}>
<h1>This should catch by ErrorBoundary</h1>
{result.something_not_existed.get("something_not_existed")}
{result.something_not_existed.get('something_not_existed')}
</div>
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/js/common/components/Example/index.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { default as Example } from "./Example";
export { default as ExampleWithError } from "./ExampleWithError";
export { default as Example } from './Example';
export { default as ExampleWithError } from './ExampleWithError';
18 changes: 9 additions & 9 deletions src/js/common/components/Header/Header.jsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
import React, { PureComponent } from "react";
import { Link } from "react-router-dom";
import React, { PureComponent } from 'react';
import { Link } from 'react-router-dom';

import styles from "./Header.css";
import styles from './Header.css';

class Header extends PureComponent {
render() {
const { location } = this.props;
const { pathname } = location;

const isHome = pathname === "/";
const isJustAnotherPage = pathname === "/page";
const isHome = pathname === '/';
const isJustAnotherPage = pathname === '/page';

return (
<header className={styles.globalHeader}>
<ul>
<li className={!isHome ? styles.active : ""}>
{isHome ? "Home" : <Link to="/">Home</Link>}
<li className={!isHome ? styles.active : ''}>
{isHome ? 'Home' : <Link to="/">Home</Link>}
</li>
<li className={!isJustAnotherPage ? styles.active : ""}>
<li className={!isJustAnotherPage ? styles.active : ''}>
{isJustAnotherPage ? (
"Just Another Page"
'Just Another Page'
) : (
<Link to="/page">Just Another Page</Link>
)}
Expand Down
2 changes: 1 addition & 1 deletion src/js/common/components/Header/index.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { default as Header } from "./Header";
export { default as Header } from './Header';
11 changes: 6 additions & 5 deletions src/js/common/components/LazyLoading/Loading.jsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import React, { PureComponent } from "react";
import React, { PureComponent } from 'react';

import styles from "./Loading.css";
import styles from './Loading.css';

class Loading extends PureComponent {
getMessage() {
const { isLoading, timedOut, pastDelay, error } = this.props;
const {
isLoading, timedOut, pastDelay, error,
} = this.props;

const errorMessage =
"We can&apos;t pull up information at this point, please try again.";
const errorMessage = 'We can&apos;t pull up information at this point, please try again.';

if (isLoading) {
if (timedOut) {
Expand Down
15 changes: 7 additions & 8 deletions src/js/common/components/LazyLoading/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import Loadable from "react-loadable";
import Loadable from 'react-loadable'

import Loading from "./Loading";
import Loading from './Loading'

export const create = (loader) =>
Loadable({
loader,
loading: Loading,
});
export const create = (loader) => Loadable({
loader,
loading: Loading,
})

export default create;
export default create
36 changes: 18 additions & 18 deletions src/js/common/components/Utilities/ErrorBoundary.jsx
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
import React, { PureComponent } from "react";
import React, { PureComponent } from 'react'

const style = {
padding: ".75rem 1.25rem",
marginBottom: "1rem",
border: "1px solid transparent",
borderRadius: ".25rem",
color: "#721c24",
backgroundColor: "#f8d7da",
borderColor: "#f5c6cb",
};
padding: '.75rem 1.25rem',
marginBottom: '1rem',
border: '1px solid transparent',
borderRadius: '.25rem',
color: '#721c24',
backgroundColor: '#f8d7da',
borderColor: '#f5c6cb',
}

class ErrorBoundary extends PureComponent {
constructor(props) {
super(props);
super(props)
this.state = {
hasError: false,
};
}
}

componentDidCatch(error, info) {
// you probably want to log it somewhere
console.log(error, info);
console.log(error, info)
this.setState({
hasError: true,
});
})
}

render() {
const { hasError } = this.state;
const { children } = this.props;
const { hasError } = this.state
const { children } = this.props

if (hasError) {
return (
<div style={style}>
Something is going wrong!! This error is caught by ErrorBoundary
feature in React 16 \o/
</div>
);
)
}

return children;
return children
}
}

export default ErrorBoundary;
export default ErrorBoundary
2 changes: 1 addition & 1 deletion src/js/common/components/Utilities/index.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { default as ErrorBoundary } from "./ErrorBoundary";
export { default as ErrorBoundary } from './ErrorBoundary';
28 changes: 14 additions & 14 deletions src/js/main.jsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
import React from "react";
import ReactDOM from "react-dom";
import { fromJS } from "immutable";
import React from 'react'
import ReactDOM from 'react-dom'
import { fromJS } from 'immutable'

import routes from "./routes";
import Root from "./Root";
import configureStore from "./redux/configureStore";
import { history } from "./app-history";
import routes from './routes'
import Root from './Root'
import configureStore from './redux/configureStore'
import { history } from './app-history'

let initialState = {};
let initialState = {}

// rehydrate initialState for JS app
if (window.__INITIAL_STATE__) {
initialState = window.__INITIAL_STATE__;
initialState = window.__INITIAL_STATE__

// Transform into Immutable.js collections,
// but leave top level keys untouched for Redux
Object.keys(initialState).forEach((key) => {
initialState[key] = fromJS(initialState[key]);
});
initialState[key] = fromJS(initialState[key])
})
}

const store = configureStore(initialState, history);
const store = configureStore(initialState, history)

// Render the React application to the DOM
// Root component is to bootstrap Provider, Router and DevTools
ReactDOM.render(
<Root history={history} routes={routes} store={store} />,
document.getElementById("app-container")
);
document.getElementById('app-container')
)
37 changes: 19 additions & 18 deletions src/js/redux/configureStore.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,37 @@
import createSagaMiddleware from "redux-saga";
import { applyMiddleware, compose, createStore } from "redux";
import createSagaMiddleware from 'redux-saga'
import { applyMiddleware, compose, createStore } from 'redux'

import sagas from "./sagas";
import rootReducer from "./rootReducers";
import sagas from './sagas'
import rootReducer from './rootReducers'

// Redux DevTools Extension for Chrome and Firefox
const reduxDevTool = () => {
return typeof window === "object" &&
typeof window.__REDUX_DEVTOOLS_EXTENSION__ !== "undefined"
return typeof window === 'object'
&& typeof window.__REDUX_DEVTOOLS_EXTENSION__ !== 'undefined'
? window.__REDUX_DEVTOOLS_EXTENSION__()
: (f) => f;
};
: (f) => f
}

export default function configureStore(initialState, history) {
const sagaMiddleware = createSagaMiddleware();
// history is passed here, for this example, we don't use history
export default function configureStore(initialState, history) { // eslint-disable-line no-unused-vars, max-len
const sagaMiddleware = createSagaMiddleware()

const middleware = applyMiddleware(sagaMiddleware);
const middleware = applyMiddleware(sagaMiddleware)

const composedStoreEnhancer = compose(
middleware,
reduxDevTool()
);
)

const store = composedStoreEnhancer(createStore)(rootReducer, initialState);
const store = composedStoreEnhancer(createStore)(rootReducer, initialState)

sagaMiddleware.run(sagas);
sagaMiddleware.run(sagas)

if (module.hot) {
module.hot.accept("./rootReducers", () => {
store.replaceReducer(require("./rootReducers"));
});
module.hot.accept('./rootReducers', () => {
store.replaceReducer(require('./rootReducers'))
})
}

return store;
return store
}
Loading

0 comments on commit e3d78ba

Please sign in to comment.