提交 1c6d8ad1 编写于 作者: Q qiang

chore: lint

上级 6b05c406
......@@ -33,8 +33,8 @@ i18n.configure({
},
fallbacks: {
'en_*': 'en',
'zh': 'zh_CN',
'zh_*': 'zh_CN',
zh: 'zh_CN',
'zh_*': 'zh_CN'
}
})
......
function format (lang) {
const array = lang.split(/[\.,]/)[0].split(/[_-]/)
const array = lang.split(/[.,]/)[0].split(/[_-]/)
array[0] = array[0].toLowerCase()
if (array[0] === 'zh') {
array[1] = (array[1] || 'CN').toUpperCase()
......@@ -10,4 +10,4 @@ function format (lang) {
module.exports = {
format
}
\ No newline at end of file
}
......@@ -2,7 +2,7 @@ const { format } = require('./lang')
const { osLocale } = require('os-locale-s-fix/cjs')
function getLocale () {
return format(process.env.UNI_HBUILDERX_LANGID || osLocale.sync({ spawn: true, cache: false }) || defaultLocale)
return format(process.env.UNI_HBUILDERX_LANGID || osLocale.sync({ spawn: true, cache: false }) || 'en')
}
module.exports = {
......
......@@ -27,12 +27,12 @@ module.exports = {
}
if (!scriptOptions.env || !scriptOptions.env.UNI_PLATFORM) {
console.error(uniI18n.__('cliShared.requireConfigUniPlatform', { "0": `package.json->uni-app->scripts->${name}->env ` }))
console.error(uniI18n.__('cliShared.requireConfigUniPlatform', { 0: `package.json->uni-app->scripts->${name}->env ` }))
process.exit(0)
}
if (PLATFORMS.indexOf(scriptOptions.env.UNI_PLATFORM) === -1) {
console.error(uniI18n.__('cliShared.supportPlatform', { "0": 'UNI_PLATFORM', "1": JSON.stringify(PLATFORMS)}))
console.error(uniI18n.__('cliShared.supportPlatform', { 0: 'UNI_PLATFORM', 1: JSON.stringify(PLATFORMS) }))
process.exit(0)
}
......
......@@ -113,7 +113,7 @@ function isNVuePage (page, root = '') {
function isValidPage (page, root = '') {
if (typeof page === 'string' || !page.path) { // 不合法的配置
console.warn(uniI18n.__('cliShared.pagesJsonError', { "0": 'https://uniapp.dcloud.io/collocation/pages?id=pages' }))
console.warn(uniI18n.__('cliShared.pagesJsonError', { 0: 'https://uniapp.dcloud.io/collocation/pages?id=pages' }))
return false
}
let pagePath = page.path
......@@ -391,7 +391,7 @@ function initAutoComponents () {
})
if (conflictFiles.length > 0) {
conflictFiles.forEach(files => {
console.warn(uniI18n.__('cliShared.easycomConflict', { "0": '[' + files.map((file, index) => { return file }).join(',') + ']' }))
console.warn(uniI18n.__('cliShared.easycomConflict', { 0: '[' + files.map((file, index) => { return file }).join(',') + ']' }))
console.log('\n')
})
}
......
......@@ -25,7 +25,7 @@ function initPlugin (plugin) {
try {
pluginApi = require(path.join(plugin.id, (plugin.config.main || '/lib/uni.config.js')))
} catch (e) {
console.warn(uniI18n.__('cliShared.missingUniConfig', { "0": plugin.id }))
console.warn(uniI18n.__('cliShared.missingUniConfig', { 0: plugin.id }))
}
pluginApi && PLUGIN_KEYS.forEach(name => {
......@@ -56,7 +56,7 @@ function resolvePlugins () {
return
}
if (!config.name) {
return console.warn(uniI18n.__('cliShared.missingNameAttribute', { "0": `${id}/package.json->uni-app` }))
return console.warn(uniI18n.__('cliShared.missingNameAttribute', { 0: `${id}/package.json->uni-app` }))
}
return {
id,
......@@ -75,7 +75,7 @@ function initExtends (name, plugin, plugins) {
process.exit(0)
}
if (!plugin) {
console.error(uniI18n.__('cliShared.noFoundPlatformPlugin', { "0": extendsPlatform }))
console.error(uniI18n.__('cliShared.noFoundPlatformPlugin', { 0: extendsPlatform }))
process.exit(0)
}
const extendsPlugin = plugins.find(plugin => plugin.name === extendsPlatform)
......@@ -102,7 +102,7 @@ module.exports = {
const plugins = resolvePlugins()
const plugin = plugins.find(plugin => plugin.name === process.env.UNI_PLATFORM)
if (!plugin) {
console.error(uniI18n.__('cliShared.noFoundPlatformPlugin', { "0": process.env.UNI_PLATFORM }))
console.error(uniI18n.__('cliShared.noFoundPlatformPlugin', { 0: process.env.UNI_PLATFORM }))
process.exit(0)
}
const name = plugin.name
......
......@@ -13,7 +13,7 @@ module.exports = function migrate (input, out, options = {}) {
options.platform = options.platform || 'mp-weixin'
const migrater = migraters[options.platform]
if (!migrater) {
return console.error(uniI18n.__('migration.errorOnlySupportConvert', { "0": Object.keys(migraters).join(',') }))
return console.error(uniI18n.__('migration.errorOnlySupportConvert', { 0: Object.keys(migraters).join(',') }))
}
input = path.resolve(input)
out = path.resolve(out || input)
......
......@@ -7,7 +7,7 @@ const migraters = {
module.exports = function validate (input, out, options) {
if (!fs.existsSync(input)) {
return console.error(uniI18n.__('migration.errorInputNotExists', { "0": input }))
return console.error(uniI18n.__('migration.errorInputNotExists', { 0: input }))
}
Object.assign(options, migraters[options.platform].options)
const templateExtname = options.extname.template
......@@ -15,7 +15,7 @@ module.exports = function validate (input, out, options) {
const stat = fs.lstatSync(input)
if (stat.isFile()) {
if (path.extname(input) !== templateExtname) {
return console.error(uniI18n.__('migration.errorConvertRequireFileUrl', { "0": templateExtname.substr(1) }))
return console.error(uniI18n.__('migration.errorConvertRequireFileUrl', { 0: templateExtname.substr(1) }))
}
options.target = 'file'
} else if (stat.isDirectory()) {
......@@ -26,7 +26,7 @@ module.exports = function validate (input, out, options) {
options.target = 'folder'
}
} else {
return console.error(uniI18n.__('migration.errorCannotConvert', { "0": input }))
return console.error(uniI18n.__('migration.errorCannotConvert', { 0: input }))
}
return true
}
......@@ -107,7 +107,7 @@ module.exports = {
]
if (t.isIdentifier(value)) {
if (value.name !== key.name) {
state.errors.add(uniI18n.__('mpWeChat.slotPropNoSupportReanme', { "0": key.name, "1": value.name }))
state.errors.add(uniI18n.__('mpWeChat.slotPropNoSupportReanme', { 0: key.name, 1: value.name }))
}
} else if (t.isAssignmentPattern(value)) {
valueObjectProperties.push(t.objectProperty(t.identifier('default'), value.right))
......@@ -115,7 +115,7 @@ module.exports = {
objectProperties.push(t.objectProperty(key, t.objectExpression(valueObjectProperties)))
})
} else {
state.errors.add(uniI18n.__('mpWeChat.onlySupportDestructuringSlot', { "0": paramExprNode.name, "1": 'v-slot="{ user }"'}))
state.errors.add(uniI18n.__('mpWeChat.onlySupportDestructuringSlot', { 0: paramExprNode.name, 1: 'v-slot="{ user }"' }))
}
const jsContent = generateJsCode(genCode(t.objectExpression(objectProperties), true))
state.files[jsFile] = jsContent
......
......@@ -111,7 +111,7 @@ ${content}
return `${eventType}${eventName}` // 原生组件不支持 bind:input 等写法,统一使用 bindinput
},
createScopedSlots (slotName, props, state) {
state.errors.add(uniI18n.__('templateCompiler.notCurrentlySupportScopedSlot', { "0": `[${slotName}]` }))
state.errors.add(uniI18n.__('templateCompiler.notCurrentlySupportScopedSlot', { 0: `[${slotName}]` }))
return {
type: 'slot',
attr: {
......@@ -124,7 +124,7 @@ ${content}
traverseExpr,
normalizeChildren
}, state) {
state.errors.add(uniI18n.__('templateCompiler.notCurrentlySupportScopedSlot', { "0": `[${slotName}]` }))
state.errors.add(uniI18n.__('templateCompiler.notCurrentlySupportScopedSlot', { 0: `[${slotName}]` }))
return {
type: 'view',
attr: {
......
......@@ -133,7 +133,7 @@ module.exports = function processClass (paths, path, state) {
// )
// )
} else {
state.errors.add(':class' + uniI18n.__('templateCompiler.noSupportSyntax', { "0": getCode(classValuePath.node) }))
state.errors.add(':class' + uniI18n.__('templateCompiler.noSupportSyntax', { 0: getCode(classValuePath.node) }))
}
}
return []
......
......@@ -78,7 +78,7 @@ function addVueId (path, state) {
const scoped = scopeds[i]
forIndexSet.add(scoped.forIndex)
if (forIndexSet.size !== i + 1) {
state.errors.add(uniI18n.__('templateCompiler.forNestedIndexNameNoArrowRepeat', { "0": 'v-for', "1": scoped.forIndex }))
state.errors.add(uniI18n.__('templateCompiler.forNestedIndexNameNoArrowRepeat', { 0: 'v-for', 1: scoped.forIndex }))
break
}
}
......
......@@ -82,7 +82,7 @@ function processElement (ast, state, isRoot) {
ast.attr['vue-slots'] = '{{[' + slots.reverse().map(slotName => `'${slotName}'`).join(',') + ']}}'
}
if (ast.attr.id && ast.attr.id.indexOf('{{') === 0) {
state.tips.add(uniI18n.__('templateCompiler.idAttribNotAllowInCustomComponentProps', { "0": ast.type }))
state.tips.add(uniI18n.__('templateCompiler.idAttribNotAllowInCustomComponentProps', { 0: ast.type }))
}
if (hasOwn(ast.attr, 'data') && platformName !== 'mp-toutiao') { // 百度中会出现异常情况
// TODO 暂不输出
......
......@@ -298,7 +298,7 @@ function genSlotNode (slotName, slotNode, fallbackNodes, state) {
function traverseRenderSlot (callExprNode, state) {
if (!t.isStringLiteral(callExprNode.arguments[0])) {
state.errors.add(uniI18n.__('templateCompiler.notSupportDynamicSlotName', { "0": 'v-slot' }))
state.errors.add(uniI18n.__('templateCompiler.notSupportDynamicSlotName', { 0: 'v-slot' }))
return
}
......
......@@ -116,7 +116,7 @@ function getForKey (forKey, forIndex, state) {
} else if (t.isMemberExpression(forKey)) {
return forKey.property.name || forKey.property.value
} else {
state.tips.add(uniI18n.__('templateCompiler.noH5KeyNoSupportExpression', { "0": getCode(forKey), "1": 'https://uniapp.dcloud.io/use?id=key' }))
state.tips.add(uniI18n.__('templateCompiler.noH5KeyNoSupportExpression', { 0: getCode(forKey), 1: 'https://uniapp.dcloud.io/use?id=key' }))
}
}
return ''
......
......@@ -133,7 +133,7 @@ async function build (args, api, options) {
log()
if (!runByHBuilderX && !runByAliIde) {
logWithSpinner(uniI18n.__('pluginUni.startCompileProjectToPlatform', { "0": process.env.UNI_SUB_PLATFORM || process.env.UNI_PLATFORM, "1": process.env.UNI_MP_PLUGIN ? uniI18n.__('platform') : uniI18n.__('plugin') }))
logWithSpinner(uniI18n.__('pluginUni.startCompileProjectToPlatform', { 0: process.env.UNI_SUB_PLATFORM || process.env.UNI_PLATFORM, 1: process.env.UNI_MP_PLUGIN ? uniI18n.__('platform') : uniI18n.__('plugin') }))
}
const targetDir = api.resolve(options.outputDir)
......@@ -219,7 +219,7 @@ function analysisPluginDir () {
if (!fs.pathExistsSync(pluginJsonPath)) {
console.log()
console.error(uniI18n.__('pluginUni.fileNoExistsCheckAfterRetry', { "0": pluginJsonName }))
console.error(uniI18n.__('pluginUni.fileNoExistsCheckAfterRetry', { 0: pluginJsonName }))
console.log()
process.exit(0)
}
......@@ -233,7 +233,7 @@ function analysisPluginDir () {
if (UNI_MP_PLUGIN_MAIN && !fs.pathExistsSync(mainFilePath)) {
console.log()
console.error(uniI18n.__('pluginUni.entryDileNoExistsCheckAfterRetry', { "0": UNI_MP_PLUGIN_MAIN }))
console.error(uniI18n.__('pluginUni.entryDileNoExistsCheckAfterRetry', { 0: UNI_MP_PLUGIN_MAIN }))
console.log()
process.exit(0)
}
......
......@@ -58,7 +58,7 @@ if (process.env.UNI_CLOUD_SPACES) {
const hasUniCloudSpace = spaces.length > 0
if (spaces.length === 1) {
const space = spaces[0]
console.log(uniI18n.__('pluginUni.currentProjectDefaultSpaceId', { "0": space.id }))
console.log(uniI18n.__('pluginUni.currentProjectDefaultSpaceId', { 0: space.id }))
}
if (
......@@ -66,13 +66,13 @@ if (process.env.UNI_CLOUD_SPACES) {
isH5 &&
isProduction
) {
console.warn(uniI18n.__('pluginUni.unicloudReleaseH5', { "0": 'https://uniapp.dcloud.io/uniCloud/quickstart?id=useinh5' }))
console.warn(uniI18n.__('pluginUni.unicloudReleaseH5', { 0: 'https://uniapp.dcloud.io/uniCloud/quickstart?id=useinh5' }))
} else if (
hasUniCloudSpace &&
isH5 &&
!isProduction
) {
console.warn(uniI18n.__('pluginUni.unicloudShowedRunByHBuilderX', { "0": 'https://uniapp.dcloud.io/uniCloud/quickstart?id=useinh5' }))
console.warn(uniI18n.__('pluginUni.unicloudShowedRunByHBuilderX', { 0: 'https://uniapp.dcloud.io/uniCloud/quickstart?id=useinh5' }))
}
process.env.UNI_CLOUD_PROVIDER = JSON.stringify(spaces.map(space => {
......@@ -295,7 +295,7 @@ if (
process.env.UNI_USING_STAT = true
if (!process.UNI_STAT_CONFIG.appid && process.env.NODE_ENV === 'production') {
console.log()
console.warn(uniI18n.__('pluginUni.uniStatisticsNoAppid', { "0": 'https://ask.dcloud.net.cn/article/36303' }))
console.warn(uniI18n.__('pluginUni.uniStatisticsNoAppid', { 0: 'https://ask.dcloud.net.cn/article/36303' }))
console.log()
}
}
......@@ -321,10 +321,10 @@ const warningMsg =
const needWarning = !platformOptions.usingComponents || usingComponentsAbsent
let hasNVue = false
// 输出编译器版本等信息
const compile_mode_url = 'https://ask.dcloud.net.cn/article/36074'
const compileModeUrl = 'https://ask.dcloud.net.cn/article/36074'
if (process.env.UNI_USING_NATIVE || process.env.UNI_USING_V3_NATIVE) {
let compile_mode = (process.env.UNI_USING_V3_NATIVE ? '(v3)' : '') + '' + (isNVueCompiler ? 'uni-app' : 'weex')
console.log(uniI18n.__('pluginUni.nvueCompileModeForDetail', { "0": compile_mode, "1": compile_mode_url }))
const compileMode = (process.env.UNI_USING_V3_NATIVE ? '(v3)' : '') + '' + (isNVueCompiler ? 'uni-app' : 'weex')
console.log(uniI18n.__('pluginUni.nvueCompileModeForDetail', { 0: compileMode, 1: compileModeUrl }))
} else if (process.env.UNI_PLATFORM !== 'h5' && process.env.UNI_PLATFORM !== 'quickapp-native') {
try {
let info = ''
......@@ -346,7 +346,7 @@ if (process.env.UNI_USING_NATIVE || process.env.UNI_USING_V3_NATIVE) {
if (needWarning) {
console.log(warningMsg)
}
console.log(uniI18n.__('pluginUni.nvueCompileModeForDetail', { "0": (isNVueCompiler ? 'uni-app' : 'weex'), "1": compile_mode_url }))
console.log(uniI18n.__('pluginUni.nvueCompileModeForDetail', { 0: (isNVueCompiler ? 'uni-app' : 'weex'), 1: compileModeUrl }))
} else {
console.log(info)
if (needWarning) {
......@@ -467,7 +467,7 @@ if (
}
if (process.env.UNI_PLATFORM.startsWith('mp-')) {
console.log(uniI18n.__('pluginUni.mpBrowserKernelDifference', { "0": "https://uniapp.dcloud.io/matter?id=mp" }))
console.log(uniI18n.__('pluginUni.mpBrowserKernelDifference', { 0: 'https://uniapp.dcloud.io/matter?id=mp' }))
}
runByHBuilderX && console.log(uniI18n.__('compiling'))
......
......@@ -31,10 +31,10 @@ module.exports = function babelPluginGlobalComponent ({
}
if (callee.object.name === 'Vue' && callee.property.name === 'component') {
if (!args[0] || args[0].type !== 'StringLiteral') {
throw new Error(uniI18n.__('mpLoader.firstParameterNeedStaticString', { "0": "Vue.component()" }))
throw new Error(uniI18n.__('mpLoader.firstParameterNeedStaticString', { 0: 'Vue.component()' }))
}
if (!args[1]) {
throw new Error(uniI18n.__('mpLoader.requireTwoParameter', { "0": "Vue.component()" }))
throw new Error(uniI18n.__('mpLoader.requireTwoParameter', { 0: 'Vue.component()' }))
}
if (!metadata.globalComponents) {
metadata.globalComponents = {}
......
......@@ -65,7 +65,7 @@ module.exports = function ({
const value = prop.value.name
const source = findSource(value, path.scope.bindings)
if (!source) {
throw new Error(uniI18n.__('mpLoader.componentReferenceError', { "0": key }))
throw new Error(uniI18n.__('mpLoader.componentReferenceError', { 0: key }))
}
if (process.UNI_LIBRARIES.includes(source)) {
const componentName = hyphenate(key)
......
......@@ -24,10 +24,10 @@ module.exports = function (ast, state = {}) {
const nameNode = args[0]
const valueNode = args[1]
if (!t.isStringLiteral(nameNode)) {
throw new Error(uniI18n.__('mpLoader.firstParameterNeedStaticString', { "0": "Vue.component()" }))
throw new Error(uniI18n.__('mpLoader.firstParameterNeedStaticString', { 0: 'Vue.component()' }))
}
if (!t.isIdentifier(valueNode)) {
throw new Error(uniI18n.__('mpLoader.requireTwoParameter', { "0": "Vue.component()" }))
throw new Error(uniI18n.__('mpLoader.requireTwoParameter', { 0: 'Vue.component()' }))
}
imports.push({
name: nameNode.value,
......
......@@ -35,7 +35,7 @@ function parseComponents (names, bindings, path) {
}) => {
const importDeclaration = findImportDeclaration(value, bindings)
if (!importDeclaration) {
throw new Error(uniI18n.__('mpLoader.componentReferenceErrorOnlySupportImport', { "0": name }))
throw new Error(uniI18n.__('mpLoader.componentReferenceErrorOnlySupportImport', { 0: name }))
}
let source = importDeclaration.node.source.value
if (process.UNI_LIBRARIES && process.UNI_LIBRARIES.includes(source)) {
......
......@@ -97,7 +97,7 @@ createPage(Page)
const babelLoader = findBabelLoader(this.loaders)
if (!babelLoader) {
throw new Error(uniI18n.__('mpLoader.findFail', { "0": "babel-loader" }))
throw new Error(uniI18n.__('mpLoader.findFail', { 0: 'babel-loader' }))
} else {
addCreateApp(babelLoader)
}
......
......@@ -126,7 +126,7 @@ module.exports = function (content, map) {
const babelLoader = findBabelLoader(this.loaders)
if (!babelLoader) {
callback(new Error(uniI18n.__('mpLoader.findFail', { "0": "babel-loader" })), content)
callback(new Error(uniI18n.__('mpLoader.findFail', { 0: 'babel-loader' })), content)
} else {
addDynamicImport(babelLoader, resourcePath, dynamicImports)
......
......@@ -112,7 +112,7 @@ module.exports = function (content, map) {
if (!isAppView && jsonFile.name === 'manifest.json') {
const content = JSON.parse(jsonFile.content)
if (!content.launch_path && content.plus['uni-app'].nvueLaunchMode === 'fast') {
console.log(uniI18n.__('pagesLoader.nvueFirstPageStartModeIsFast', { "0": "https://ask.dcloud.net.cn/article/36749" }))
console.log(uniI18n.__('pagesLoader.nvueFirstPageStartModeIsFast', { 0: 'https://ask.dcloud.net.cn/article/36749' }))
}
}
if (jsonFile.name === 'define-pages.js') {
......
......@@ -42,7 +42,7 @@ const pagesJson2AppJson = {
tabBar: function (name, value, json, fromJson) {
if (value && value.list && value.list.length) {
if (value.list.length < 2) {
console.error(uniI18n.__('pagesLoader.pagesTabbarMinItem2', { "0": "tabBar.list" }))
console.error(uniI18n.__('pagesLoader.pagesTabbarMinItem2', { 0: 'tabBar.list' }))
}
const pages = json.pages
value.list.forEach((page, index) => {
......@@ -57,7 +57,7 @@ const pagesJson2AppJson = {
}) => path === (page.pagePath + '.html'))
)
) {
console.error(uniI18n.__('pagesLoader.needInPagesNode', { "0": `pages.json tabBar['list'][${index}]['pagePath'] "${page.pagePath}"` }))
console.error(uniI18n.__('pagesLoader.needInPagesNode', { 0: `pages.json tabBar['list'][${index}]['pagePath'] "${page.pagePath}"` }))
}
}
})
......
......@@ -81,22 +81,22 @@ export function chooseImage ({
// fix By Lxh 暂时添加拍照压缩逻辑,等客户端增加逻辑后修改
// 判断是否需要压缩
if (sizeType && sizeType.includes('compressed')) {
return getFileInfo(path).then(({size}) => {
return getFileInfo(path).then(({ size }) => {
// 压缩阈值 0.5 兆
const THRESHOLD = 1024 * 1024 * 0.5
return size && size > THRESHOLD
? compressImage(path).then(dstPath => successCallback([dstPath]))
:successCallback([path])
return size && size > THRESHOLD
? compressImage(path).then(dstPath => successCallback([dstPath]))
: successCallback([path])
}).catch(errorCallback)
}
return successCallback([path])
},
errorCallback, {
filename: TEMP_PATH + '/camera/',
resolution: 'high',
crop
})
errorCallback, {
filename: TEMP_PATH + '/camera/',
resolution: 'high',
crop
})
}
function openAlbum () {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册