commit 16b0c750c7e4609b1bab2e2b29e23609f090e0ef
parent eb616f733f42079fdc23ade87c5f1c77de3c561d
Author: Sergej Orlov <wladimirych@gmail.com>
Date: Sat, 25 Jan 2020 12:23:34 +0100
fix lint errors (prettier)
Diffstat:
7 files changed, 97 insertions(+), 102 deletions(-)
diff --git a/myEslintBrowserRules.js b/myEslintBrowserRules.js
@@ -1,7 +1,7 @@
-"use strict";
+'use strict';
module.exports = {
- extends: ["./myEslintRules.js"],
+ extends: ['./myEslintRules.js'],
rules: {
- "no-console": "error"
- }
+ 'no-console': 'error',
+ },
};
diff --git a/myEslintRules.js b/myEslintRules.js
@@ -1,4 +1,4 @@
-"use strict";
+'use strict';
module.exports = {
extends: ['eslint:recommended'],
diff --git a/scripts/build.js b/scripts/build.js
@@ -1,4 +1,4 @@
-"use strict";
+'use strict';
const recursive = require('recursive-readdir');
const fs = require('fs-extra');
@@ -13,22 +13,22 @@ const errorExitStatus = 1;
const paths = require('../webpack/paths');
function getVersionFromGit() {
- const verCmd = "echo -n `date +%Y-%m-%d_%H:%M:%S`-`git rev-parse --abbrev-ref HEAD`-`git rev-parse --short HEAD``git diff-index --quiet HEAD -- || echo '-dirty'`";
+ const verCmd =
+ "echo -n `date +%Y-%m-%d_%H:%M:%S`-`git rev-parse --abbrev-ref HEAD`-`git rev-parse --short HEAD``git diff-index --quiet HEAD -- || echo '-dirty'`";
return execSync(verCmd).toString();
}
// Input: /User/dan/app/build/static/js/main.82be8.js
// Output: /static/js/main.js
function removeFileNameHash(fileName) {
- return fileName
- .replace(/\/?(.*)(\.[0-9a-f]+)(\.js|\.css)/u, (match, p1, p2, p3) => p1 + p3);
+ return fileName.replace(/\/?(.*)(\.[0-9a-f]+)(\.js|\.css)/u, (match, p1, p2, p3) => p1 + p3);
}
function getSizes(removeNameHash) {
return new Promise((resolve) => {
recursive(paths.appBuild, (err, fileNames) => {
const previousSizeMap = (fileNames || [])
- .filter(fileName => /\.(js|css)$/u.test(fileName))
+ .filter((fileName) => /\.(js|css)$/u.test(fileName))
.reduce((memo, fileName) => {
const contents = fs.readFileSync(fileName);
const relativeFileName = fileName.replace(paths.appBuild + '/', '');
@@ -44,16 +44,15 @@ function getSizes(removeNameHash) {
// Print a detailed summary of build files.
function printFileSizes(sizeMap, previousSizeMap) {
const ASSET_DIFF_SIZE_WARNING_THRESHOLD = 50000;
- const assets = Object.entries(sizeMap)
- .map(([filename, size]) => {
- const difference = size - (previousSizeMap[removeFileNameHash(filename)] || 0);
- return {
- folder: path.join('build', path.dirname(filename)),
- name: path.basename(filename),
- size: size,
- difference: difference,
- };
- });
+ const assets = Object.entries(sizeMap).map(([filename, size]) => {
+ const difference = size - (previousSizeMap[removeFileNameHash(filename)] || 0);
+ return {
+ folder: path.join('build', path.dirname(filename)),
+ name: path.basename(filename),
+ size: size,
+ difference: difference,
+ };
+ });
assets.sort((a, b) => b.size - a.size);
for (let asset of assets) {
let sizeLabel = ' ' + filesize(asset.size);
@@ -80,11 +79,12 @@ function printFileSizes(sizeMap, previousSizeMap) {
}
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));
+ console.log(
+ sizeLabel + differenceLabel + padding + chalk.dim(asset.folder + path.sep) + chalk.cyan(asset.name)
+ );
}
}
-
async function main() {
process.env.NODE_ENV = 'production';
const version = getVersionFromGit();
@@ -93,8 +93,9 @@ async function main() {
console.log('Version:', version);
const prevSizes = await getSizes(true);
try {
- execSync("webpack --config webpack/webpack.config.js --colors --profile --progress",
- {stdio: "inherit"});
+ execSync('webpack --config webpack/webpack.config.js --colors --profile --progress', {
+ stdio: 'inherit',
+ });
} catch (e) {
process.exit(errorExitStatus);
}
diff --git a/test/karma.conf.js b/test/karma.conf.js
@@ -1,4 +1,4 @@
-"use strict";
+'use strict';
const webpackConfig = require('../webpack/webpack.config');
@@ -6,9 +6,7 @@ module.exports = function(config) {
config.set({
basePath: '../',
frameworks: ['mocha', 'chai'],
- files: [
- { pattern: './test/**/*.js'},
- ],
+ files: [{pattern: './test/**/*.js'}],
preprocessors: {
'./test/**/*.js': ['webpack'],
},
@@ -17,7 +15,7 @@ module.exports = function(config) {
stats: 'errors-only',
},
reporters: ['mocha'],
- port: 9876, // karma web server port
+ port: 9876, // karma web server port
colors: true,
logLevel: config.LOG_INFO,
client: {
@@ -29,5 +27,5 @@ module.exports = function(config) {
mochaReporter: {
showDiff: true,
},
- });
+ });
};
diff --git a/test/test_layers.js b/test/test_layers.js
@@ -121,5 +121,4 @@ test('Order contains markers for custom layers in right order', function() {
const customTopOrder = titlesByOrder.indexOf('#custom-top');
const customBottomOrder = titlesByOrder.indexOf('#custom-bottom');
assert.isAbove(customTopOrder, customBottomOrder);
-
});
diff --git a/webpack/paths.js b/webpack/paths.js
@@ -1,16 +1,16 @@
-"use strict";
+'use strict';
const path = require('path');
function resolveApp(relativePath) {
- return path.resolve(__dirname, '..', relativePath);
+ return path.resolve(__dirname, '..', relativePath);
}
// config after eject: we're in ./config/
module.exports = {
- appBuild: resolveApp('build'),
- appPublic: resolveApp('public'),
- appIndexJs: resolveApp('src/index.js'),
- appIndexHtml: resolveApp('src/index.html'),
- appSrc: resolveApp('src'),
+ appBuild: resolveApp('build'),
+ appPublic: resolveApp('public'),
+ appIndexJs: resolveApp('src/index.js'),
+ appIndexHtml: resolveApp('src/index.html'),
+ appSrc: resolveApp('src'),
};
diff --git a/webpack/webpack.config.js b/webpack/webpack.config.js
@@ -1,4 +1,4 @@
-"use strict";
+'use strict';
const Webpack = require('webpack');
const {CleanWebpackPlugin} = require('clean-webpack-plugin');
@@ -36,27 +36,24 @@ const productionOutput = {
};
const babelConfig = {
- "presets": [
+ presets: [
[
- "@babel/preset-env",
+ '@babel/preset-env',
{
- "useBuiltIns": "usage",
- "corejs": "3.0.0",
- "modules": "commonjs",
+ useBuiltIns: 'usage',
+ corejs: '3.0.0',
+ modules: 'commonjs',
},
],
],
- "overrides": [
+ overrides: [
{
- "test": "./src/vendored/github.com/augustl/js-unzip/js-unzip.js",
- "sourceType": "script",
+ test: './src/vendored/github.com/augustl/js-unzip/js-unzip.js',
+ sourceType: 'script',
},
],
- "plugins": [
- "@babel/plugin-syntax-dynamic-import",
- "@babel/plugin-proposal-class-properties",
- ],
+ plugins: ['@babel/plugin-syntax-dynamic-import', '@babel/plugin-proposal-class-properties'],
};
const sourceMapOption = {
@@ -69,29 +66,32 @@ const devToolPlugin = isProduction ? Webpack.SourceMapDevToolPlugin : Webpack.Ev
const plugins = [
...(isProduction ? [new CleanWebpackPlugin()] : []),
- ...(isProduction ? [new CopyWebpackPlugin([
- { from: paths.appPublic, to: '' },
- ])] : []),
+ ...(isProduction ? [new CopyWebpackPlugin([{from: paths.appPublic, to: ''}])] : []),
new HtmlWebpackPlugin({
template: paths.appIndexHtml,
minify: false,
}),
- ...((isProduction || isDevelopment) ? [new MiniCssExtractPlugin({
- filename: 'static/css/[name].[contenthash:8].css',
- })] : []),
+ ...(isProduction || isDevelopment
+ ? [
+ new MiniCssExtractPlugin({
+ filename: 'static/css/[name].[contenthash:8].css',
+ }),
+ ]
+ : []),
new Webpack.DefinePlugin({
- 'NODE_ENV': JSON.stringify(mode),
- 'RELEASE_VER': JSON.stringify(process.env.RELEASE_VER || 'local devel'),
+ NODE_ENV: JSON.stringify(mode),
+ RELEASE_VER: JSON.stringify(process.env.RELEASE_VER || 'local devel'),
}),
- ...(isProduction || isDevelopment) ? [new StyleLintPlugin({
- config: {"extends": "stylelint-config-recommended"},
- files: [
- 'src/**/*.css',
- 'vendored/**/*.css',
- ],
- emitWarning: isDevelopment,
- emitError: isProduction,
- })] : [],
+ ...(isProduction || isDevelopment
+ ? [
+ new StyleLintPlugin({
+ config: {extends: 'stylelint-config-recommended'},
+ files: ['src/**/*.css', 'vendored/**/*.css'],
+ emitWarning: isDevelopment,
+ emitError: isProduction,
+ }),
+ ]
+ : []),
new devToolPlugin(sourceMapOption),
];
@@ -102,19 +102,12 @@ const productionCSSLoader = [
loader: 'postcss-loader',
options: {
ident: 'postcss',
- plugins: () => [
- require('postcss-import')(),
- require('postcss-preset-env')(),
- require('cssnano')(),
- ],
+ plugins: () => [require('postcss-import')(), require('postcss-preset-env')(), require('cssnano')()],
},
},
];
-const developmentCSSLoader = [
- 'style-loader',
- {loader: 'css-loader', options: {importLoaders: 1}},
-];
+const developmentCSSLoader = ['style-loader', {loader: 'css-loader', options: {importLoaders: 1}}];
const loaders = [
{
@@ -127,7 +120,7 @@ const loaders = [
use: {
loader: 'url-loader',
options: {
- limit: (isProduction || isDevelopment) ? urlLoaderSizeLimit : false,
+ limit: isProduction || isDevelopment ? urlLoaderSizeLimit : false,
name: '[path][name].[ext]',
},
},
@@ -137,22 +130,23 @@ const loaders = [
loader: 'raw-loader',
},
- ...((isProduction || isDevelopment) ? [{
- test: /\.js$/u,
- include: paths.appSrc,
- enforce: 'pre',
- loader: 'eslint-loader',
- options: {
- emitWarning: !isProduction,
- },
- }] : []),
+ ...(isProduction || isDevelopment
+ ? [
+ {
+ test: /\.js$/u,
+ include: paths.appSrc,
+ enforce: 'pre',
+ loader: 'eslint-loader',
+ options: {
+ emitWarning: !isProduction,
+ },
+ },
+ ]
+ : []),
{
test: /\.js$/u,
- exclude: isProduction ? [
- /node_modules\/core-js/u,
- /node_modules\/webpack/u,
- ] : /node_modules/u,
+ exclude: isProduction ? [/node_modules\/core-js/u, /node_modules\/webpack/u] : /node_modules/u,
loaders: [
{
loader: 'babel-loader',
@@ -163,7 +157,7 @@ const loaders = [
{
test: /\.s?css/iu,
- loaders : isProduction ? productionCSSLoader : developmentCSSLoader,
+ loaders: isProduction ? productionCSSLoader : developmentCSSLoader,
},
];
@@ -173,9 +167,11 @@ module.exports = {
stats: 'errors-warnings',
bail: isProduction || isTesting,
- entry: isTesting ? false : {
- app: paths.appIndexJs,
- },
+ entry: isTesting
+ ? false
+ : {
+ app: paths.appIndexJs,
+ },
optimization: {
splitChunks: {
@@ -183,13 +179,14 @@ module.exports = {
name: true,
},
runtimeChunk: 'single',
- minimizer: [new TerserPlugin({
- cache: true,
- parallel: true,
- sourceMap: true,
- exclude: /mapillary/u,
- })],
-
+ minimizer: [
+ new TerserPlugin({
+ cache: true,
+ parallel: true,
+ sourceMap: true,
+ exclude: /mapillary/u,
+ }),
+ ],
},
resolve: {