From d73fbc8cfa502930c2e684e014fdcd3248070fec Mon Sep 17 00:00:00 2001 From: qiang Date: Mon, 8 Aug 2022 15:04:10 +0800 Subject: [PATCH] chore: lint --- .../build/webpack.nvue.conf.js | 2 +- packages/vue-cli-plugin-uni/commands/build.js | 4 +- packages/vue-cli-plugin-uni/commands/serve.js | 80 +++++++++---------- .../vue-cli-plugin-uni/lib/app-plus/index.js | 2 +- .../lib/configure-webpack.js | 26 +++--- .../lib/h5/cssnano-options.js | 4 +- 6 files changed, 59 insertions(+), 59 deletions(-) diff --git a/packages/vue-cli-plugin-hbuilderx/build/webpack.nvue.conf.js b/packages/vue-cli-plugin-hbuilderx/build/webpack.nvue.conf.js index d6d01474d2..4415d1182f 100644 --- a/packages/vue-cli-plugin-hbuilderx/build/webpack.nvue.conf.js +++ b/packages/vue-cli-plugin-hbuilderx/build/webpack.nvue.conf.js @@ -135,7 +135,7 @@ const rules = [{ babelrc: false } }, - jsPreprocessorLoader + jsPreprocessorLoader ] // exclude (modulePath) { // nvue js均提供babel,否则还得提供transpileDependencies配置 // return excludeModuleReg.test(modulePath) && modulePath.indexOf('@dcloudio') === -1 diff --git a/packages/vue-cli-plugin-uni/commands/build.js b/packages/vue-cli-plugin-uni/commands/build.js index 9744264cfe..0b64298d0b 100644 --- a/packages/vue-cli-plugin-uni/commands/build.js +++ b/packages/vue-cli-plugin-uni/commands/build.js @@ -100,7 +100,7 @@ function getWebpackConfig (api, args, options) { modifyConfig(webpackConfig, config => { config.optimization.minimize = true if (webpack.version[0] <= 4) { - config.optimization.namedModules = false + config.optimization.namedModules = false } }) } else { @@ -109,7 +109,7 @@ function getWebpackConfig (api, args, options) { config.optimization = {} } if (webpack.version[0] <= 4) { - config.optimization.namedModules = false + config.optimization.namedModules = false } }) } diff --git a/packages/vue-cli-plugin-uni/commands/serve.js b/packages/vue-cli-plugin-uni/commands/serve.js index b2d04db4a9..7bd7f4b14e 100644 --- a/packages/vue-cli-plugin-uni/commands/serve.js +++ b/packages/vue-cli-plugin-uni/commands/serve.js @@ -172,8 +172,8 @@ module.exports = (api, options) => { // launch editor support. // this works with vue-devtools & @vue/cli-overlay devServer.app.use('/__open-in-editor', launchEditorMiddleware(() => console.log( - `To specify an editor, specify the EDITOR env variable or ` + - `add "editor" field to your Vue project config.\n` + 'To specify an editor, specify the EDITOR env variable or ' + + 'add "editor" field to your Vue project config.\n' ))) // allow other plugins to register middlewares, e.g. PWA @@ -189,42 +189,42 @@ module.exports = (api, options) => { }), compiler) } else { server = new WebpackDevServer(compiler, Object.assign({ - clientLogLevel: 'none', - historyApiFallback: { - disableDotRule: true, - rewrites: [{ - from: /./, - to: path.posix.join(options.publicPath, 'index.html') - }] - }, - contentBase: api.resolve('public'), - watchContentBase: !isProduction, - hot: !isProduction, - quiet: true, - compress: isProduction, - publicPath: options.publicPath, - overlay: isProduction // TODO disable this - ? false : { - warnings: false, - errors: true - } - }, projectDevServerOptions, { - https: useHttps, - proxy: proxySettings, - before (app, server) { + clientLogLevel: 'none', + historyApiFallback: { + disableDotRule: true, + rewrites: [{ + from: /./, + to: path.posix.join(options.publicPath, 'index.html') + }] + }, + contentBase: api.resolve('public'), + watchContentBase: !isProduction, + hot: !isProduction, + quiet: true, + compress: isProduction, + publicPath: options.publicPath, + overlay: isProduction // TODO disable this + ? false : { + warnings: false, + errors: true + } + }, projectDevServerOptions, { + https: useHttps, + proxy: proxySettings, + before (app, server) { // launch editor support. // this works with vue-devtools & @vue/cli-overlay - app.use('/__open-in-editor', launchEditorMiddleware(() => console.log( - 'To specify an editor, sepcify the EDITOR env variable or ' + + app.use('/__open-in-editor', launchEditorMiddleware(() => console.log( + 'To specify an editor, sepcify the EDITOR env variable or ' + 'add "editor" field to your Vue project config.\n' - ))) - // allow other plugins to register middlewares, e.g. PWA - api.service.devServerConfigFns.forEach(fn => fn(app, server)) - // apply in project middlewares - projectDevServerOptions.before && projectDevServerOptions.before(app, - server) - } - })) + ))) + // allow other plugins to register middlewares, e.g. PWA + api.service.devServerConfigFns.forEach(fn => fn(app, server)) + // apply in project middlewares + projectDevServerOptions.before && projectDevServerOptions.before(app, + server) + } + })) } ; @@ -356,11 +356,11 @@ module.exports = (api, options) => { if (webpack.version[0] > 4) { server.start().catch(err => reject(err)) } else { - server.listen(port, host, err => { - if (err) { - reject(err) - } - }) + server.listen(port, host, err => { + if (err) { + reject(err) + } + }) } }) }) diff --git a/packages/vue-cli-plugin-uni/lib/app-plus/index.js b/packages/vue-cli-plugin-uni/lib/app-plus/index.js index 11224fcb5d..88935bb52d 100644 --- a/packages/vue-cli-plugin-uni/lib/app-plus/index.js +++ b/packages/vue-cli-plugin-uni/lib/app-plus/index.js @@ -139,7 +139,7 @@ const v3 = { filename: '[name].js', chunkFilename: '[id].js', // webpack5 use strict - globalObject: webpack.version[0] > 4 ? `(new Function("return this")())` : 'this' + globalObject: webpack.version[0] > 4 ? '(new Function("return this")())' : 'this' }, performance: { hints: false diff --git a/packages/vue-cli-plugin-uni/lib/configure-webpack.js b/packages/vue-cli-plugin-uni/lib/configure-webpack.js index f5e0784ba6..4011c1193e 100644 --- a/packages/vue-cli-plugin-uni/lib/configure-webpack.js +++ b/packages/vue-cli-plugin-uni/lib/configure-webpack.js @@ -70,15 +70,15 @@ module.exports = function configureWebpack (platformOptions, manifestPlatformOpt return rules.length > 0 && rule.use } else { const RuleSet = require('webpack/lib/RuleSet') - const normalized = RuleSet.normalizeRule(clone, {}, '') - return ( - !rule.enforce && + const normalized = RuleSet.normalizeRule(clone, {}, '') + return ( + !rule.enforce && normalized.resource && normalized.resource(fakeFile) - ) + ) + } } } - } function updateJsLoader (rawRules, fakeFile, checkLoaderRegex, loader) { const matchRule = rawRules.find(createMatcher(fakeFile)) @@ -185,18 +185,18 @@ module.exports = function configureWebpack (platformOptions, manifestPlatformOpt if (uses.find(use => babelLoaderRe.test(use.loader))) { const index = uses.findIndex(use => cacheLoaderRe.test(use.loader)) if (index >= 0) { - if (process.env.UNI_USING_CACHE) { - Object.assign(uses[index].options, api.genCacheConfig( - 'babel-loader/' + process.env.UNI_PLATFORM, - getPartialIdentifier() - )) - } else { - uses.splice(index, 1) + if (process.env.UNI_USING_CACHE) { + Object.assign(uses[index].options, api.genCacheConfig( + 'babel-loader/' + process.env.UNI_PLATFORM, + getPartialIdentifier() + )) + } else { + uses.splice(index, 1) + } } } } } - } // js preprocess updateJsLoader(rawRules, 'foo.js', babelLoaderRe, { diff --git a/packages/vue-cli-plugin-uni/lib/h5/cssnano-options.js b/packages/vue-cli-plugin-uni/lib/h5/cssnano-options.js index 8a783f9ae5..3324d8c8a6 100644 --- a/packages/vue-cli-plugin-uni/lib/h5/cssnano-options.js +++ b/packages/vue-cli-plugin-uni/lib/h5/cssnano-options.js @@ -11,8 +11,8 @@ module.exports = function initCssnanoOptions (webpackConfig) { } const plugins = [require('cssnano')({ - preset: ['default', getPlatformCssnano()] - })] + preset: ['default', getPlatformCssnano()] + })] // TODO postcss-loader version > 4 if (webpack.version[0] > 4) { -- GitLab