提交 79caaa9c 编写于 作者: Q qiang

chore: lint

上级 c25fc1ca
...@@ -35,7 +35,7 @@ module.exports = { ...@@ -35,7 +35,7 @@ module.exports = {
if (scriptName !== name) { if (scriptName !== name) {
const define = uniAppOptions.scripts[scriptName].define const define = uniAppOptions.scripts[scriptName].define
Object.keys(define).forEach(name => { Object.keys(define).forEach(name => {
if (typeof scriptOptions.define[name] !== "undefined") { if (typeof scriptOptions.define[name] !== 'undefined') {
delete define[name] delete define[name]
} else { } else {
define[name] = false define[name] = false
......
...@@ -56,33 +56,38 @@ describe('mp:compiler-mp-weixin', () => { ...@@ -56,33 +56,38 @@ describe('mp:compiler-mp-weixin', () => {
it('generate string express with escape quote', () => { it('generate string express with escape quote', () => {
assertCodegen( assertCodegen(
`<view :data-text="text+'\\''"></view>`, '<view :data-text="text+\'\\\'\'"></view>',
'<view data-text="{{$root.a0}}"></view>', '<view data-text="{{$root.a0}}"></view>',
`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( assertCodegen(
/* eslint-disable no-template-curly-in-string */
'<view :data-text="`${text}\'`"></view>', '<view :data-text="`${text}\'`"></view>',
'<view data-text="{{$root.a0}}"></view>', '<view data-text="{{$root.a0}}"></view>',
/* eslint-disable no-template-curly-in-string */
'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( assertCodegen(
`<view>{{text+'\\''}}</view>`, '<view>{{text+\'\\\'\'}}</view>',
'<view>{{$root.t0}}</view>', '<view>{{$root.t0}}</view>',
`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( assertCodegen(
/* eslint-disable no-template-curly-in-string */
'<view>{{`${text}\'`}}</view>', '<view>{{`${text}\'`}}</view>',
'<view>{{$root.t0}}</view>', '<view>{{$root.t0}}</view>',
/* eslint-disable no-template-curly-in-string */
'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( assertCodegen(
/* eslint-disable no-template-curly-in-string */
'<view>{{`${text}"`}}</view>', '<view>{{`${text}"`}}</view>',
`<view>{{text+'"'}}</view>` '<view>{{text+\'"\'}}</view>'
) )
assertCodegen( assertCodegen(
`<view>{{text+"\\""}}</view>`, '<view>{{text+"\\""}}</view>',
'<view>{{$root.t0}}</view>', '<view>{{$root.t0}}</view>',
`with(this){var t0=text+"\\"";$mp.data=Object.assign({},{$root:{t0:t0}})}` 'with(this){var t0=text+"\\"";$mp.data=Object.assign({},{$root:{t0:t0}})}'
) )
}) })
......
...@@ -248,7 +248,7 @@ function analysisPluginDir () { ...@@ -248,7 +248,7 @@ function analysisPluginDir () {
process.env.UNI_MP_PLUGIN_MAIN = pluginJson.main process.env.UNI_MP_PLUGIN_MAIN = pluginJson.main
const UNI_MP_PLUGIN_MAIN = process.env.UNI_MP_PLUGIN_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) const mainFilePath = path.resolve(process.env.UNI_INPUT_DIR, UNI_MP_PLUGIN_MAIN)
if (UNI_MP_PLUGIN_MAIN && !fs.pathExistsSync(mainFilePath)) { if (UNI_MP_PLUGIN_MAIN && !fs.pathExistsSync(mainFilePath)) {
console.log() console.log()
console.error(uniI18n.__('pluginUni.entryDileNoExistsCheckAfterRetry', { console.error(uniI18n.__('pluginUni.entryDileNoExistsCheckAfterRetry', {
......
...@@ -77,21 +77,21 @@ function addMPPluginRequire (compilation) { ...@@ -77,21 +77,21 @@ function addMPPluginRequire (compilation) {
if (needProcess) { if (needProcess) {
const modules = compilation.modules const modules = compilation.modules
const orignalSource = compilation.assets[name].source() 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 filePath = normalizePath(path.resolve(process.env.UNI_INPUT_DIR, name))
const uniModuleId = modules.find(module => module.resource && normalizePath(module.resource) === filePath).id const uniModuleId = modules.find(module => module.resource && normalizePath(module.resource) === filePath).id
const newlineIndex = orignalSource.lastIndexOf('\n') const newlineIndex = orignalSource.lastIndexOf('\n')
const source = const source =
orignalSource.substring(0, newlineIndex) orignalSource.substring(0, newlineIndex) +
+ `\nmodule.exports = ${globalEnv}.__webpack_require_UNI_MP_PLUGIN__('${uniModuleId}');\n` `\nmodule.exports = ${globalEnv}.__webpack_require_UNI_MP_PLUGIN__('${uniModuleId}');\n` +
+ orignalSource.substring(newlineIndex + 1) orignalSource.substring(newlineIndex + 1)
compilation.assets[name] = { compilation.assets[name] = {
size() { size () {
return Buffer.byteLength(source, 'utf8') return Buffer.byteLength(source, 'utf8')
}, },
source() { source () {
return source return source
} }
} }
......
...@@ -545,7 +545,7 @@ export default { ...@@ -545,7 +545,7 @@ export default {
} }
}, },
_report (type, currentChannel) { _report (type, currentChannel) {
let reportData = { const reportData = {
h: __uniConfig.compilerVersion, h: __uniConfig.compilerVersion,
a: this.adpid, a: this.adpid,
at: type at: type
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册