Skip to content
This repository has been archived by the owner on Jun 28, 2021. It is now read-only.

Commit

Permalink
Add prettier (#754)
Browse files Browse the repository at this point in the history
* add prettier

* ensure prettier works
  • Loading branch information
thabti authored and mmahalwy committed Apr 20, 2017
1 parent 230eaf5 commit 538606d
Show file tree
Hide file tree
Showing 4 changed files with 304 additions and 62 deletions.
5 changes: 5 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@
"comma-dangle": 0,
"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }],
"import/no-extraneous-dependencies": 0,
"import/prefer-default-export": 1,
"import/extensions": 0,
"import/no-unresolved": 0,
"property": 0,
"no-mixed-operators": 0,
"strict": 0
},
"ecmaFeatures": {
Expand Down Expand Up @@ -38,7 +41,9 @@
mixpanel: true,
"expect": true,
"browser": true,
"import": true,
"FB": true,
"window": true,
sinon: true
},
"env": {
Expand Down
24 changes: 18 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,21 @@
"build:client": "webpack --config ./webpack/prod.config.js",
"validate": "npm ls",
"analyze:build": "env NODE_ENV=production webpack --json --config ./webpack/prod.config.js > bundle-stats.json",
"analyze:json": "webpack-bundle-size-analyzer bundle-stats.json"
"analyze:json": "webpack-bundle-size-analyzer bundle-stats.json",
"lint:fix": "npm run test:dev:lint -- --fix",
"prettier": "prettier --single-quote --write",
"precommit": "lint-staged"
},
"pre-commit": [
"test:stylelint",
"precommit"
],
"lint-staged": {
"*.js": [
"npm run prettier",
"npm run lint:fix",
"git add"
]
},
"engines": {
"node": ">= 6.3.0"
Expand Down Expand Up @@ -158,13 +172,15 @@
"karma-sinon": "1.0.4",
"karma-sourcemap-loader": "0.3.7",
"karma-webpack": "1.8.0",
"lint-staged": "^3.4.0",
"mocha": "2.2.5",
"nodemon": "1.7.1",
"path": "0.11.14",
"phantomjs": "1.9.20",
"phantomjs-polyfill": "0.0.1",
"piping": "0.3.0",
"pre-commit": "1.1.3",
"prettier": "^1.2.2",
"react-addons-test-utils": "15.4.1",
"react-transform-catch-errors": "1.0.0",
"react-transform-hmr": "1.0.1",
Expand All @@ -179,9 +195,5 @@
"webpack-bundle-analyzer": "2.2.1",
"webpack-dev-server": "2.1.0-beta.0",
"webpack-hot-middleware": "2.12.2"
},
"pre-commit": [
"test:dev:lint",
"test:stylelint"
]
}
}
67 changes: 33 additions & 34 deletions src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,8 @@ Raven.config(config.sentryServer, {
autoBreadcrumbs: true
}).install();


expressConfig(server);


server.use(Raven.requestHandler());

server.use((req, res, next) => {
Expand All @@ -49,14 +47,11 @@ server.use((req, res, next) => {
}

if (req.query.DISABLE_SSR) {
return res.status(200).send(`<!doctype html>\n${ReactDOM.renderToString(
<IntlProvider locale="en" messages={localMessages}>
<Html
store={store}
assets={webpack_isomorphic_tools.assets()}
/>
</IntlProvider>
)}`);
return res.status(200).send(
`<!doctype html>\n${ReactDOM.renderToString(<IntlProvider locale="en" messages={localMessages}>
<Html store={store} assets={webpack_isomorphic_tools.assets()} />
</IntlProvider>)}`
);
}

store.dispatch(setUserAgent(req.useragent));
Expand All @@ -74,29 +69,29 @@ server.use((req, res, next) => {
console.error('ROUTER ERROR:', pretty.render(error));
res.status(500).send(error);
} else if (renderProps) {
const status = renderProps.location.pathname.indexOf('/error') > -1 ? 404 : 200;

loadOnServer({ ...renderProps, store, helpers: { client } }).then(() => {
const component = (
<IntlProvider messages={localMessages} locale="en" >
<Provider store={store}>
<ReduxAsyncConnect {...renderProps} />
</Provider>
</IntlProvider>
);

res.type('html');
res.setHeader('Cache-Control', 'public, max-age=31557600');
res.status(status);
debug('Server', 'Sending markup');
res.send(`<!doctype html>\n${ReactDOM.renderToString(
<Html
component={component}
store={store}
assets={webpack_isomorphic_tools.assets()}
/>
)}`);
}).catch(next);
const status = renderProps.location.pathname.indexOf('/error') > -1
? 404
: 200;

loadOnServer({ ...renderProps, store, helpers: { client } })
.then(() => {
const component = (
<IntlProvider messages={localMessages} locale="en">
<Provider store={store}>
<ReduxAsyncConnect {...renderProps} />
</Provider>
</IntlProvider>
);

res.type('html');
res.setHeader('Cache-Control', 'public, max-age=31557600');
res.status(status);
debug('Server', 'Sending markup');
res.send(
`<!doctype html>\n${ReactDOM.renderToString(<Html component={component} store={store} assets={webpack_isomorphic_tools.assets()} />)}`
);
})
.catch(next);
}
}
);
Expand All @@ -123,7 +118,11 @@ export default function serve(cb) {
console.info(`==> 🌎 ENV=${process.env.NODE_ENV}`);
console.info(`==> ✅ Server is listening at http://localhost:${port}`);
console.info(`==> 🎯 API at ${process.env.API_URL}`);
Object.keys(config).forEach(key => config[key].constructor.name !== 'Object' && console.info(`==> ${key}`, config[key]));
Object.keys(config).forEach(
key =>
config[key].constructor.name !== 'Object' &&
console.info(`==> ${key}`, config[key])
);

return cb && cb(this);
});
Expand Down
Loading

0 comments on commit 538606d

Please sign in to comment.