From da397b450442051de2714ade94d40a83c46a95b9 Mon Sep 17 00:00:00 2001 From: where where Date: Mon, 3 Nov 2025 21:08:21 +0800 Subject: [PATCH] fix: fix lint --- index.js | 8 +++----- lib/css.js | 5 +++-- lib/filter.js | 18 +++++++++--------- lib/html.js | 3 ++- lib/js.js | 5 +++-- lib/json.js | 3 ++- lib/svg.js | 3 ++- lib/tools.js | 3 ++- lib/xml.js | 3 ++- lib/zlib.js | 3 ++- 10 files changed, 30 insertions(+), 24 deletions(-) diff --git a/index.js b/index.js index c90ce5b..e70e472 100644 --- a/index.js +++ b/index.js @@ -119,16 +119,14 @@ if (hexo.config.minify.enable === true && !(hexo.config.minify.previewServer === if (hexo.config.minify.css.enable === true) { if (hexo.config.minify.css.sourceMap) { hexo.extend.filter.register('after_generate', require('./lib/css').minifyCssWithMap, hexo.config.minify.js.priority) - } - else { + } else { hexo.extend.filter.register('after_render:css', require('./lib/css').minifyCss, hexo.config.minify.css.priority) } } if (hexo.config.minify.js.enable === true) { if (hexo.config.minify.js.sourceMap) { hexo.extend.filter.register('after_generate', require('./lib/js').minifyJsWithMap, hexo.config.minify.js.priority) - } - else { + } else { hexo.extend.filter.register('after_render:js', require('./lib/js').minifyJs, hexo.config.minify.js.priority) } } @@ -153,4 +151,4 @@ if (hexo.config.minify.enable === true && !(hexo.config.minify.previewServer === hexo.extend.filter.register('after_generate', zlib.zstdFn, hexo.config.minify.zstd.priority) } } -} \ No newline at end of file +} diff --git a/lib/css.js b/lib/css.js index e7a8e58..6dffe79 100644 --- a/lib/css.js +++ b/lib/css.js @@ -1,3 +1,4 @@ +/* eslint-disable space-before-function-paren */ 'use strict' const CleanCSS = require('clean-css') const { isMatch, match, logFn } = require('./tools') @@ -51,7 +52,7 @@ function minifyCssWithMap() { try { const { base, ext, name } = parse(path) const { styles, sourceMap } = await cleanCSS.minify(assetTxt) - if (verbose) logFn.call(this, assetTxt, result, path, 'css') + if (verbose) logFn.call(this, assetTxt, styles, path, 'css') route.set(path, `${styles}\n/*# sourceMappingURL=${base}.map */`) const map = sourceMap.toJSON() map.sources = [`${name}.source${ext}`] @@ -72,4 +73,4 @@ function minifyCssWithMap() { module.exports = { minifyCss, minifyCssWithMap -} \ No newline at end of file +} diff --git a/lib/filter.js b/lib/filter.js index 9cc9099..2cd0fd0 100644 --- a/lib/filter.js +++ b/lib/filter.js @@ -1,11 +1,11 @@ 'use strict' module.exports = { - ... require('./html'), - ... require('./css'), - ... require('./js'), - ... require('./svg'), - ... require('./xml'), - ... require('./json'), - ... require('./zlib'), - ... require('./zstd') -} \ No newline at end of file + ...require('./html'), + ...require('./css'), + ...require('./js'), + ...require('./svg'), + ...require('./xml'), + ...require('./json'), + ...require('./zlib'), + ...require('./zstd') +} diff --git a/lib/html.js b/lib/html.js index 863a3b0..98e4139 100644 --- a/lib/html.js +++ b/lib/html.js @@ -1,3 +1,4 @@ +/* eslint-disable space-before-function-paren */ 'use strict' const { minify: htmlMinify } = require('html-minifier-terser') const { isMatch, logFn } = require('./tools') @@ -29,4 +30,4 @@ async function minifyHtml(str, data) { module.exports = { minifyHtml -} \ No newline at end of file +} diff --git a/lib/js.js b/lib/js.js index 5bdcfa3..171e6df 100644 --- a/lib/js.js +++ b/lib/js.js @@ -1,3 +1,4 @@ +/* eslint-disable space-before-function-paren */ 'use strict' const { minify: terserMinify } = require('terser') const { isMatch, match, logFn } = require('./tools') @@ -68,7 +69,7 @@ function minifyJsWithMap() { url: `${base}.map` } const { code, map } = await terserMinify(assetTxt, { ...jsOptions }) - if (verbose) logFn.call(this, assetTxt, result, path, 'js') + if (verbose) logFn.call(this, assetTxt, code, path, 'js') route.set(path, code) map.sources = [`${name}.source${ext}`] route.set(`${path}.map`, JSON.stringify(map)) @@ -85,4 +86,4 @@ function minifyJsWithMap() { module.exports = { minifyJs, minifyJsWithMap -} \ No newline at end of file +} diff --git a/lib/json.js b/lib/json.js index 9f40e51..1957250 100644 --- a/lib/json.js +++ b/lib/json.js @@ -1,3 +1,4 @@ +/* eslint-disable space-before-function-paren */ 'use strict' const { match, logFn } = require('./tools') @@ -36,4 +37,4 @@ function minifyJson() { module.exports = { minifyJson -} \ No newline at end of file +} diff --git a/lib/svg.js b/lib/svg.js index 0cfb0e0..a3cce57 100644 --- a/lib/svg.js +++ b/lib/svg.js @@ -1,3 +1,4 @@ +/* eslint-disable space-before-function-paren */ 'use strict' const { optimize: svgOptimize } = require('svgo') const { match, logFn } = require('./tools') @@ -45,4 +46,4 @@ function minifySvg() { module.exports = { minifySvg -} \ No newline at end of file +} diff --git a/lib/tools.js b/lib/tools.js index d381d4c..761a249 100644 --- a/lib/tools.js +++ b/lib/tools.js @@ -1,3 +1,4 @@ +/* eslint-disable space-before-function-paren */ 'use strict' const micromatch = require('micromatch') @@ -69,4 +70,4 @@ module.exports = { isMatch, match, logFn -} \ No newline at end of file +} diff --git a/lib/xml.js b/lib/xml.js index 6325ed9..de63e29 100644 --- a/lib/xml.js +++ b/lib/xml.js @@ -1,3 +1,4 @@ +/* eslint-disable space-before-function-paren */ 'use strict' const { match, logFn } = require('./tools') @@ -38,4 +39,4 @@ async function minifyXml() { module.exports = { minifyXml -} \ No newline at end of file +} diff --git a/lib/zlib.js b/lib/zlib.js index 25bd1de..7551a08 100644 --- a/lib/zlib.js +++ b/lib/zlib.js @@ -1,3 +1,4 @@ +/* eslint-disable space-before-function-paren */ 'use strict' const zlib = require('zlib') const { promisify } = require('util') @@ -124,4 +125,4 @@ module.exports = { gzipFn, brotliFn, zstdFn -} \ No newline at end of file +}