Improves eslint rules (#785)

* Switch to airbnb's eslint

* Applies automatic fixes

* Clean up dependencies

* New lint rules

* Apply auto fixes

* Prettier

* Update prettier position in eslint config

* Aligns prettier and eslint

* Use partial configs for client and server directories

* Finalizes eslint config (for now)

* Applies all elsint fixes

* Removes duplciated config

* Fixes build & local dev

* Fix CI build
This commit is contained in:
John Furrow
2019-05-02 22:21:47 -07:00
committed by GitHub
parent 92e8989c0c
commit dbedc6c7a5
168 changed files with 11074 additions and 6728 deletions
+21 -24
View File
@@ -7,6 +7,7 @@ const ManifestPlugin = require('webpack-manifest-plugin');
const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin');
const eslintFormatter = require('react-dev-utils/eslintFormatter');
const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin');
const TerserPlugin = require('terser-webpack-plugin');
const paths = require('./paths');
const getClientEnvironment = require('./env');
@@ -23,7 +24,7 @@ if (env.stringified['process.env'].NODE_ENV !== '"production"') {
}
// Note: defined here because it will be used more than once.
const cssFilename = 'static/css/[name].[contenthash:8].css';
const cssFilename = 'static/css/[name].[hash:8].css';
// ExtractTextPlugin expects the build output to be flat.
// (See https://github.com/webpack-contrib/extract-text-webpack-plugin/issues/27)
@@ -35,6 +36,7 @@ const extractTextPluginOptions = {};
// It compiles slowly and is focused on producing a fast and minimal bundle.
// The development configuration is different and lives in a separate file.
module.exports = {
mode: process.env.NODE_ENV,
// Don't attempt to continue if there are any errors.
bail: true,
// We generate sourcemaps in production. This is slow but gives good results.
@@ -51,7 +53,7 @@ module.exports = {
filename: 'static/js/[name].[chunkhash:8].js',
chunkFilename: 'static/js/[name].[chunkhash:8].chunk.js',
// We inferred the "public path" (such as / or /my-project) from homepage.
publicPath: publicPath,
publicPath,
// Point sourcemap entries to original disk location (format as URL on Windows)
devtoolModuleFilenameTemplate: info => path.relative(paths.appSrc, info.absoluteResourcePath).replace(/\\/g, '/'),
},
@@ -62,7 +64,7 @@ module.exports = {
// https://github.com/facebookincubator/create-react-app/issues/253
modules: ['node_modules', paths.appNodeModules].concat(
// It is guaranteed to exist because we tweak it in `env.js`
process.env.NODE_PATH.split(path.delimiter).filter(Boolean)
process.env.NODE_PATH.split(path.delimiter).filter(Boolean),
),
// These are the reasonable defaults supported by the Node ecosystem.
// We also include JSX as a common component filename extension to support
@@ -195,8 +197,8 @@ module.exports = {
},
],
},
extractTextPluginOptions
)
extractTextPluginOptions,
),
),
// Note: this won't work without `new ExtractTextPlugin()` in `plugins`.
},
@@ -204,11 +206,24 @@ module.exports = {
// Remember to add the new extension(s) to the "file" loader exclusion list.
],
},
optimization: {
minimizer: [
new TerserPlugin({
cache: true,
parallel: true,
sourceMap: true,
}),
],
},
performance: {
// TODO: Add code-splitting and re-enable this when the bundle is smaller
hints: false,
},
plugins: [
// Makes some environment variables available in index.html.
// The base URI is available as %BASE_URI% in index.html, e.g.:
// <link rel="shortcut icon" href="%BASE_URI%/favicon.ico">
new InterpolateHtmlPlugin(env.raw),
new InterpolateHtmlPlugin(HtmlWebpackPlugin, env.raw),
// Generates an `index.html` file with the <script> injected.
new HtmlWebpackPlugin({
inject: true,
@@ -231,24 +246,6 @@ module.exports = {
// It is absolutely essential that NODE_ENV was set to production here.
// Otherwise React will be compiled in the very slow development mode.
new webpack.DefinePlugin(env.stringified),
// Minify the code.
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false,
// Disabled because of an issue with Uglify breaking seemingly valid code:
// https://github.com/facebookincubator/create-react-app/issues/2376
// Pending further investigation:
// https://github.com/mishoo/UglifyJS2/issues/2011
comparisons: false,
},
output: {
comments: false,
// Turned on because emoji and regex is not minified properly using default
// https://github.com/facebookincubator/create-react-app/issues/2488
ascii_only: true,
},
sourceMap: true,
}),
// Note: this won't work without ExtractTextPlugin.extract(..) in `loaders`.
new ExtractTextPlugin({
filename: cssFilename,