Skip to content
This repository has been archived by the owner on Nov 15, 2017. It is now read-only.

Commit

Permalink
Eslint autofix result
Browse files Browse the repository at this point in the history
  • Loading branch information
swernerx committed Jul 14, 2016
1 parent 910bd36 commit 54f0d2d
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 60 deletions.
31 changes: 16 additions & 15 deletions src/client/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import React from 'react';
import { render } from 'react-dom';
import { AppContainer } from 'react-hot-loader';
import Router from 'react-router/lib/Router';
import browserHistory from 'react-router/lib/browserHistory';
import match from 'react-router/lib/match';
import routes from '../shared/routes';
import React from "react"
import { render } from "react-dom"
import { AppContainer } from "react-hot-loader"
import Router from "react-router/lib/Router"
import browserHistory from "react-router/lib/browserHistory"
import match from "react-router/lib/match"
import routes from "../shared/routes"

// Get the DOM Element that will host our React application.
const container = document.getElementById('app');
const container = document.getElementById("app")

function renderApp() {
// As we are using dynamic react-router routes we have to use the following
Expand All @@ -16,7 +16,7 @@ function renderApp() {
match({ history: browserHistory, routes }, (error, redirectLocation, renderProps) => {
if (error) {
// TODO: Error handling.
console.log('==> 😭 React Router match failed.'); // eslint-disable-line no-console
console.log("==> 😭 React Router match failed.") // eslint-disable-line no-console
}

render(
Expand All @@ -29,16 +29,17 @@ function renderApp() {
<Router {...renderProps} />
</AppContainer>,
container
);
});
)
})
}

// The following is needed so that we can hot reload our App.
if (process.env.NODE_ENV === 'development' && module.hot) {
if (process.env.NODE_ENV === "development" && module.hot) {
// Accept changes to this file for hot reloading.
module.hot.accept();
module.hot.accept()

// Any changes to our routes will cause a hotload re-render.
module.hot.accept('../shared/routes', renderApp);
module.hot.accept("../shared/routes", renderApp)
}

renderApp();
renderApp()
39 changes: 20 additions & 19 deletions src/server/middleware/universalReactApp.js
Original file line number Diff line number Diff line change
@@ -1,46 +1,47 @@
import React from 'react';
import RouterContext from 'react-router/lib/RouterContext';
import createMemoryHistory from 'react-router/lib/createMemoryHistory';
import match from 'react-router/lib/match';
import render from '../htmlPage/render';
import routes from '../../shared/routes';
import React from "react"
import RouterContext from "react-router/lib/RouterContext"
import createMemoryHistory from "react-router/lib/createMemoryHistory"
import match from "react-router/lib/match"
import render from "../htmlPage/render"
import routes from "../../shared/routes"

/**
* An express middleware that is capabable of doing React server side rendering.
*/
function universalReactAppMiddleware(request, response) {
if (process.env.DISABLE_SSR) {
if (process.env.NODE_ENV === 'development') {
console.log('==> 🐌 Handling react route without SSR'); // eslint-disable-line no-console
if (process.env.NODE_ENV === "development") {
console.log("==> 🐌 Handling react route without SSR") // eslint-disable-line no-console
}

// SSR is disabled so we will just return an empty html page and will
// rely on the client to populate the initial react application state.
const html = render();
response.status(200).send(html);
return;
const html = render()
response.status(200).send(html)
return
}

const history = createMemoryHistory(request.originalUrl);
const history = createMemoryHistory(request.originalUrl)

// Server side handling of react-router.
// Read more about this here:
// https://github.com/reactjs/react-router/blob/master/docs/guides/ServerRendering.md
match({ routes, history }, (error, redirectLocation, renderProps) => {
if (error) {
response.status(500).send(error.message);
response.status(500).send(error.message)
} else if (redirectLocation) {
response.redirect(302, redirectLocation.pathname + redirectLocation.search);
response.redirect(302, redirectLocation.pathname + redirectLocation.search)
} else if (renderProps) {
// You can check renderProps.components or renderProps.routes for
// your "not found" component or route respectively, and send a 404 as
// below, if you're using a catch-all route.

const html = render({ rootElement: <RouterContext {...renderProps} /> });
response.status(200).send(html);
const html = render({ rootElement: <RouterContext {...renderProps} /> })
response.status(200).send(html)
} else {
response.status(404).send('Not found');
response.status(404).send("Not found")
}
});
})
}

export default universalReactAppMiddleware;
export default universalReactAppMiddleware
6 changes: 3 additions & 3 deletions src/shared/components/About/About.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React from "react"
import Styles from "./AboutStyles.css"

function About() {
Expand All @@ -8,7 +8,7 @@ function About() {
Produced with ❤️ by <a href="https://github.com/sebastiansoft">Sebastian Software</a>
</p>
</article>
);
)
}

export default About;
export default About
12 changes: 6 additions & 6 deletions src/shared/components/App/App.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'normalize.css/normalize.css';
import "normalize.css/normalize.css"

import React, { PropTypes } from 'react';
import Link from 'react-router/lib/Link';
import React, { PropTypes } from "react"
import Link from "react-router/lib/Link"

function App({ children }) {
return (
Expand All @@ -20,11 +20,11 @@ function App({ children }) {
{children}
</div>
</main>
);
)
}

App.propTypes = {
children: PropTypes.node
};
}

export default App;
export default App
6 changes: 3 additions & 3 deletions src/shared/components/Home/Home.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React from "react"

function Home() {
return (
Expand All @@ -7,7 +7,7 @@ function Home() {
Home Component
</p>
</article>
);
)
}

export default Home;
export default Home
28 changes: 14 additions & 14 deletions src/shared/routes/index.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import React from 'react';
import Route from 'react-router/lib/Route';
import IndexRoute from 'react-router/lib/IndexRoute';
import App from '../components/App';
import React from "react"
import Route from "react-router/lib/Route"
import IndexRoute from "react-router/lib/IndexRoute"
import App from "../components/App"

function handleError(err) {
// TODO: Error handling, do we return an Error component here?
console.log('==> Error occurred loading dynamic route'); // eslint-disable-line no-console
console.log(err); // eslint-disable-line no-console
console.log("==> Error occurred loading dynamic route") // eslint-disable-line no-console
console.log(err) // eslint-disable-line no-console
}

function resolveIndexComponent(nextState, cb) {
System.import('../components/Home')
.then(module => cb(null, module.default))
.catch(handleError);
System.import("../components/Home")
.then((module) => cb(null, module.default))
.catch(handleError)
}

function resolveAboutComponent(nextState, cb) {
System.import('../components/About')
.then(module => cb(null, module.default))
.catch(handleError);
System.import("../components/About")
.then((module) => cb(null, module.default))
.catch(handleError)
}

/**
Expand All @@ -35,6 +35,6 @@ const routes = (
<IndexRoute getComponent={resolveIndexComponent} />
<Route path="about" getComponent={resolveAboutComponent} />
</Route>
);
)

export default routes;
export default routes

0 comments on commit 54f0d2d

Please sign in to comment.