From df4b389a3790f8b217dca83e4ebbb4d14ac1ffaa Mon Sep 17 00:00:00 2001 From: Julien Wajsberg Date: Thu, 29 Jun 2017 20:43:27 +0200 Subject: [PATCH] Check also the webpack config and the server code --- .eslintrc.js | 1 + package.json | 2 +- server.js | 6 ++-- webpack.config.js | 82 ++++++++++++++++++++++++----------------------- 4 files changed, 48 insertions(+), 43 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index f2ea092043..ce9e190af8 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -39,6 +39,7 @@ module.exports = { // overriding recommended rules "no-constant-condition": ["error", { checkLoops: false }], "no-console": [ "error", { allow: ["log", "warn", "error"] } ], + "no-unused-vars": ["error", { "argsIgnorePattern": "^_" }], // possible errors "array-callback-return": "error", diff --git a/package.json b/package.json index 3edee9c873..328e29db17 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "build-prod": "yarn run build:clean && NODE_ENV=production webpack -p --progress", "build-prod-readable": "yarn run build:clean && NODE_ENV=production webpack --progress", "build-docs": "documentation build src/types/profile.js -f md > docs/processed-profile-format.md; cat docs/processed-profile-format.md", - "eslint": "eslint index.js src", + "eslint": "eslint *.js src", "eslint-fix": "yarn eslint -- --fix", "flow": "flow", "flow-coverage": "flow-coverage-report -i 'src/**/*.js' -t html -t text", diff --git a/server.js b/server.js index ddb305c7dc..cec73d79b3 100644 --- a/server.js +++ b/server.js @@ -14,13 +14,15 @@ new WebpackDevServer(webpack(config), { stats: { colors: true, }, -}).listen(port, 'localhost', function (err) { +}).listen(port, 'localhost', function(err) { if (err) { console.log(err); } console.log(`Listening at localhost:${port}`); if (port === 4242) { - console.log('You can change this default port with the environment variable PERFHTML_PORT.'); + console.log( + 'You can change this default port with the environment variable PERFHTML_PORT.' + ); } }); diff --git a/webpack.config.js b/webpack.config.js index 732eae688f..a1ce18abe1 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -2,14 +2,9 @@ const path = require('path'); const webpack = require('webpack'); const HtmlWebpackPlugin = require('html-webpack-plugin'); const OfflinePlugin = require('offline-plugin'); -const includes = [ - path.join(__dirname, 'src'), - path.join(__dirname, 'res'), -]; +const includes = [path.join(__dirname, 'src'), path.join(__dirname, 'res')]; -const es6modules = [ - 'pretty-bytes', -]; +const es6modules = ['pretty-bytes']; const es6modulePaths = es6modules.map(module => { return path.join(__dirname, 'node_modules', module); }); @@ -36,33 +31,40 @@ const baseConfig = { alias: { 'redux-devtools/lib': path.join(__dirname, '..', '..', 'src'), 'redux-devtools': path.join(__dirname, '..', '..', 'src'), - 'react': path.join(__dirname, 'node_modules', 'react'), + react: path.join(__dirname, 'node_modules', 'react'), }, extensions: ['.js'], }, module: { - rules: [{ - test: /\.js$/, - loaders: ['babel-loader'], - include: includes.concat(es6modulePaths), - }, { - test: /\.json$/, - loaders: ['json-loader'], - include: includes, - }, { - test: /\.css?$/, - loaders: ['style-loader', 'css-loader?minimize'], - include: includes, - }, { - test: /\.jpg$/, - loader: 'file-loader', - }, { - test: /\.png$/, - loader: 'file-loader', - }, { - test: /\.svg$/, - loader: 'file-loader', - }], + rules: [ + { + test: /\.js$/, + loaders: ['babel-loader'], + include: includes.concat(es6modulePaths), + }, + { + test: /\.json$/, + loaders: ['json-loader'], + include: includes, + }, + { + test: /\.css?$/, + loaders: ['style-loader', 'css-loader?minimize'], + include: includes, + }, + { + test: /\.jpg$/, + loader: 'file-loader', + }, + { + test: /\.png$/, + loader: 'file-loader', + }, + { + test: /\.svg$/, + loader: 'file-loader', + }, + ], }, node: { process: false, @@ -71,7 +73,9 @@ const baseConfig = { if (process.env.NODE_ENV === 'development') { baseConfig.devtool = 'source-map'; - baseConfig.entry = ['webpack-dev-server/client?http://localhost:4242'].concat(baseConfig.entry); + baseConfig.entry = ['webpack-dev-server/client?http://localhost:4242'].concat( + baseConfig.entry + ); } const contentConfig = Object.assign({}, baseConfig, { @@ -80,10 +84,9 @@ const contentConfig = Object.assign({}, baseConfig, { title: 'perf.html', template: 'res/index.html', favicon: 'res/favicon.png', - })), - entry: [ - './src/index', - ], + }) + ), + entry: ['./src/index'], output: { path: path.join(__dirname, 'dist'), filename: '[hash].bundle.js', @@ -105,19 +108,18 @@ if (process.env.NODE_ENV === 'production') { cacheMaps: [ { requestTypes: null, - match: function (url, request) { + match: function(url, _request) { return url.origin === location.origin ? url.origin + '/' : null; }, }, ], - })); + }) + ); } const workerConfig = Object.assign({}, baseConfig, { plugins: basePlugins.slice(0), - entry: [ - './src/profile-logic/summary-worker/index', - ], + entry: ['./src/profile-logic/summary-worker/index'], output: { path: path.join(__dirname, 'dist'), filename: 'worker.js',