nakarte

Source code of https://map.sikmir.ru (fork)
git clone git://git.sikmir.ru/nakarte
Log | Files | Refs | LICENSE

commit 89bbae21d12d7dc37bec228f2aac7b023ea4a11f
parent 4db1bcae4da0900b4d8fa27f6fd03fff6b58f094
Author: Sergej Orlov <wladimirych@gmail.com>
Date:   Sun,  5 Jan 2020 19:23:03 +0100

fix lint errors (no-magic-numbers)

Diffstat:
Mscripts/build.js | 14+++++++++-----
Mwebpack/webpack.config.js | 7+++++--
2 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/scripts/build.js b/scripts/build.js @@ -6,6 +6,8 @@ const filesize = require('filesize'); const chalk = require('chalk'); const path = require('path'); +const errorExitStatus = 1; + const paths = require('../webpack/paths'); function getVersionFromGit() { @@ -39,7 +41,7 @@ function getSizes(removeNameHash) { // Print a detailed summary of build files. function printFileSizes(sizeMap, previousSizeMap) { - const FIFTY_KILOBYTES = 1024 * 50; + const ASSET_DIFF_SIZE_WARNING_THRESHOLD = 50000; const assets = Object.entries(sizeMap) .map(([filename, size]) => { const difference = size - (previousSizeMap[removeFileNameHash(filename)] || 0); @@ -57,7 +59,7 @@ function printFileSizes(sizeMap, previousSizeMap) { let labelSize = sizeLabel.length; if (asset.difference !== 0) { let differenceColor; - if (asset.difference > FIFTY_KILOBYTES) { + if (asset.difference > ASSET_DIFF_SIZE_WARNING_THRESHOLD) { differenceColor = chalk.red; } else if (asset.difference > 0) { differenceColor = chalk.yellow; @@ -71,9 +73,11 @@ function printFileSizes(sizeMap, previousSizeMap) { labelSize += differenceLabel.length; differenceLabel = differenceColor(differenceLabel); differenceLabel = ` (${differenceLabel})`; - labelSize += 4; + const labelSizeAllowance = 4; + labelSize += labelSizeAllowance; } - const padding = ' '.repeat(Math.max(30 - labelSize, 0)); + const maxLabelSize = 30; + const padding = ' '.repeat(Math.max(maxLabelSize - labelSize, 0)); console.log(sizeLabel + differenceLabel + padding + chalk.dim(asset.folder + path.sep) + chalk.cyan(asset.name)); } } @@ -91,7 +95,7 @@ async function main() { {stdio: "inherit"}); } catch (e) { - process.exit(1); + process.exit(errorExitStatus); } console.log(chalk.green('Compiled successfully.')); const newSizes = await getSizes(false); diff --git a/webpack/webpack.config.js b/webpack/webpack.config.js @@ -8,6 +8,9 @@ const TerserPlugin = require('terser-webpack-plugin'); const paths = require('./paths'); +const errorExitStatus = 1; +const urlLoaderSizeLimit = 10000; + const envs = { production: true, development: true, @@ -18,7 +21,7 @@ const mode = process.env.NODE_ENV; if (!envs[mode]) { console.log(`NODE_ENV has invalid value "${mode}"`); - process.exit(1); + process.exit(errorExitStatus); } const isProduction = mode === 'production'; @@ -122,7 +125,7 @@ const loaders = [ use: { loader: 'url-loader', options: { - limit: (isProduction || isDevelopment) ? 10000 : false, + limit: (isProduction || isDevelopment) ? urlLoaderSizeLimit : false, name: '[path][name].[ext]' } }