From 79caaa9c462b4cf62ac91b31a7b1724c67f93205 Mon Sep 17 00:00:00 2001 From: qiang Date: Fri, 14 Jan 2022 11:04:15 +0800 Subject: [PATCH] chore: lint --- packages/uni-cli-shared/lib/package.js | 2 +- .../__tests__/compiler-mp-weixin.spec.js | 19 ++++++++++++------- packages/vue-cli-plugin-uni/commands/build.js | 2 +- .../lib/plugin/index-new.js | 12 ++++++------ src/platforms/h5/view/components/ad/index.vue | 2 +- 5 files changed, 21 insertions(+), 16 deletions(-) diff --git a/packages/uni-cli-shared/lib/package.js b/packages/uni-cli-shared/lib/package.js index d4bc7e7b6..3a3f90916 100644 --- a/packages/uni-cli-shared/lib/package.js +++ b/packages/uni-cli-shared/lib/package.js @@ -35,7 +35,7 @@ module.exports = { if (scriptName !== name) { const define = uniAppOptions.scripts[scriptName].define Object.keys(define).forEach(name => { - if (typeof scriptOptions.define[name] !== "undefined") { + if (typeof scriptOptions.define[name] !== 'undefined') { delete define[name] } else { define[name] = false diff --git a/packages/uni-template-compiler/__tests__/compiler-mp-weixin.spec.js b/packages/uni-template-compiler/__tests__/compiler-mp-weixin.spec.js index b2a2da1d3..bb2785cec 100644 --- a/packages/uni-template-compiler/__tests__/compiler-mp-weixin.spec.js +++ b/packages/uni-template-compiler/__tests__/compiler-mp-weixin.spec.js @@ -56,33 +56,38 @@ describe('mp:compiler-mp-weixin', () => { it('generate string express with escape quote', () => { assertCodegen( - ``, + '', '', - `with(this){var a0=text+"'";$mp.data=Object.assign({},{$root:{a0:a0}})}` + 'with(this){var a0=text+"\'";$mp.data=Object.assign({},{$root:{a0:a0}})}' ) assertCodegen( + /* eslint-disable no-template-curly-in-string */ '', '', + /* eslint-disable no-template-curly-in-string */ 'with(this){var a0=`${text}\'`;$mp.data=Object.assign({},{$root:{a0:a0}})}' ) assertCodegen( - `{{text+'\\''}}`, + '{{text+\'\\\'\'}}', '{{$root.t0}}', - `with(this){var t0=text+"'";$mp.data=Object.assign({},{$root:{t0:t0}})}` + 'with(this){var t0=text+"\'";$mp.data=Object.assign({},{$root:{t0:t0}})}' ) assertCodegen( + /* eslint-disable no-template-curly-in-string */ '{{`${text}\'`}}', '{{$root.t0}}', + /* eslint-disable no-template-curly-in-string */ 'with(this){var t0=`${text}\'`;$mp.data=Object.assign({},{$root:{t0:t0}})}' ) assertCodegen( + /* eslint-disable no-template-curly-in-string */ '{{`${text}"`}}', - `{{text+'"'}}` + '{{text+\'"\'}}' ) assertCodegen( - `{{text+"\\""}}`, + '{{text+"\\""}}', '{{$root.t0}}', - `with(this){var t0=text+"\\"";$mp.data=Object.assign({},{$root:{t0:t0}})}` + 'with(this){var t0=text+"\\"";$mp.data=Object.assign({},{$root:{t0:t0}})}' ) }) diff --git a/packages/vue-cli-plugin-uni/commands/build.js b/packages/vue-cli-plugin-uni/commands/build.js index bf6695583..1dd768586 100644 --- a/packages/vue-cli-plugin-uni/commands/build.js +++ b/packages/vue-cli-plugin-uni/commands/build.js @@ -248,7 +248,7 @@ function analysisPluginDir () { process.env.UNI_MP_PLUGIN_MAIN = pluginJson.main const UNI_MP_PLUGIN_MAIN = process.env.UNI_MP_PLUGIN_MAIN const mainFilePath = path.resolve(process.env.UNI_INPUT_DIR, UNI_MP_PLUGIN_MAIN) - + if (UNI_MP_PLUGIN_MAIN && !fs.pathExistsSync(mainFilePath)) { console.log() console.error(uniI18n.__('pluginUni.entryDileNoExistsCheckAfterRetry', { diff --git a/packages/webpack-uni-mp-loader/lib/plugin/index-new.js b/packages/webpack-uni-mp-loader/lib/plugin/index-new.js index 185938399..89371203c 100644 --- a/packages/webpack-uni-mp-loader/lib/plugin/index-new.js +++ b/packages/webpack-uni-mp-loader/lib/plugin/index-new.js @@ -77,21 +77,21 @@ function addMPPluginRequire (compilation) { if (needProcess) { const modules = compilation.modules const orignalSource = compilation.assets[name].source() - const globalEnv = process.env.UNI_PLATFORM === 'mp-alipay' ? 'my' : 'wx'; + const globalEnv = process.env.UNI_PLATFORM === 'mp-alipay' ? 'my' : 'wx' const filePath = normalizePath(path.resolve(process.env.UNI_INPUT_DIR, name)) const uniModuleId = modules.find(module => module.resource && normalizePath(module.resource) === filePath).id const newlineIndex = orignalSource.lastIndexOf('\n') const source = - orignalSource.substring(0, newlineIndex) - + `\nmodule.exports = ${globalEnv}.__webpack_require_UNI_MP_PLUGIN__('${uniModuleId}');\n` - + orignalSource.substring(newlineIndex + 1) + orignalSource.substring(0, newlineIndex) + + `\nmodule.exports = ${globalEnv}.__webpack_require_UNI_MP_PLUGIN__('${uniModuleId}');\n` + + orignalSource.substring(newlineIndex + 1) compilation.assets[name] = { - size() { + size () { return Buffer.byteLength(source, 'utf8') }, - source() { + source () { return source } } diff --git a/src/platforms/h5/view/components/ad/index.vue b/src/platforms/h5/view/components/ad/index.vue index d5e54e341..ae5253eeb 100644 --- a/src/platforms/h5/view/components/ad/index.vue +++ b/src/platforms/h5/view/components/ad/index.vue @@ -545,7 +545,7 @@ export default { } }, _report (type, currentChannel) { - let reportData = { + const reportData = { h: __uniConfig.compilerVersion, a: this.adpid, at: type -- GitLab