Skip to content

Commit 4ec0d0d

Browse files
style: default prettier options
1 parent df86584 commit 4ec0d0d

29 files changed

+300
-301
lines changed

Diff for: .eslintrc.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module.exports = {
22
root: true,
3-
extends: ['@webpack-contrib/eslint-config-webpack', 'prettier'],
3+
extends: ["@webpack-contrib/eslint-config-webpack", "prettier"],
44
};

Diff for: .prettierrc.js

-1
This file was deleted.

Diff for: README.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ Then add the plugin to your `webpack` configuration. For example:
2929
**webpack.config.js**
3030

3131
```js
32-
const HtmlMinimizerPlugin = require('html-minimizer-webpack-plugin');
33-
const CopyPlugin = require('copy-webpack-plugin');
32+
const HtmlMinimizerPlugin = require("html-minimizer-webpack-plugin");
33+
const CopyPlugin = require("copy-webpack-plugin");
3434

3535
module.exports = {
3636
module: {
@@ -39,9 +39,9 @@ module.exports = {
3939
test: /\.html$/i,
4040
use: [
4141
{
42-
loader: 'file-loader',
42+
loader: "file-loader",
4343
options: {
44-
name: '[name].[ext]',
44+
name: "[name].[ext]",
4545
},
4646
},
4747
],
@@ -52,8 +52,8 @@ module.exports = {
5252
new CopyPlugin({
5353
patterns: [
5454
{
55-
context: path.resolve(__dirname, 'dist'),
56-
from: './src/*.html',
55+
context: path.resolve(__dirname, "dist"),
56+
from: "./src/*.html",
5757
},
5858
],
5959
}),
@@ -210,7 +210,7 @@ module.exports = {
210210
collapseWhitespace: true,
211211
},
212212
minify: (data, minimizerOptions) => {
213-
const htmlMinifier = require('html-minifier-terser');
213+
const htmlMinifier = require("html-minifier-terser");
214214
const [[filename, input]] = Object.entries(data);
215215

216216
return htmlMinifier.minify(input, minimizerOptions);

Diff for: babel.config.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ module.exports = (api) => {
77
return {
88
presets: [
99
[
10-
'@babel/preset-env',
10+
"@babel/preset-env",
1111
{
1212
targets: {
13-
node: '10.13.0',
13+
node: "10.13.0",
1414
},
1515
},
1616
],

Diff for: commitlint.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module.exports = {
2-
extends: ['@commitlint/config-conventional'],
2+
extends: ["@commitlint/config-conventional"],
33
};

Diff for: husky.config.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module.exports = {
22
hooks: {
3-
'pre-commit': 'lint-staged',
4-
'commit-msg': 'commitlint -E HUSKY_GIT_PARAMS',
3+
"pre-commit": "lint-staged",
4+
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
55
},
66
};

Diff for: jest.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module.exports = {
2-
testEnvironment: 'node',
2+
testEnvironment: "node",
33
};

Diff for: lint-staged.config.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module.exports = {
2-
'*.js': ['prettier --write', 'eslint --fix', 'git add'],
3-
'*.{json,md,yml,css,ts}': ['prettier --write', 'git add'],
2+
"*.js": ["eslint --fix", "prettier --write"],
3+
"*.{json,md,yml,css,ts}": ["prettier --write"],
44
};

Diff for: src/cjs.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
module.exports = require('./index').default;
1+
module.exports = require("./index").default;

Diff for: src/index.js

+18-18
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
import os from 'os';
1+
import os from "os";
22

3-
import { validate } from 'schema-utils';
4-
import serialize from 'serialize-javascript';
5-
import HtmlMinimizerPackageJson from 'html-minifier-terser/package.json';
6-
import pLimit from 'p-limit';
7-
import Worker from 'jest-worker';
3+
import { validate } from "schema-utils";
4+
import serialize from "serialize-javascript";
5+
import HtmlMinimizerPackageJson from "html-minifier-terser/package.json";
6+
import pLimit from "p-limit";
7+
import Worker from "jest-worker";
88

9-
import schema from './options.json';
9+
import schema from "./options.json";
1010

11-
import { minify as minifyFn } from './minify';
11+
import { minify as minifyFn } from "./minify";
1212

1313
class HtmlMinimizerPlugin {
1414
constructor(options = {}) {
1515
validate(schema, options, {
16-
name: 'Html Minimizer Plugin',
17-
baseDataPath: 'options',
16+
name: "Html Minimizer Plugin",
17+
baseDataPath: "options",
1818
});
1919

2020
const {
@@ -53,7 +53,7 @@ class HtmlMinimizerPlugin {
5353
}
5454

5555
async optimize(compiler, compilation, assets, optimizeOptions) {
56-
const cache = compilation.getCache('HtmlMinimizerWebpackPlugin');
56+
const cache = compilation.getCache("HtmlMinimizerWebpackPlugin");
5757
let numberOfAssetsForMinify = 0;
5858
const assetsForMinify = await Promise.all(
5959
Object.keys(assets)
@@ -108,7 +108,7 @@ class HtmlMinimizerPlugin {
108108
return initializedWorker;
109109
}
110110

111-
initializedWorker = new Worker(require.resolve('./minify'), {
111+
initializedWorker = new Worker(require.resolve("./minify"), {
112112
numWorkers: numberOfWorkers,
113113
enableWorkerThreads: true,
114114
});
@@ -117,15 +117,15 @@ class HtmlMinimizerPlugin {
117117
const workerStdout = initializedWorker.getStdout();
118118

119119
if (workerStdout) {
120-
workerStdout.on('data', (chunk) => {
120+
workerStdout.on("data", (chunk) => {
121121
return process.stdout.write(chunk);
122122
});
123123
}
124124

125125
const workerStderr = initializedWorker.getStderr();
126126

127127
if (workerStderr) {
128-
workerStderr.on('data', (chunk) => {
128+
workerStderr.on("data", (chunk) => {
129129
return process.stderr.write(chunk);
130130
});
131131
}
@@ -216,7 +216,7 @@ class HtmlMinimizerPlugin {
216216
});
217217

218218
hooks.chunkHash.tap(pluginName, (chunk, hash) => {
219-
hash.update('HtmlMinimizerPlugin');
219+
hash.update("HtmlMinimizerPlugin");
220220
hash.update(data);
221221
});
222222

@@ -234,12 +234,12 @@ class HtmlMinimizerPlugin {
234234

235235
compilation.hooks.statsPrinter.tap(pluginName, (stats) => {
236236
stats.hooks.print
237-
.for('asset.info.minimized')
237+
.for("asset.info.minimized")
238238
.tap(
239-
'html-minimizer-webpack-plugin',
239+
"html-minimizer-webpack-plugin",
240240
(minimized, { green, formatFlag }) =>
241241
// eslint-disable-next-line no-undefined
242-
minimized ? green(formatFlag('minimized')) : undefined
242+
minimized ? green(formatFlag("minimized")) : undefined
243243
);
244244
});
245245
});

Diff for: src/minify.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const htmlMinifier = require('html-minifier-terser');
1+
const htmlMinifier = require("html-minifier-terser");
22

33
const defaultMinimizerOptions = {
44
caseSensitive: true,
@@ -45,11 +45,11 @@ async function transform(options) {
4545
// Safer for possible security issues, albeit not critical at all here
4646
// eslint-disable-next-line no-new-func, no-param-reassign
4747
options = new Function(
48-
'exports',
49-
'require',
50-
'module',
51-
'__filename',
52-
'__dirname',
48+
"exports",
49+
"require",
50+
"module",
51+
"__filename",
52+
"__dirname",
5353
`'use strict'\nreturn ${options}`
5454
)(exports, require, module, __filename, __dirname);
5555

0 commit comments

Comments
 (0)