Skip to content

Commit abb92d8

Browse files
committed
Fix eslint errors
1 parent 015ca89 commit abb92d8

34 files changed

+296
-270
lines changed

.eslintrc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"extends": "./src/config/eslint.js",
3+
"rules": {
4+
// Since most of the files in this project don't use ES6, we need to change a
5+
// few rules from our base ESLint configuration.
6+
"comma-dangle": [
7+
"error",
8+
{
9+
"arrays": "always-multiline",
10+
"objects": "always-multiline",
11+
"imports": "always-multiline",
12+
"exports": "always-multiline",
13+
"functions": "ignore"
14+
}
15+
]
16+
}
17+
}

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
},
2323
"scripts": {},
2424
"dependencies": {
25+
"autoprefixer": "6.7.7",
2526
"babel-cli": "6.24.1",
2627
"babel-core": "6.24.1",
2728
"babel-eslint": "7.2.2",
@@ -43,9 +44,6 @@
4344
"eslint-import-resolver-node": "0.3.0",
4445
"eslint-loader": "1.7.1",
4546
"eslint-plugin-flowtype": "2.30.4",
46-
"eslint-plugin-import": "2.2.0",
47-
"eslint-plugin-jsx-a11y": "4.0.0",
48-
"eslint-plugin-react": "6.10.3",
4947
"express": "4.15.2",
5048
"extract-text-webpack-plugin": "2.1.0",
5149
"file-loader": "0.11.1",

src/bootstrap/client/start.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,11 @@ hydrate(meta, { render }, data);
2424
if (process.env.APP_MODE === 'development') {
2525
window.React = React; // enable debugger
2626

27-
if (!dest
28-
|| !dest.firstChild
29-
|| !dest.firstChild.attributes
30-
|| !dest.firstChild.attributes['data-react-checksum']
27+
if (
28+
!dest ||
29+
!dest.firstChild ||
30+
!dest.firstChild.attributes ||
31+
!dest.firstChild.attributes['data-react-checksum']
3132
) {
3233
// eslint-disable-next-line no-console
3334
console.error('React server rendering was discarded.');

src/bootstrap/server/createHttpServer.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ module.exports = function createHttpServer(config) {
1313
const server = new http.Server(app);
1414

1515
// proxy middleware
16-
config.proxies.forEach((proxy) => {
16+
config.proxies.forEach(proxy => {
1717
app.use(proxy.path, createProxy(proxy, server));
1818
});
1919

@@ -38,17 +38,20 @@ module.exports = function createHttpServer(config) {
3838

3939
// start server
4040
if (config.port && config.host) {
41-
server.listen(config.port, config.host, function(err) {
41+
server.listen(config.port, config.host, err => {
4242
if (err) {
43+
// eslint-disable-next-line no-console
4344
console.error(err);
4445
}
46+
// eslint-disable-next-line no-console
4547
console.info(
4648
'\n~~> Node.js server is running.\n Open',
4749
`\x1b[93mhttp://localhost:${config.port}\x1b[0m`,
4850
'in a browser to view the app.\n'
4951
);
5052
});
5153
} else {
54+
// eslint-disable-next-line no-console
5255
console.error('ERROR: No PORT or HOST config variable has been specified');
5356
}
5457
};

src/bootstrap/server/createReactAppOnServer.js

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
const React = require('react');
21
const ReactDOM = require('react-dom/server');
32
// const 'isomorphic-fetch';
43
const addCookie = require('../utils/addCookie');
@@ -16,11 +15,14 @@ module.exports = function createAppOnServer(config) {
1615
return (req, res) => {
1716
// try to find locale from url, header and cookies
1817
const localeFromUrl = getLocaleFromUrl(req.originalUrl, config.app.locale.supported);
19-
const localeFromHeader = getLocaleFromHeader(req.headers['accept-language'], config.app.locale.supported);
18+
const localeFromHeader = getLocaleFromHeader(
19+
req.headers['accept-language'],
20+
config.app.locale.supported
21+
);
2022
const localeFromCookies = getLocaleFromCookies(req.cookies, config.app.locale.supported);
2123

2224
const url = req.url;
23-
const urlWithoutLocale = (localeFromUrl)
25+
const urlWithoutLocale = localeFromUrl
2426
? stripLocaleFromUrl(req.originalUrl, localeFromUrl)
2527
: req.originalUrl;
2628

@@ -38,7 +40,7 @@ module.exports = function createAppOnServer(config) {
3840
addCookie(req, res, {
3941
name: 'lang',
4042
value: locale,
41-
options: { maxAge: 2628000 * 60 * 1000 } // 5 years lifetime
43+
options: { maxAge: 2628000 * 60 * 1000 }, // 5 years lifetime
4244
});
4345
}
4446

@@ -57,7 +59,7 @@ module.exports = function createAppOnServer(config) {
5759
addCookie(req, res, {
5860
name: 'csrf',
5961
value: csrfToken,
60-
options: { httpOnly: true }
62+
options: { httpOnly: true },
6163
});
6264
}
6365

@@ -82,15 +84,17 @@ module.exports = function createAppOnServer(config) {
8284
if (process.env.APP_MODE === 'development') {
8385
delete require.cache[paths.webpackAssets];
8486

85-
Object.keys(require.cache).forEach(function(id) {
86-
if (/[\/\\]app[\/\\]/.test(id)) delete require.cache[id];
87+
Object.keys(require.cache).forEach(id => {
88+
if (/[/\\]app[/\\]/.test(id)) delete require.cache[id];
8789
});
8890
}
8991

9092
// define render, redirect and error function for hydrate function
9193
const render = (component, data) => {
94+
// eslint-disable-next-line
9295
const assets = require(paths.webpackAssets);
9396
const content = component ? ReactDOM.renderToString(component) : '';
97+
// eslint-disable-next-line
9498
const renderHtml = require(paths.appHtml).default;
9599

96100
const htmlSnippets = generateHtmlSnippets(meta, content, assets, data, config.devBuild.dll);
@@ -99,15 +103,15 @@ module.exports = function createAppOnServer(config) {
99103

100104
res.status(200).send(html);
101105
};
102-
const redirect = (path) => {
106+
const redirect = path => {
103107
res.redirect(path);
104-
}
105-
const error = (message, status) => {
108+
};
109+
const error = message => {
106110
res.status(404);
107111
if (message) {
108-
res.send(message)
112+
res.send(message);
109113
}
110-
}
114+
};
111115

112116
// Render page on client if server side rendering is disabled.
113117
// Initial state should be empty in this case.
@@ -117,7 +121,8 @@ module.exports = function createAppOnServer(config) {
117121
}
118122

119123
// get hydrate function and hydrate
124+
// eslint-disable-next-line
120125
const hydrate = require(paths.appServerEntry).default;
121126
hydrate(meta, { error, redirect, render });
122127
};
123-
};
128+
};

src/bootstrap/server/defaultConfig.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
const paths = require('../../config/paths');
2-
31
module.exports = {
42
host: 'localhost',
53
port: 8080,
@@ -14,10 +12,10 @@ module.exports = {
1412
supported: ['en'],
1513
},
1614
device: {
17-
autoDetect: true
15+
autoDetect: true,
1816
},
1917
},
2018
devBuild: {
2119
dll: false,
22-
}
20+
},
2321
};

src/bootstrap/server/run.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ module.exports = function runServer(customConfig) {
1212
const config = deepmerge(defaultConfig, customConfig);
1313

1414
// define process.env.NODE_PATH for imports
15+
// eslint-disable-next-line global-require
1516
const Module = require('module').Module;
1617
process.env.NODE_PATH = paths.appMain;
18+
// eslint-disable-next-line no-underscore-dangle
1719
Module._initPaths();
1820

1921
// define app process.env constants
@@ -22,9 +24,12 @@ module.exports = function runServer(customConfig) {
2224
process.env.APP_PLATFORM = 'web';
2325

2426
// define webpackIsomorphicTools constant
25-
new WebpackIsomorphicTools(require('../../config/webpackIsomorphicTools'))
26-
.server(paths.appRoot, function() {
27-
const createHttpServer = require('./createHttpServer');
28-
createHttpServer(config);
29-
});
27+
new WebpackIsomorphicTools(
28+
// eslint-disable-next-line global-require
29+
require('../../config/webpackIsomorphicTools')
30+
).server(paths.appRoot, () => {
31+
// eslint-disable-next-line global-require
32+
const createHttpServer = require('./createHttpServer');
33+
createHttpServer(config);
34+
});
3035
};

src/bootstrap/utils/addCookie.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ module.exports = function addCookie(req, res, data) {
99
req.headers.cookie = `${req.headers.cookie};${data.name}=${data.value}`;
1010
}
1111
res.cookie(data.name, data.value, data.options);
12-
}
12+
};

src/bootstrap/utils/createProxy.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ function proxyError(error, req, res) {
44
// add the error handling
55
// https://github.com/nodejitsu/node-http-proxy/issues/527
66
if (error.code !== 'ECONNRESET') {
7+
// eslint-disable-next-line no-console
78
console.error('proxy error', error);
89
}
910
if (!res.headersSent) {
@@ -12,7 +13,7 @@ function proxyError(error, req, res) {
1213

1314
const json = { error: 'proxy_error', reason: error.message };
1415
res.end(JSON.stringify(json));
15-
};
16+
}
1617

1718
module.exports = function createProxy(options, server) {
1819
const proxy = httpProxy.createProxyServer(options);

src/bootstrap/utils/detectDevice.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,10 @@ module.exports = function detectDevice(userAgent, cookie, auto) {
1717
if (md.phone() !== null) {
1818
// phone
1919
return 'mobile';
20-
} else {
21-
// tablet
22-
return 'desktop';
2320
}
24-
} else {
25-
// desktop
21+
// tablet
2622
return 'desktop';
2723
}
24+
// desktop
25+
return 'desktop';
2826
};

0 commit comments

Comments
 (0)