diff --git a/.eslintrc.js b/.eslintrc.js
index 2adc439e07cf..f1d2fdb008d4 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -5,8 +5,7 @@ module.exports = {
'import',
'jest',
'react',
- 'simple-import-sort',
- 'prettier'
+ 'simple-import-sort'
],
extends: [
'eslint:recommended',
@@ -14,7 +13,6 @@ module.exports = {
'plugin:@typescript-eslint/recommended',
'plugin:react/jsx-runtime',
'plugin:react/recommended',
- 'prettier'
],
rules: {
'@typescript-eslint/ban-ts-comment': 0,
@@ -31,6 +29,10 @@ module.exports = {
'@typescript-eslint/no-use-before-define': [1, { functions: false, classes: false }],
'@typescript-eslint/no-var-requires': 0,
camelcase: 0,
+ 'eol-last': 0,
+ 'comma-dangle': 0,
+ 'no-mixed-operators': 1,
+ 'no-multiple-empty-lines': 0,
'import/first': 2,
'import/newline-after-import': 2,
'import/no-duplicates': 2,
diff --git a/.vscode/settings.json b/.vscode/settings.json
index 40629da47a9c..14c42a2afc83 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -1,16 +1,4 @@
{
- "eslint.validate": [
- "javascript",
- "javascriptreact",
- {
- "language": "typescript",
- "autoFix": true
- },
- {
- "language": "typescriptreact",
- "autoFix": true
- }
- ],
"search.exclude": {
"**/.git": true,
"**/node_modules": true,
diff --git a/examples/mini-program-example/src/app.config.ts b/examples/mini-program-example/src/app.config.ts
index abbc20fbd38b..847d1653cc36 100644
--- a/examples/mini-program-example/src/app.config.ts
+++ b/examples/mini-program-example/src/app.config.ts
@@ -51,7 +51,7 @@ export default defineAppConfig({
'pages/api/alipay/index',
'pages/api/analysis/index',
'pages/api/basics/basics/index',
- 'pages/api/basics/debug/index',
+ 'pages/api/basics/nativeDebug/index',
'pages/api/basics/encryption/index',
'pages/api/basics/miniProgram/index',
'pages/api/basics/performance/index',
diff --git a/examples/mini-program-example/src/pages/api/basics/nativeDebug/index.config.ts b/examples/mini-program-example/src/pages/api/basics/nativeDebug/index.config.ts
new file mode 100644
index 000000000000..f5713a15e54f
--- /dev/null
+++ b/examples/mini-program-example/src/pages/api/basics/nativeDebug/index.config.ts
@@ -0,0 +1,3 @@
+export default {
+ navigationBarTitleText: '基础-调试',
+}
diff --git a/examples/mini-program-example/src/pages/api/basics/nativeDebug/index.scss b/examples/mini-program-example/src/pages/api/basics/nativeDebug/index.scss
new file mode 100644
index 000000000000..c1d9171bb8b6
--- /dev/null
+++ b/examples/mini-program-example/src/pages/api/basics/nativeDebug/index.scss
@@ -0,0 +1,6 @@
+@import "@/styles/variables.scss";
+
+.test-style {
+ color: #f5f5f5;
+ background-color: $color-success;
+}
diff --git a/examples/mini-program-example/src/pages/api/basics/nativeDebug/index.tsx b/examples/mini-program-example/src/pages/api/basics/nativeDebug/index.tsx
new file mode 100644
index 000000000000..8c97ca2fb836
--- /dev/null
+++ b/examples/mini-program-example/src/pages/api/basics/nativeDebug/index.tsx
@@ -0,0 +1,146 @@
+import React from 'react'
+import Taro from '@tarojs/taro'
+import { View, Text } from '@tarojs/components'
+import ButtonList from '@/components/buttonList'
+import './index.scss'
+import { TestConsole } from '@/util/util'
+
+/**
+ * 基础-调试
+ * @returns
+ */
+let realtimeLogManager
+let logManager
+export default class Index extends React.Component {
+ state = {
+ list: [
+ {
+ id: 'setEnableDebug',
+ func: () => {
+ TestConsole.consoleTest('setEnableDebug')
+ Taro.setEnableDebug({
+ enableDebug: true,
+ success(res) {
+ TestConsole.consoleSuccess(res)
+ },
+ fail(res) {
+ TestConsole.consoleFail(res)
+ },
+ complete(res) {
+ TestConsole.consoleComplete(res)
+ },
+ }).then((res) => {
+ TestConsole.consoleResult(res)
+ })
+ },
+ },
+ {
+ id: 'getRealtimeLogManager',
+ func: () => {
+ realtimeLogManager = Taro.getRealtimeLogManager()
+ TestConsole.consoleNormal('setEnableDebug', realtimeLogManager)
+ },
+ },
+ {
+ id: 'RealtimeLogManager-addFilterMsg',
+ func: () => {
+ TestConsole.consoleNormal('RealtimeLogManager-addFilterMsg')
+ realtimeLogManager.addFilterMsg('test')
+ },
+ },
+ {
+ id: 'RealtimeLogManager-in',
+ func: () => {
+ TestConsole.consoleNormal('RealtimeLogManager-in')
+ realtimeLogManager.in(Taro.getCurrentPages())
+ },
+ },
+ {
+ id: 'RealtimeLogManager-error',
+ func: () => {
+ TestConsole.consoleNormal('RealtimeLogManager-error')
+ realtimeLogManager.error('test', ['test'])
+ },
+ },
+ {
+ id: 'RealtimeLogManager-info',
+ func: () => {
+ TestConsole.consoleNormal('RealtimeLogManager-info')
+ realtimeLogManager.info(['test'])
+ },
+ },
+ {
+ id: 'RealtimeLogManager-setFilterMsg',
+ func: () => {
+ TestConsole.consoleNormal('RealtimeLogManager-setFilterMsg')
+ realtimeLogManager.setFilterMsg('test')
+ },
+ },
+ {
+ id: 'RealtimeLogManager-warn',
+ func: () => {
+ TestConsole.consoleNormal('RealtimeLogManager-warn')
+ realtimeLogManager.warn('test', ['test'])
+ },
+ },
+ {
+ id: 'RealtimeLogManager-tag',
+ func: () => {
+ let realtimeTagLogManage = realtimeLogManager.tag('test')
+ TestConsole.consoleNormal('RealtimeLogManager-tag', realtimeTagLogManage)
+ },
+ },
+ {
+ id: 'getLogManager',
+ func: () => {
+ logManager = Taro.getLogManager()
+ TestConsole.consoleNormal('getLogManager', logManager)
+ },
+ },
+ {
+ id: 'LogManager-debug',
+ func: () => {
+ logManager.debug(['test'])
+ TestConsole.consoleNormal('LogManager-debug')
+ },
+ },
+ {
+ id: 'LogManager-info',
+ func: () => {
+ logManager.info(['test'])
+ TestConsole.consoleNormal('LogManager-info')
+ },
+ },
+ {
+ id: 'LogManager-log',
+ func: () => {
+ logManager.log(['test'])
+ TestConsole.consoleNormal('LogManager-log')
+ },
+ },
+ {
+ id: 'LogManager-warn',
+ func: () => {
+ logManager.warn(['test'])
+ TestConsole.consoleNormal('LogManager-warn')
+ },
+ },
+ {
+ id: 'console',
+ func: null,
+ },
+ {
+ id: 'RealtimeTagLogManager',
+ func: null,
+ },
+ ],
+ }
+ render() {
+ const { list } = this.state
+ return (
+
+
+
+ )
+ }
+}
diff --git a/package.json b/package.json
index 61a9cbe75fbf..2e9d2aa7ca9e 100644
--- a/package.json
+++ b/package.json
@@ -26,8 +26,10 @@
"build:binding:release": "pnpm --filter @tarojs/binding run build",
"format::rs": "cargo fmt --all",
"clear-all": "rimraf **/node_modules",
- "lint": "eslint packages/ --ext .js --ext .ts --ext .tsx",
+ "lint": "eslint ./packages/ --ext .js,.jsx,.ts,.tsx",
"lint:style": "stylelint ./packages/**/*.{css,scss}",
+ "format": "prettier --write --cache .",
+ "format:check": "prettier --check --cache .",
"test": "pnpm --if-present -r --aggregate-output --filter=./packages/* test:ci",
"test:binding": "pnpm --filter @tarojs/binding run test",
"updateSnapshot": "pnpm --if-present -r --aggregate-output --filter=./packages/* updateSnapshot",
diff --git a/packages/shared/src/template.ts b/packages/shared/src/template.ts
index 03f3ad8152cc..f927d3b1c340 100644
--- a/packages/shared/src/template.ts
+++ b/packages/shared/src/template.ts
@@ -316,7 +316,6 @@ export class BaseTemplate {
? ``
: ``
}
-
}
private getChildren (comp: Component, level: number): string {
diff --git a/packages/taro-alipay/src/template.ts b/packages/taro-alipay/src/template.ts
index 880d2f0f7094..85f6a0fdc5fa 100644
--- a/packages/taro-alipay/src/template.ts
+++ b/packages/taro-alipay/src/template.ts
@@ -144,7 +144,7 @@ export class Template extends RecursiveTemplate {
if (pageConfig?.enablePageMeta) {
const getComponentAttrs = (componentName: string, dataPath: string) => {
return Object.entries(this.transferComponents[componentName]).reduce((sum, [key, value]) => {
- sum +=`${key}="${value === 'eh' ? value : `{{${value.replace('i.', dataPath)}}}`}" `
+ sum += `${key}="${value === 'eh' ? value : `{{${value.replace('i.', dataPath)}}}`}" `
return sum
}, '')
}
diff --git a/packages/taro-api/__tests__/interceptorify.test.ts b/packages/taro-api/__tests__/interceptorify.test.ts
index 33cf8171371b..a82ebd86a8f3 100644
--- a/packages/taro-api/__tests__/interceptorify.test.ts
+++ b/packages/taro-api/__tests__/interceptorify.test.ts
@@ -35,5 +35,4 @@ describe('taro interceptorify', () => {
const res2 = await execLink.request({ msg: 'test2' })
expect(res2.msg).toBe('test2__exec')
})
-
})
diff --git a/packages/taro-api/__tests__/pxTransform.test.ts b/packages/taro-api/__tests__/pxTransform.test.ts
index 579f7a96c1b8..67c49acbd93c 100644
--- a/packages/taro-api/__tests__/pxTransform.test.ts
+++ b/packages/taro-api/__tests__/pxTransform.test.ts
@@ -76,5 +76,4 @@ describe('pxtransform', () => {
})
expect(Taro.pxTransform(20)).toBe('0.585rem')
})
-
})
diff --git a/packages/taro-api/src/tools.ts b/packages/taro-api/src/tools.ts
index 645dfb86f0f1..9380dce327d5 100644
--- a/packages/taro-api/src/tools.ts
+++ b/packages/taro-api/src/tools.ts
@@ -47,9 +47,9 @@ export function getPxTransform (taro) {
const config = taro.config || {}
const baseFontSize = config.baseFontSize
const deviceRatio = config.deviceRatio || defaultDesignRatio
- const designWidth = (((input = 0) => isFunction(config.designWidth)
+ const designWidth = ((input = 0) => isFunction(config.designWidth)
? config.designWidth(input)
- : config.designWidth || defaultDesignWidth))(size)
+ : config.designWidth || defaultDesignWidth)(size)
if (!(designWidth in deviceRatio)) {
throw new Error(`deviceRatio 配置中不存在 ${designWidth} 的设置!`)
}
diff --git a/packages/taro-cli-convertor/__tests__/__mocks__/fs-extra.js b/packages/taro-cli-convertor/__tests__/__mocks__/fs-extra.js
index 0d5628a903ed..30fa130e3afb 100644
--- a/packages/taro-cli-convertor/__tests__/__mocks__/fs-extra.js
+++ b/packages/taro-cli-convertor/__tests__/__mocks__/fs-extra.js
@@ -12,9 +12,9 @@ const resFileMap = new Map()
/**
* 输出模拟文件的所有path结构
*/
-const flatteningFile = (file,path = '',result = {}) => {
- for(const filePath in file){
- if(typeof file[filePath] === 'object' && file[filePath] !== null){
+const flatteningFile = (file, path = '', result = {}) => {
+ for (const filePath in file) {
+ if (typeof file[filePath] === 'object' && file[filePath] !== null) {
result[path + filePath] = file[filePath]
flatteningFile(file[filePath], path + filePath, result)
} else {
@@ -25,24 +25,24 @@ const flatteningFile = (file,path = '',result = {}) => {
/**
* 保存文件信息
- *
- * @param { string } root 工程根目录
- * @param { map } newMockFiles
+ *
+ * @param { string } root 工程根目录
+ * @param { map } newMockFiles
*/
function setMockFiles (root, newMockFiles) {
const flatteningFileRes = {}
- flatteningFile(newMockFiles,'',flatteningFileRes)
+ flatteningFile(newMockFiles, '', flatteningFileRes)
for (const file in flatteningFileRes) {
oriFileMap.set(normalizePath(path.join(root, file)), flatteningFileRes[file])
}
- oriFileMap.set(root,newMockFiles)
+ oriFileMap.set(root, newMockFiles)
}
/**
* 获取原始的mock文件
- *
- * @returns
+ *
+ * @returns
*/
function getMockFiles () {
return oriFileMap
@@ -50,12 +50,12 @@ function getMockFiles () {
/**
* 更新oriFileMap
- *
- * @param { map } updateFiles
+ *
+ * @param { map } updateFiles
*/
function updateMockFiles (root, updateFiles) {
const flatteningFileRes = {}
- flatteningFile(updateFiles,'',flatteningFileRes)
+ flatteningFile(updateFiles, '', flatteningFileRes)
for (const file in flatteningFileRes) {
oriFileMap.set(normalizePath(path.join(root, file)), flatteningFileRes[file])
}
@@ -68,7 +68,7 @@ function getResMapFile () {
/**
* 清空fileMap
- *
+ *
*/
function clearMockFiles () {
oriFileMap.clear()
@@ -77,8 +77,8 @@ function clearMockFiles () {
/**
* 删除oriFileMap中元素
- *
- * @param { 文件路径 } key
+ *
+ * @param { 文件路径 } key
*/
function deleteMockFiles (key) {
oriFileMap.delete(key)
@@ -86,9 +86,9 @@ function deleteMockFiles (key) {
/**
* 读取文件
- *
- * @param { 文件路径 } path
- * @returns
+ *
+ * @param { 文件路径 } path
+ * @returns
*/
function readFileSyncMock (path, type) {
if (path === undefined || path === null || path === '') {
@@ -96,27 +96,27 @@ function readFileSyncMock (path, type) {
}
path = normalizePath(path)
-
+
if (!existsSyncMock(path)) {
throw new Error(`文件不存在,path:${path}`)
}
const fileMap = oriFileMap.has(path) ? oriFileMap : resFileMap
const content = fileMap.get(path)
- return content !== undefined ? content : fsSystem.readFileSync(path,type)
+ return content !== undefined ? content : fsSystem.readFileSync(path, type)
}
/**
* 判断文件是否存在
- *
+ *
*/
function existsSyncMock (pathParam) {
/**
* 针对于测试 generateConfigFiles 函数需要,因为 generateConfigFiles 中会查找 taro 子包中的文件
* jest.requireActual('fs-extra') 操作使用的是真实fs-extra模块,非模拟,所以会查找真实路径
*/
- if(fsSystem.existsSync(pathParam) && path.isAbsolute(pathParam)) return true
-
+ if (fsSystem.existsSync(pathParam) && path.isAbsolute(pathParam)) return true
+
if (typeof pathParam !== 'string' || pathParam === '') {
return false
}
@@ -129,14 +129,14 @@ function existsSyncMock (pathParam) {
let isFile = true
if (oriFileMap.get(pathParam) === undefined) {
isFile = false
- }
- if(resFileMap.get(pathParam)){
+ }
+ if (resFileMap.get(pathParam)) {
isFile = true
}
return isFile
}
// 判断文件夹
- if(oriFileMap.get(pathParam) && !parts[parts.length - 1].includes('.')){
+ if (oriFileMap.get(pathParam) && !parts[parts.length - 1].includes('.')) {
return true
}
// 文件夹内默认不存在
@@ -145,7 +145,7 @@ function existsSyncMock (pathParam) {
/**
* 保证文件夹存在,不存在则创建
- *
+ *
* @returns 默认存在
*/
function ensureDirSyncMock () {
@@ -154,31 +154,31 @@ function ensureDirSyncMock () {
/**
* 保证文件夹存在,不存在则创建
- *
+ *
* @returns 默认存在
*/
function ensureDirMock (path) {
- resFileMap.set(path,'')
+ resFileMap.set(path, '')
return true
}
/**
* 创建文件夹
- *
- * @returns
+ *
+ * @returns
*/
function mkdirSyncMock (path) {
path = normalizePath(path)
- resFileMap.set(path,'')
+ resFileMap.set(path, '')
return true
}
/**
* 向文件中追加内容
- *
- * @param { string } path
- * @param { 追加的内容 } appendContent
- * @returns
+ *
+ * @param { string } path
+ * @param { 追加的内容 } appendContent
+ * @returns
*/
function appendFileMock (path, appendContent) {
if (typeof path !== 'string' || path === '') {
@@ -195,10 +195,10 @@ function appendFileMock (path, appendContent) {
/**
* 向文件中写内容
- *
- * @param { string } path
- * @param { string } data
- * @returns
+ *
+ * @param { string } path
+ * @param { string } data
+ * @returns
*/
function writeFileSyncMock (path, data) {
if (typeof path !== 'string' || path === '') {
@@ -214,10 +214,10 @@ function writeFileSyncMock (path, data) {
/**
* 复制文件
- *
- * @param { string } from
- * @param { string } to
- * @returns
+ *
+ * @param { string } from
+ * @param { string } to
+ * @returns
*/
function copySyncMock (from, to) {
if (typeof from !== 'string' || from === '') {
@@ -248,8 +248,8 @@ function copySyncMock (from, to) {
/**
* 判断路径是否为文件夹
- *
- * @param { string } path
+ *
+ * @param { string } path
* @returns boolean
*/
function isDir (path) {
@@ -300,18 +300,18 @@ function lstatSyncMock (path) {
}
}
-/**
+/**
* 读取文件夹下的内容
*/
-function readdirSyncMock (source){
+function readdirSyncMock (source) {
source = normalizePath(source)
const parts = source.split('/')
- if(oriFileMap.get(source) && !parts[parts.length - 1].includes('.')){
- const fileName = []
+ if (oriFileMap.get(source) && !parts[parts.length - 1].includes('.')) {
+ const fileName = []
Object.keys(oriFileMap.get(source)).forEach((item) => {
fileName.push(item)
})
- return fileName
+ return fileName
} else {
return fsSystem.readdirSync(source)
}
@@ -320,11 +320,11 @@ function readdirSyncMock (source){
/**
* 文件复制
*/
-function copyFileSyncMock (sourcePath, destinationPath){
+function copyFileSyncMock (sourcePath, destinationPath) {
resFileMap.set(destinationPath, oriFileMap.get(sourcePath))
}
-function copyFileMock (sourcePath, destinationPath){
+function copyFileMock (sourcePath, destinationPath) {
resFileMap.set(destinationPath, oriFileMap.get(sourcePath))
}
@@ -332,7 +332,7 @@ function copyFileMock (sourcePath, destinationPath){
function customIsFile (path) {
let isFileRes = false
const fileMap = oriFileMap.has(path) ? oriFileMap : resFileMap
- if(fileMap.has(path)){
+ if (fileMap.has(path)) {
isFileRes = typeof fileMap.get(path) === 'string'
}
return isFileRes
@@ -348,9 +348,9 @@ function customIsDirectory (path) {
/**
* 路径格式化
- *
- * @param { string } path
- * @returns
+ *
+ * @param { string } path
+ * @returns
*/
function normalizePath (path) {
return path.replace(/\\/g, '/').replace(/\/{2,}/g, '/')
@@ -358,7 +358,7 @@ function normalizePath (path) {
module.exports = {
...fsSystem,
- readFileSync: jest.fn((content,type) => readFileSyncMock(content,type)),
+ readFileSync: jest.fn((content, type) => readFileSyncMock(content, type)),
existsSync: jest.fn((path) => existsSyncMock(path)),
ensureDirSync: jest.fn(() => ensureDirSyncMock()),
ensureDir: jest.fn(() => ensureDirMock()),
@@ -368,10 +368,10 @@ module.exports = {
copySync: jest.fn((from, to) => copySyncMock(from, to)),
statSync: jest.fn((path) => statSyncMock(path)),
lstatSync: jest.fn((path) => lstatSyncMock(path)),
- readdirSync:jest.fn((source) => readdirSyncMock(source)),
- copyFileSync:jest.fn((sourcePath,destinationPath) => copyFileSyncMock(sourcePath,destinationPath)),
- copyFile:jest.fn((sourcePath,destinationPath) => copyFileMock(sourcePath,destinationPath)),
- writeJSONSync:jest.fn(() => true)
+ readdirSync: jest.fn((source) => readdirSyncMock(source)),
+ copyFileSync: jest.fn((sourcePath, destinationPath) => copyFileSyncMock(sourcePath, destinationPath)),
+ copyFile: jest.fn((sourcePath, destinationPath) => copyFileMock(sourcePath, destinationPath)),
+ writeJSONSync: jest.fn(() => true)
}
module.exports.setMockFiles = setMockFiles
diff --git a/packages/taro-cli-convertor/__tests__/__mocks__/path.js b/packages/taro-cli-convertor/__tests__/__mocks__/path.js
index 703c89e2f28f..1bab8efa8e90 100644
--- a/packages/taro-cli-convertor/__tests__/__mocks__/path.js
+++ b/packages/taro-cli-convertor/__tests__/__mocks__/path.js
@@ -1,8 +1,8 @@
/**
* mock join方法
- *
- * @param {...string} pathSegments
- * @returns
+ *
+ * @param {...string} pathSegments
+ * @returns
*/
function joinMock (...pathSegments) {
// 定义一个函数来处理路径段
@@ -19,14 +19,14 @@ function joinMock (...pathSegments) {
for (let segment of pathSegments) {
// 将路劲中的 `\\` 替换为 `/` (示例:"E:\\code\\taro-16\\packages\\taro-cli")
- if(segment.includes(`\\`)){
+ if (segment.includes(`\\`)) {
segment = segment.replace(/\\/g, '/')
}
-
+
// 去掉路径段两端的斜杠并分割路径
const segments = segment.split('/').filter(processPathSegment)
- // 处理路径段中的 `..`
+ // 处理路径段中的 `..`
for (const subSegment of segments) {
if (subSegment === '..') {
// 如果是 `..`,则回退一层
diff --git a/packages/taro-cli-convertor/__tests__/config.test.ts b/packages/taro-cli-convertor/__tests__/config.test.ts
index 2b192df3d515..609368882f57 100644
--- a/packages/taro-cli-convertor/__tests__/config.test.ts
+++ b/packages/taro-cli-convertor/__tests__/config.test.ts
@@ -120,7 +120,7 @@ describe('转换报告', () => {
setMockFiles(root, REPORT_DEMO)
const convertor = new Convertor(root, false)
convertor.run()
-
+
expect(resFileMap.has('/wxProject/taroConvert/report/static/media/HarmonyOS_Sans_SC_Medium.ttf')).toBeTruthy()
expect(resFileMap.has('/wxProject/taroConvert/report/static/media/HarmonyOS_Sans_SC_Bold.ttf')).toBeTruthy()
expect(resFileMap.has('/wxProject/taroConvert/report/favicon.ico')).toBeTruthy()
@@ -128,7 +128,7 @@ describe('转换报告', () => {
resFileMap.delete('/wxProject/taroConvert/report/static/media/HarmonyOS_Sans_SC_Bold.ttf')
resFileMap.delete('/wxProject/taroConvert/report/favicon.ico')
- expect(resFileMap).toMatchSnapshot()
+ expect(resFileMap).toMatchSnapshot()
expect(resFileMap.has('/wxProject/taroConvert/report')).toBeTruthy()
expect(resFileMap.has('/wxProject/taroConvert/report/static/js')).toBeTruthy()
expect(resFileMap.has('/wxProject/taroConvert/report/static/css')).toBeTruthy()
@@ -167,7 +167,7 @@ describe('生成转换报告及日志', () => {
const convert = new Convertor(root, false)
expect(spy).toHaveBeenCalledTimes(3)
convert.generateReport()
-
+
expect(resFileMap.has('/wxProject/taroConvert/report')).toBeTruthy()
expect(resFileMap.has('/wxProject/taroConvert/report/static/js')).toBeTruthy()
expect(resFileMap.has('/wxProject/taroConvert/report/static/css')).toBeTruthy()
@@ -185,7 +185,7 @@ describe('生成转换报告及日志', () => {
},
},
'/images': {
- '/tu.jpg':'',
+ '/tu.jpg': '',
},
'/project.config.json': `{}`,
'/app.js': `App({})`,
@@ -216,12 +216,12 @@ describe('生成转换报告及日志', () => {
],
"plugins": {}
}`,
- '/pages':{
- '/index':{
- '/index.js':`Page({})`,
- '/index.wxml':``,
- '/index.json':`{}`,
- '/index.wxss':``,
+ '/pages': {
+ '/index': {
+ '/index.js': `Page({})`,
+ '/index.wxml': ``,
+ '/index.json': `{}`,
+ '/index.wxss': ``,
}
}
},
@@ -229,7 +229,7 @@ describe('生成转换报告及日志', () => {
setMockFiles(root, DEMO_PLUGIN_COMPLETE_DIRECTORY)
updateMockFiles(root, NO_REGISTERED_PLUGIN)
jest.spyOn(process, 'exit').mockImplementation()
- const convertor = new Convertor(root,false)
+ const convertor = new Convertor(root, false)
convertor.generateReport()
expect(resFileMap.has('/wxProject/taroConvert/report')).toBeTruthy()
@@ -254,9 +254,9 @@ describe('生成转换报告及日志', () => {
'/index.wxss': '',
},
},
- '/components':{
- '/index':{
- '/index.wxml':''
+ '/components': {
+ '/index': {
+ '/index.wxml': ''
}
},
'/project.config.json': `{}`,
@@ -270,7 +270,7 @@ describe('生成转换报告及日志', () => {
`,
}
setMockFiles(root, COMPONENT_NO_JS)
- const convertor = new Convertor(root,false)
+ const convertor = new Convertor(root, false)
convertor.run()
expect(resFileMap.has('/wxProject/taroConvert/report')).toBeTruthy()
expect(resFileMap.has('/wxProject/taroConvert/report/static/js')).toBeTruthy()
@@ -295,21 +295,21 @@ describe('生成转换报告及日志', () => {
"hello-list": "plugin://hello-component"
}
}`,
- '/pages':{
- '/index':{
- '/index.js':`Page({})`,
- '/index.wxml':``,
- '/index.json':`{
+ '/pages': {
+ '/index': {
+ '/index.js': `Page({})`,
+ '/index.wxml': ``,
+ '/index.json': `{
}`,
- '/index.wxss':``,
+ '/index.wxss': ``,
}
}
}
}
setMockFiles(root, DEMO_PLUGIN_COMPLETE_DIRECTORY)
updateMockFiles(root, PLUGIN_PATH_ABNORMAL)
- const convertor = new Convertor(root,false)
+ const convertor = new Convertor(root, false)
convertor.run()
expect(resFileMap.has('/wxProject/taroConvert/report')).toBeTruthy()
expect(resFileMap.has('/wxProject/taroConvert/report/static/js')).toBeTruthy()
@@ -320,28 +320,28 @@ describe('生成转换报告及日志', () => {
test('插件配置信息为空,解析plugin.json失败', () => {
const PLUGIN_PATH_ABNORMAL = {
'/plugin': {
- '/components':{
- '/hello-component.js':`Component({})`,
- '/hello-component.wxml':`plugin/components/hello-component.wxml`,
- '/hello-component.json':`{
+ '/components': {
+ '/hello-component.js': `Component({})`,
+ '/hello-component.wxml': `plugin/components/hello-component.wxml`,
+ '/hello-component.json': `{
"component": true,
"usingComponents": {}
}`,
- '/hello-component.wxss':``,
+ '/hello-component.wxss': ``,
},
- '/pages':{
- '/hello-page.js':`Page({})`,
- '/hello-page.wxml':'This is a plugin page!',
- '/hello-page.json':'{}',
- '/hello-page.wxss':'',
+ '/pages': {
+ '/hello-page.js': `Page({})`,
+ '/hello-page.wxml': 'This is a plugin page!',
+ '/hello-page.json': '{}',
+ '/hello-page.wxss': '',
},
- '/plugin.json':Buffer.alloc(0),
+ '/plugin.json': Buffer.alloc(0),
},
}
setMockFiles(root, DEMO_PLUGIN_COMPLETE_DIRECTORY)
updateMockFiles(root, PLUGIN_PATH_ABNORMAL)
jest.spyOn(process, 'exit').mockImplementation()
- const convertor = new Convertor(root,false)
+ const convertor = new Convertor(root, false)
convertor.generateReport()
expect(resFileMap.has('/wxProject/taroConvert/report')).toBeTruthy()
expect(resFileMap.has('/wxProject/taroConvert/report/static/js')).toBeTruthy()
@@ -362,7 +362,7 @@ describe('生成转换报告及日志', () => {
setMockFiles(root, DEMO_PLUGIN_COMPLETE_DIRECTORY)
updateMockFiles(root, NO_PLUGINROOT)
jest.spyOn(process, 'exit').mockImplementation()
- const convertor = new Convertor(root,false)
+ const convertor = new Convertor(root, false)
convertor.generateReport()
expect(resFileMap.has('/wxProject/taroConvert/report')).toBeTruthy()
expect(resFileMap.has('/wxProject/taroConvert/report/static/js')).toBeTruthy()
@@ -373,22 +373,22 @@ describe('生成转换报告及日志', () => {
test('引用了未注册的插件组件', () => {
const USE_NOT_REGISTERED_COMPONENT = {
'/plugin': {
- '/components':{
- '/hello-component.js':`Component({})`,
- '/hello-component.wxml':`plugin/components/hello-component.wxml`,
- '/hello-component.json':`{
+ '/components': {
+ '/hello-component.js': `Component({})`,
+ '/hello-component.wxml': `plugin/components/hello-component.wxml`,
+ '/hello-component.json': `{
"component": true,
"usingComponents": {}
}`,
- '/hello-component.wxss':``,
+ '/hello-component.wxss': ``,
},
- '/pages':{
- '/hello-page.js':`Page({})`,
- '/hello-page.wxml':'This is a plugin page!',
- '/hello-page.json':'{}',
- '/hello-page.wxss':'',
+ '/pages': {
+ '/hello-page.js': `Page({})`,
+ '/hello-page.wxml': 'This is a plugin page!',
+ '/hello-page.json': '{}',
+ '/hello-page.wxss': '',
},
- '/plugin.json':`
+ '/plugin.json': `
{
"pages": {
"hello-page": "pages/hello-page"
@@ -400,7 +400,7 @@ describe('生成转换报告及日志', () => {
}
setMockFiles(root, DEMO_PLUGIN_COMPLETE_DIRECTORY)
updateMockFiles(root, USE_NOT_REGISTERED_COMPONENT)
- const convertor = new Convertor(root,false)
+ const convertor = new Convertor(root, false)
convertor.run()
expect(resFileMap.has('/wxProject/taroConvert/report')).toBeTruthy()
@@ -428,18 +428,18 @@ describe('生成转换报告及日志', () => {
},
'/project.config.json': `{}`,
'/app.js': `App({})`,
- '/app.json':`
+ '/app.json': `
{
"pages": [
"pages/index/index"
]
}
`,
- '/node_modules':{}
+ '/node_modules': {}
}
setMockFiles(root, NODE_MODULES_NO_INSTALL)
- const convertor = new Convertor(root,false)
+ const convertor = new Convertor(root, false)
convertor.run()
expect(resFileMap.has('/wxProject/taroConvert/report')).toBeTruthy()
@@ -472,7 +472,7 @@ describe('生成转换报告及日志', () => {
`,
}
setMockFiles(root, JS_IMPORT_NOT_EXIST_FILE)
- const convertor = new Convertor(root,false)
+ const convertor = new Convertor(root, false)
convertor.run()
expect(resFileMap.has('/wxProject/taroConvert/report')).toBeTruthy()
@@ -505,7 +505,7 @@ describe('生成转换报告及日志', () => {
`,
}
setMockFiles(root, JS_IMPORT_NOT_EXIST_FILE)
- const convertor = new Convertor(root,false)
+ const convertor = new Convertor(root, false)
convertor.run()
expect(resFileMap.has('/wxProject/taroConvert/report')).toBeTruthy()
@@ -563,7 +563,7 @@ describe('生成转换报告及日志', () => {
}
setMockFiles(root, UTILS_NO_INDEXJS_FILE)
- const convertor = new Convertor(root,false)
+ const convertor = new Convertor(root, false)
convertor.run()
expect(resFileMap.has('/wxProject/taroConvert/report')).toBeTruthy()
@@ -572,4 +572,3 @@ describe('生成转换报告及日志', () => {
expect(resFileMap.has('/wxProject/taroConvert/report/static/media')).toBeTruthy()
})
})
-
\ No newline at end of file
diff --git a/packages/taro-cli-convertor/__tests__/data/fileData.ts b/packages/taro-cli-convertor/__tests__/data/fileData.ts
index dcf4c7babfe7..973d4118aa7f 100644
--- a/packages/taro-cli-convertor/__tests__/data/fileData.ts
+++ b/packages/taro-cli-convertor/__tests__/data/fileData.ts
@@ -50,7 +50,7 @@ export const DEMO_JS_FILE_INFO_MINIPROGRANROOT = {
]
}
`,
- '/miniprogram/app.wxss':'',
+ '/miniprogram/app.wxss': '',
'/miniprogram/pages/index/index.js': `
const app = getApp()
Page({
@@ -295,14 +295,14 @@ export const SUBPAKCAEGS_AND_PLUGIN_CONFIG = {
}
}
`,
- '/miniprogram/packageA/pages/index.wxml':`packageA/index.wxml`,
- '/miniprogram/packageA/pages/index.js':`Page({})`,
- '/miniprogram/packageB/pages/index.wxml':`packageB/index.wxml`,
- '/miniprogram/packageB/pages/index.js':`Page({})`,
+ '/miniprogram/packageA/pages/index.wxml': `packageA/index.wxml`,
+ '/miniprogram/packageA/pages/index.js': `Page({})`,
+ '/miniprogram/packageB/pages/index.wxml': `packageB/index.wxml`,
+ '/miniprogram/packageB/pages/index.js': `Page({})`,
}
export const DEMO_JS_FILES = {
- '/app.js':'App({})',
+ '/app.js': 'App({})',
'/app.json': `
{
"pages":[
@@ -357,9 +357,9 @@ export const USINGCOMPONENTS_FILE_DATA = {
"cpt": "/components/cpt/cpt"
}
}
- `,
- '/miniprogram/app.js':`app({})`,
- '/miniprogram/pages/index/index.json':`
+ `,
+ '/miniprogram/app.js': `app({})`,
+ '/miniprogram/pages/index/index.json': `
{
"usingComponents": {
"cpt2": "/components/cpt2/cpt2",
@@ -368,13 +368,13 @@ export const USINGCOMPONENTS_FILE_DATA = {
}
}
`,
- '/miniprogram/pages/index/index.wxml':`
+ '/miniprogram/pages/index/index.wxml': `
`,
- '/miniprogram/components/cpt/cpt.js':`
+ '/miniprogram/components/cpt/cpt.js': `
Component({
properties: {
text: {
@@ -388,7 +388,7 @@ export const USINGCOMPONENTS_FILE_DATA = {
}
})
`,
- '/miniprogram/components/cpt/cpt.json':`
+ '/miniprogram/components/cpt/cpt.json': `
{
"component": true,
"usingComponents": {
@@ -396,11 +396,11 @@ export const USINGCOMPONENTS_FILE_DATA = {
}
}
`,
- '/miniprogram/components/cpt/cpt.wxml':`
+ '/miniprogram/components/cpt/cpt.wxml': `
cpt
`,
- '/miniprogram/components/cpt2/cpt2.js':`
+ '/miniprogram/components/cpt2/cpt2.js': `
Component({
properties: {
text: {
@@ -414,20 +414,20 @@ export const USINGCOMPONENTS_FILE_DATA = {
}
})
`,
- '/miniprogram/components/cpt2/cpt2.json':`
+ '/miniprogram/components/cpt2/cpt2.json': `
{
"component": true,
"usingComponents": {
}
}
`,
- '/miniprogram/components/cpt2/cpt2.wxml':`
+ '/miniprogram/components/cpt2/cpt2.wxml': `
cpt2
`,
- '/miniprogram/components/cpt3/cpt3.js':`
+ '/miniprogram/components/cpt3/cpt3.js': `
Component({
properties: {
text: {
@@ -441,7 +441,7 @@ export const USINGCOMPONENTS_FILE_DATA = {
}
})
`,
- '/miniprogram/components/cpt3/cpt3.json':`
+ '/miniprogram/components/cpt3/cpt3.json': `
{
"component": true,
"usingComponents": {
@@ -449,7 +449,7 @@ export const USINGCOMPONENTS_FILE_DATA = {
}
}
`,
- '/miniprogram/components/cpt3/cpt3.wxml':`
+ '/miniprogram/components/cpt3/cpt3.wxml': `
cpt3
@@ -458,7 +458,7 @@ export const USINGCOMPONENTS_FILE_DATA = {
}
export const DEMO_TABBER = {
- '/app.json':`
+ '/app.json': `
{
"pages": [
"pages/component/index",
@@ -486,20 +486,20 @@ export const DEMO_TABBER = {
}
}
`,
- '/app.js':'App({})',
+ '/app.js': 'App({})',
'/project.config.json': `{}`,
- '/pages/component/index.js':'Page({})',
- '/pages/component/index.wxml':`组件`,
- '/pages/api/index.js':'Page({})',
- '/pages/api/index.wxml':'接口',
- '/image/icon_component.png':'',
- '/image/icon_component_HL.png':'',
- '/image/icon_API.png':'',
- '/image/icon_API_HL.png':''
+ '/pages/component/index.js': 'Page({})',
+ '/pages/component/index.wxml': `组件`,
+ '/pages/api/index.js': 'Page({})',
+ '/pages/api/index.wxml': '接口',
+ '/image/icon_component.png': '',
+ '/image/icon_component_HL.png': '',
+ '/image/icon_API.png': '',
+ '/image/icon_API_HL.png': ''
}
export const DEMO_CUSTOM_TABBER = {
- '/app.json':`
+ '/app.json': `
{
"pages": [
"pages/component/index",
@@ -528,26 +528,26 @@ export const DEMO_CUSTOM_TABBER = {
}
}
`,
- '/app.js':'App({})',
+ '/app.js': 'App({})',
'/project.config.json': `{}`,
- '/pages/component/index.js':'Page({})',
- '/pages/component/index.wxml':`组件`,
- '/pages/api/index.js':'Page({})',
- '/pages/api/index.wxml':'接口',
- '/image/icon_component.png':'',
- '/image/icon_component_HL.png':'',
- '/image/icon_API.png':'',
- '/image/icon_API_HL.png':'',
- '/custom-tab-bar':{
- '/index.js':'Component({})',
- '/index.wxml':'',
- '/index.json':'{}',
- '/index.wxss':'',
+ '/pages/component/index.js': 'Page({})',
+ '/pages/component/index.wxml': `组件`,
+ '/pages/api/index.js': 'Page({})',
+ '/pages/api/index.wxml': '接口',
+ '/image/icon_component.png': '',
+ '/image/icon_component_HL.png': '',
+ '/image/icon_API.png': '',
+ '/image/icon_API_HL.png': '',
+ '/custom-tab-bar': {
+ '/index.js': 'Component({})',
+ '/index.wxml': '',
+ '/index.json': '{}',
+ '/index.wxss': '',
}
}
export const DEMO_SUBPACKAFES = {
- '/app.json':`
+ '/app.json': `
{
"pages": [
"pages/index/index"
@@ -568,14 +568,14 @@ export const DEMO_SUBPACKAFES = {
]
}
`,
- '/app.js':'App({})',
+ '/app.js': 'App({})',
'/project.config.json': `{}`,
- '/pages/index/index.wxml':'pages/index/index.wxml',
- '/pages/index/index.js':'Page({})',
- '/packageA/pages/component/index.js':'Page({})',
- '/packageA/pages/component/index.wxml':'packageA/pages/component/index.wxml',
- '/packageB/pages/api/index.js':'Page({})',
- '/packageB/pages/api/index.wxml':'packageB/pages/api/index.wxml',
+ '/pages/index/index.wxml': 'pages/index/index.wxml',
+ '/pages/index/index.js': 'Page({})',
+ '/packageA/pages/component/index.js': 'Page({})',
+ '/packageA/pages/component/index.wxml': 'packageA/pages/component/index.wxml',
+ '/packageB/pages/api/index.js': 'Page({})',
+ '/packageB/pages/api/index.wxml': 'packageB/pages/api/index.wxml',
}
export const DEMO_PAGE_NO_JS = {
@@ -618,32 +618,32 @@ export const DEMO_PLUGIN_COMPLETE_DIRECTORY = {
"hello-list": "plugin://hello-plugin/hello-component"
}
}`,
- '/pages':{
- '/index':{
- '/index.js':`Page({})`,
- '/index.wxml':``,
- '/index.json':`{}`,
- '/index.wxss':``,
+ '/pages': {
+ '/index': {
+ '/index.js': `Page({})`,
+ '/index.wxml': ``,
+ '/index.json': `{}`,
+ '/index.wxss': ``,
}
}
},
'/plugin': {
- '/components':{
- '/hello-component.js':`Component({})`,
- '/hello-component.wxml':`plugin/components/hello-component.wxml`,
- '/hello-component.json':`{
+ '/components': {
+ '/hello-component.js': `Component({})`,
+ '/hello-component.wxml': `plugin/components/hello-component.wxml`,
+ '/hello-component.json': `{
"component": true,
"usingComponents": {}
}`,
- '/hello-component.wxss':``,
+ '/hello-component.wxss': ``,
},
- '/pages':{
- '/hello-page.js':`Page({})`,
- '/hello-page.wxml':'This is a plugin page!',
- '/hello-page.json':'{}',
- '/hello-page.wxss':'',
+ '/pages': {
+ '/hello-page.js': `Page({})`,
+ '/hello-page.wxml': 'This is a plugin page!',
+ '/hello-page.json': '{}',
+ '/hello-page.wxss': '',
},
- '/plugin.json':`
+ '/plugin.json': `
{
"publicComponents": {
"hello-component": "components/hello-component"
diff --git a/packages/taro-cli-convertor/__tests__/index.test.ts b/packages/taro-cli-convertor/__tests__/index.test.ts
index 6d8c1b7f8880..94e11e4efb39 100644
--- a/packages/taro-cli-convertor/__tests__/index.test.ts
+++ b/packages/taro-cli-convertor/__tests__/index.test.ts
@@ -522,7 +522,7 @@ describe('parseAst', () => {
const { add } = require('/add')
Page({})
`,
- '/pages/index/add.js':`
+ '/pages/index/add.js': `
function add(num1,num2){
return num1 + num2
}
@@ -545,7 +545,7 @@ describe('parseAst', () => {
})
const { ast } = convert.parseAst({
ast: taroizeResult.ast,
- sourceFilePath: path.join(root,'/pages/index/index.js'),
+ sourceFilePath: path.join(root, '/pages/index/index.js'),
outputFilePath: '',
importStylePath: '',
depComponents: new Set(),
@@ -557,13 +557,13 @@ describe('parseAst', () => {
expect(jsCode).toMatchSnapshot()
})
- test('处理js文件中非正常路径,比如 a/b',() => {
+ test('处理js文件中非正常路径,比如 a/b', () => {
const DEMO_ABSOLUTE = {
'/pages/index/index.js': `
const { add } = require('add')
Page({})
`,
- '/pages/index/add.js':`
+ '/pages/index/add.js': `
function add(num1,num2){
return num1 + num2
}
@@ -586,7 +586,7 @@ describe('parseAst', () => {
})
const { ast } = convert.parseAst({
ast: taroizeResult.ast,
- sourceFilePath: path.join(root,'/pages/index/index.js'),
+ sourceFilePath: path.join(root, '/pages/index/index.js'),
outputFilePath: '',
importStylePath: '',
depComponents: new Set(),
@@ -598,7 +598,7 @@ describe('parseAst', () => {
expect(jsCode).toMatchSnapshot()
})
- test('使用 resolveAlias 配置项用来自定义模块路径的映射规则',() => {
+ test('使用 resolveAlias 配置项用来自定义模块路径的映射规则', () => {
const DEMO_RESOLVEALIAS = {
'/pages/index/index.js': `
const { formatTime } = require('@utils/tools/util.js')
@@ -606,7 +606,7 @@ describe('parseAst', () => {
const { test } = require('com/navigation-bar/test')
Page({})
`,
- '/pages/index/utils.js':`
+ '/pages/index/utils.js': `
const name = 'wsjzy'
const mesg = 'who are you ?'
module.exports = {
@@ -614,7 +614,7 @@ describe('parseAst', () => {
mesg
}
`,
- '/pages/tools/util.js':`
+ '/pages/tools/util.js': `
function formatTime() {
return '1111' + '2222'
}
@@ -625,7 +625,7 @@ describe('parseAst', () => {
a
}
`,
- '/components/navigation-bar/test.js':`
+ '/components/navigation-bar/test.js': `
const test = 'test from components'
module.exports = {
test
@@ -633,7 +633,7 @@ describe('parseAst', () => {
`,
}
// 为app.json配置resolveAlias配置项
- convert.entryJSON = {
+ convert.entryJSON = {
pages: ['pages/index/index'],
resolveAlias: {
'~/*': '/*',
@@ -661,7 +661,7 @@ describe('parseAst', () => {
})
const { ast } = convert.parseAst({
ast: taroizeResult.ast,
- sourceFilePath: path.join(root,'/pages/index/index.js'),
+ sourceFilePath: path.join(root, '/pages/index/index.js'),
outputFilePath: '',
importStylePath: '',
depComponents: new Set(),
diff --git a/packages/taro-cli-convertor/__tests__/script.test.ts b/packages/taro-cli-convertor/__tests__/script.test.ts
index c8d261d20331..8f45d0e5a636 100644
--- a/packages/taro-cli-convertor/__tests__/script.test.ts
+++ b/packages/taro-cli-convertor/__tests__/script.test.ts
@@ -236,7 +236,6 @@ describe('文件转换', () => {
}
}
})
-
})
describe('page页面转换', () => {
diff --git a/packages/taro-cli-convertor/__tests__/wxss.test.ts b/packages/taro-cli-convertor/__tests__/wxss.test.ts
index 5bc740b95695..f44c4e41d48e 100644
--- a/packages/taro-cli-convertor/__tests__/wxss.test.ts
+++ b/packages/taro-cli-convertor/__tests__/wxss.test.ts
@@ -28,7 +28,7 @@ describe('引入外部wxss文件', () => {
}
`
const WITHOUT_WXSS_DEMO = {
- '/pages/common.wxss':`
+ '/pages/common.wxss': `
page {
height: 100vh;
display: flex;
@@ -40,7 +40,7 @@ describe('引入外部wxss文件', () => {
}
setMockFiles(root, WITHOUT_WXSS_DEMO)
const convertor = new Convertor(root, false)
- await convertor.traverseStyle(path.join(root,'/pages/index/index.wxss'), wxssStr)
+ await convertor.traverseStyle(path.join(root, '/pages/index/index.wxss'), wxssStr)
const resFileMap = getResMapFile()
expect(resFileMap).toMatchSnapshot()
})
@@ -54,7 +54,7 @@ describe('引入外部wxss文件', () => {
}
`
const WITHOUT_WXSS_DEMO = {
- '/pages/common.wxss':`
+ '/pages/common.wxss': `
page {
height: 100vh;
display: flex;
@@ -66,7 +66,7 @@ describe('引入外部wxss文件', () => {
}
setMockFiles(root, WITHOUT_WXSS_DEMO)
const convertor = new Convertor(root, false)
- await convertor.traverseStyle(path.join(root,'/pages/index/index.wxss'), wxssStr)
+ await convertor.traverseStyle(path.join(root, '/pages/index/index.wxss'), wxssStr)
const resFileMap = getResMapFile()
expect(resFileMap).toMatchSnapshot()
})
@@ -80,7 +80,7 @@ describe('引入外部wxss文件', () => {
}
`
const WITHOUT_WXSS_DEMO = {
- '/pages/common.wxss':`
+ '/pages/common.wxss': `
page {
height: 100vh;
display: flex;
@@ -92,7 +92,7 @@ describe('引入外部wxss文件', () => {
}
setMockFiles(root, WITHOUT_WXSS_DEMO)
const convertor = new Convertor(root, false)
- await convertor.traverseStyle(path.join(root,'/pages/index/index.wxss'), wxssStr)
+ await convertor.traverseStyle(path.join(root, '/pages/index/index.wxss'), wxssStr)
const resFileMap = getResMapFile()
expect(resFileMap).toMatchSnapshot()
})
@@ -105,15 +105,14 @@ describe('引入外部wxss文件', () => {
}
`
const DEMO_FONTS = {
- '/fonts/Algerian.ttf':'字体二进制',
+ '/fonts/Algerian.ttf': '字体二进制',
'/pages/index/index.wxss': wxssStr
}
setMockFiles(root, DEMO_JS_FILE_INFO)
updateMockFiles(root, DEMO_FONTS)
const convertor = new Convertor(root, false)
- await convertor.traverseStyle(path.join(root,'/pages/index/index.wxss'), wxssStr)
+ await convertor.traverseStyle(path.join(root, '/pages/index/index.wxss'), wxssStr)
const resFileMap = getResMapFile()
expect(resFileMap).toMatchSnapshot()
})
-
})
diff --git a/packages/taro-cli-convertor/src/index.ts b/packages/taro-cli-convertor/src/index.ts
index 5cc70bbbcf78..9a7d0eb6cb71 100644
--- a/packages/taro-cli-convertor/src/index.ts
+++ b/packages/taro-cli-convertor/src/index.ts
@@ -867,7 +867,7 @@ export default class Convertor {
if (needInsertImportTaro && !hasTaroImport(bodyNode)) {
// 根据模块类型(commonjs/es6) 确定导入taro模块的类型
if (isCommonjsModule(ast.program.body as any)) {
- ;(astPath.node as t.Program).body.unshift(
+ (astPath.node as t.Program).body.unshift(
t.variableDeclaration('const', [
t.variableDeclarator(
t.identifier('Taro'),
@@ -876,7 +876,7 @@ export default class Convertor {
])
)
} else {
- ;(astPath.node as t.Program).body.unshift(
+ (astPath.node as t.Program).body.unshift(
t.importDeclaration([t.importDefaultSpecifier(t.identifier('Taro'))], t.stringLiteral('@tarojs/taro'))
)
}
diff --git a/packages/taro-cli/src/__tests__/dotenv-parse.spec.ts b/packages/taro-cli/src/__tests__/dotenv-parse.spec.ts
index 799083d1b1f0..ba5114c45e2d 100644
--- a/packages/taro-cli/src/__tests__/dotenv-parse.spec.ts
+++ b/packages/taro-cli/src/__tests__/dotenv-parse.spec.ts
@@ -45,7 +45,6 @@ describe('inspect', () => {
})
describe('cli mode env', () => {
-
it('dotenvParse .env .env.dev should success', async () => {
expect(process.env.TARO_test).toBeUndefined()
dotenvParse(path.resolve(__dirname, 'env'), 'TARO_', 'dev')
diff --git a/packages/taro-cli/src/__tests__/update.spec.ts b/packages/taro-cli/src/__tests__/update.spec.ts
index 65691e6782e2..2a68e9848df5 100644
--- a/packages/taro-cli/src/__tests__/update.spec.ts
+++ b/packages/taro-cli/src/__tests__/update.spec.ts
@@ -37,7 +37,7 @@ jest.mock('ora', () => {
return {
stop () {},
warn () {},
- succeed (){}
+ succeed () {}
}
}
})
diff --git a/packages/taro-cli/src/cli.ts b/packages/taro-cli/src/cli.ts
index 3965d07c2061..a8aca72de6fb 100644
--- a/packages/taro-cli/src/cli.ts
+++ b/packages/taro-cli/src/cli.ts
@@ -89,7 +89,7 @@ export default class CLI {
// 将自定义的 变量 添加到 config.env 中,实现 definePlugin 字段定义
const initialConfig = kernel.config?.initialConfig
- if(initialConfig) {
+ if (initialConfig) {
initialConfig.env = patchEnv(initialConfig, expandEnv)
}
if (command === 'doctor') {
diff --git a/packages/taro-cli/src/create/page.ts b/packages/taro-cli/src/create/page.ts
index 6504bdd87dbe..586ae31fee23 100644
--- a/packages/taro-cli/src/create/page.ts
+++ b/packages/taro-cli/src/create/page.ts
@@ -1,4 +1,4 @@
-import { CompilerType, createPage as createPageBinding,CSSType, FrameworkType, NpmType, PeriodType } from '@tarojs/binding'
+import { CompilerType, createPage as createPageBinding, CSSType, FrameworkType, NpmType, PeriodType } from '@tarojs/binding'
import { chalk, DEFAULT_TEMPLATE_SRC, fs, getUserHomeDir, TARO_BASE_CONFIG, TARO_CONFIG_FOLDER } from '@tarojs/helper'
import { isNil } from 'lodash'
import * as path from 'path'
@@ -40,7 +40,7 @@ type TCustomTemplateInfo = Omit void
-type TGetCustomTemplate = (cb: TSetCustomTemplateConfig ) => Promise
+type TGetCustomTemplate = (cb: TSetCustomTemplateConfig) => Promise
const DEFAULT_TEMPLATE_INFO = {
name: 'default',
@@ -137,7 +137,7 @@ export default class Page extends Creator {
this.conf.date = `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()}`
// apply 插件,由插件设置自定义模版 config
await this.modifyCustomTemplateConfig(this.setCustomTemplateConfig.bind(this))
- if(!this.conf.isCustomTemplate){
+ if (!this.conf.isCustomTemplate) {
const pkgTemplateInfo = this.getPkgTemplateInfo()
this.setTemplateConfig(pkgTemplateInfo)
if (!fs.existsSync(this.templatePath(this.conf.template))) {
diff --git a/packages/taro-cli/src/create/project.ts b/packages/taro-cli/src/create/project.ts
index b13ef64f50dd..7f064ecbc81c 100644
--- a/packages/taro-cli/src/create/project.ts
+++ b/packages/taro-cli/src/create/project.ts
@@ -44,7 +44,7 @@ export interface IProjectConf {
type CustomPartial = Omit & Partial>;
-type IProjectConfOptions = CustomPartial
+type IProjectConfOptions = CustomPartial
interface AskMethods {
(conf: IProjectConfOptions, prompts: Record[], choices?: ITemplates[]): void
diff --git a/packages/taro-cli/src/doctor/index.ts b/packages/taro-cli/src/doctor/index.ts
index 98622cda217a..9b8fe06df577 100644
--- a/packages/taro-cli/src/doctor/index.ts
+++ b/packages/taro-cli/src/doctor/index.ts
@@ -3,7 +3,8 @@ import {
validateEnv,
validateEslint,
validatePackage,
- validateRecommend } from '@tarojs/plugin-doctor'
+ validateRecommend
+} from '@tarojs/plugin-doctor'
export default {
validators: [
diff --git a/packages/taro-cli/src/index.ts b/packages/taro-cli/src/index.ts
index b4c4d2dd8211..921fd393eeb3 100644
--- a/packages/taro-cli/src/index.ts
+++ b/packages/taro-cli/src/index.ts
@@ -20,4 +20,5 @@ export {
defineConfig,
doctor,
getRootPath,
- Project }
+ Project
+}
diff --git a/packages/taro-cli/src/presets/commands/global-config.ts b/packages/taro-cli/src/presets/commands/global-config.ts
index 8a005368ba26..6b2068e685cd 100644
--- a/packages/taro-cli/src/presets/commands/global-config.ts
+++ b/packages/taro-cli/src/presets/commands/global-config.ts
@@ -47,7 +47,7 @@ export default (ctx: IPluginContext) => {
const rootPath = getRootPath()
const templatePath = path.join(rootPath, 'templates', 'global-config')
function makeSureConfigExists () {
- if(!fs.existsSync(globalPluginConfigDir)){
+ if (!fs.existsSync(globalPluginConfigDir)) {
const spinner = ora(`目录不存在,全局配置初始化`).start()
try {
fs.copySync(templatePath, globalPluginConfigDir)
@@ -56,10 +56,9 @@ export default (ctx: IPluginContext) => {
spinner.fail(`全局配置初始化失败,${e}`)
process.exit(1)
}
-
}
}
- function addOrRemovePresetOrPlugin (actionType: TPresetOrPluginAction, pluginType: TPluginType ) {
+ function addOrRemovePresetOrPlugin (actionType: TPresetOrPluginAction, pluginType: TPluginType) {
makeSureConfigExists()
const presetOrPluginChineseName = PRESET_OR_PLUGIN_CHINESE_NAME_MAP[pluginType]
const chineseCommand = PRESET_OR_PLUGIN_COMMAND_CHINESE_MAP_MAP[actionType]
@@ -70,7 +69,7 @@ export default (ctx: IPluginContext) => {
const spinner = ora(`开始${chineseCommand}${presetOrPluginChineseName} ${pluginName}`).start()
const pluginWithoutVersionName = getPkgNameByFilterVersion(pluginName)
- if(!validatePkgName(pluginWithoutVersionName).validForNewPackages) {
+ if (!validatePkgName(pluginWithoutVersionName).validForNewPackages) {
spinner.fail('安装的插件名不合规!')
process.exit(1)
}
@@ -83,21 +82,21 @@ export default (ctx: IPluginContext) => {
let globalConfig
try {
globalConfig = fs.readJSONSync(configFilePath)
- } catch (e){
+ } catch (e) {
spinner.fail('获取配置文件失败')
}
const configKey = PLUGIN_TYPE_TO_CONFIG_KEY[pluginType]
const configItem = globalConfig[configKey] || []
- const pluginIndex = configItem.findIndex((item)=>{
- if(typeof item === 'string') return item === pluginWithoutVersionName
- if( item instanceof Array) return item?.[0] === pluginWithoutVersionName
+ const pluginIndex = configItem.findIndex((item) => {
+ if (typeof item === 'string') return item === pluginWithoutVersionName
+ if (item instanceof Array) return item?.[0] === pluginWithoutVersionName
})
const shouldChangeFile = !(Number(pluginIndex !== -1) ^ Number(actionType === 'uninstall'))
- if(shouldChangeFile){
+ if (shouldChangeFile) {
actionType === 'install' ? configItem.push(pluginWithoutVersionName) : configItem.splice(pluginIndex, 1)
try {
fs.writeJSONSync(configFilePath, {
- [configKey] : configItem
+ [configKey]: configItem
})
} catch (e) {
spinner.fail(`修改配置文件失败:${e}`)
@@ -125,7 +124,7 @@ export default (ctx: IPluginContext) => {
addOrRemovePresetOrPlugin('uninstall', 'preset')
break
case 'reset':
- if(fs.existsSync(globalPluginConfigDir)) fs.removeSync(globalPluginConfigDir)
+ if (fs.existsSync(globalPluginConfigDir)) fs.removeSync(globalPluginConfigDir)
fs.copySync(templatePath, globalPluginConfigDir)
break
default:
diff --git a/packages/taro-cli/src/presets/commands/update.ts b/packages/taro-cli/src/presets/commands/update.ts
index 26a6f5986910..da6324a38199 100644
--- a/packages/taro-cli/src/presets/commands/update.ts
+++ b/packages/taro-cli/src/presets/commands/update.ts
@@ -63,7 +63,7 @@ export default (ctx: IPluginContext) => {
const updateTarget = isSelf ? ' CLI ' : ' Taro 项目依赖'
const spinString = `正在更新${updateTarget}到 v${version} ...`
const spinner = ora(spinString).start()
- execCommand({
+ execCommand({
command,
successCallback (data) {
spinner.stop()
diff --git a/packages/taro-components-advanced/src/components/virtual-list/react/list.ts b/packages/taro-components-advanced/src/components/virtual-list/react/list.ts
index f687c5158ba3..01fda151bb5d 100644
--- a/packages/taro-components-advanced/src/components/virtual-list/react/list.ts
+++ b/packages/taro-components-advanced/src/components/virtual-list/react/list.ts
@@ -291,7 +291,7 @@ export default class List extends React.PureComponent {
duration: 300,
}
if (isHorizontal) {
- option.left = scrollOffset
+ option.left = scrollOffset
} else {
option.top = scrollOffset
}
diff --git a/packages/taro-components-advanced/src/components/virtual-list/react/wrapper.ts b/packages/taro-components-advanced/src/components/virtual-list/react/wrapper.ts
index 5371ea39d890..db4d91355461 100644
--- a/packages/taro-components-advanced/src/components/virtual-list/react/wrapper.ts
+++ b/packages/taro-components-advanced/src/components/virtual-list/react/wrapper.ts
@@ -29,7 +29,7 @@ function getRenderExpandNodes ({
visibility: 'hidden',
height: isHorizontal ? '100%' : 100,
width: isHorizontal ? 100 : '100%',
- [isHorizontal ? isRtl ? 'marginRight' : 'marginLeft': 'marginTop']: -100,
+ [isHorizontal ? isRtl ? 'marginRight' : 'marginLeft' : 'marginTop']: -100,
zIndex: -1,
}
}
@@ -81,7 +81,7 @@ const outerWrapper = React.forwardRef(
...rest
}, [
getRenderExpandNodes({
- direction: isHorizontal ? isRtl ? 'right' : 'left': 'top',
+ direction: isHorizontal ? isRtl ? 'right' : 'left' : 'top',
isHorizontal,
isRtl,
id,
diff --git a/packages/taro-components-advanced/src/components/virtual-list/vue/list.ts b/packages/taro-components-advanced/src/components/virtual-list/vue/list.ts
index b5767b370b09..a78a87fadc03 100644
--- a/packages/taro-components-advanced/src/components/virtual-list/vue/list.ts
+++ b/packages/taro-components-advanced/src/components/virtual-list/vue/list.ts
@@ -133,7 +133,7 @@ export default defineComponent({
duration: 300,
}
if (isHorizontal) {
- option.left = scrollOffset
+ option.left = scrollOffset
} else {
option.top = scrollOffset
}
@@ -443,7 +443,7 @@ export default defineComponent({
visibility: 'hidden',
height: isHorizontal ? '100%' : 100,
width: isHorizontal ? 100 : '100%',
- [isHorizontal ? isRtl ? 'marginRight' : 'marginLeft': 'marginTop']: -100,
+ [isHorizontal ? isRtl ? 'marginRight' : 'marginLeft' : 'marginTop']: -100,
zIndex: -1,
}
}
diff --git a/packages/taro-components-advanced/src/utils/math.ts b/packages/taro-components-advanced/src/utils/math.ts
index 63c914b5f5b9..16be4bf6bfe4 100644
--- a/packages/taro-components-advanced/src/utils/math.ts
+++ b/packages/taro-components-advanced/src/utils/math.ts
@@ -4,7 +4,7 @@ export function getMiddleNumber (...list: number[]) {
export function isCosDistributing (list: number[], datum = 0) {
let flags = 0
- for(let i = 0; i < list.length - 1; i++) {
+ for (let i = 0; i < list.length - 1; i++) {
if (getMiddleNumber(list[i], datum, list[i + 1]) === datum) {
flags++
}
diff --git a/packages/taro-components-advanced/src/utils/vue-render.ts b/packages/taro-components-advanced/src/utils/vue-render.ts
index 303d398f2376..ce92ada10815 100644
--- a/packages/taro-components-advanced/src/utils/vue-render.ts
+++ b/packages/taro-components-advanced/src/utils/vue-render.ts
@@ -8,7 +8,7 @@ export default function (componentName: string, options?: Record, c
const name = `on${key.charAt(0).toUpperCase()}${key.slice(1)}`
el[name] = on[key]
})
- return h(componentName, { ...attrs, ...props, ...slots, ... el }, children)
+ return h(componentName, { ...attrs, ...props, ...slots, ...el }, children)
}
return h(componentName, options, children)
}
diff --git a/packages/taro-components-library-vue2/src/vue-component-lib/utils.ts b/packages/taro-components-library-vue2/src/vue-component-lib/utils.ts
index 1e92f9adfa4f..fb7a54f61326 100644
--- a/packages/taro-components-library-vue2/src/vue-component-lib/utils.ts
+++ b/packages/taro-components-library-vue2/src/vue-component-lib/utils.ts
@@ -2,7 +2,7 @@
* Modify from https://github.com/diondree/stencil-vue2-output-target/blob/master/vue-component-lib/utils.ts
* MIT License https://github.com/diondree/stencil-vue2-output-target/blob/master/LICENSE.md
*/
-import Vue, { CreateElement,VNode } from 'vue'
+import Vue, { CreateElement, VNode } from 'vue'
export const createCommonMethod = (methodName: string) =>
function (...args: any[]) {
diff --git a/packages/taro-components-library-vue3/src/vue-component-lib/utils.ts b/packages/taro-components-library-vue3/src/vue-component-lib/utils.ts
index 0bf2f8f159c9..2d101bfd68d0 100644
--- a/packages/taro-components-library-vue3/src/vue-component-lib/utils.ts
+++ b/packages/taro-components-library-vue3/src/vue-component-lib/utils.ts
@@ -2,7 +2,7 @@
* Modify from https://github.com/ionic-team/stencil-ds-output-targets/blob/main/packages/vue-output-target/vue-component-lib/utils.ts
* MIT License https://github.com/ionic-team/stencil-ds-output-targets/blob/main/LICENSE
*/
-import { defineComponent, getCurrentInstance, h, inject, Ref,ref, VNode } from 'vue'
+import { defineComponent, getCurrentInstance, h, inject, Ref, ref, VNode } from 'vue'
export interface InputProps {
modelValue?: T
diff --git a/packages/taro-components-react/src/components/button/index.tsx b/packages/taro-components-react/src/components/button/index.tsx
index 6814861beee2..2d07c7d0da30 100644
--- a/packages/taro-components-react/src/components/button/index.tsx
+++ b/packages/taro-components-react/src/components/button/index.tsx
@@ -5,7 +5,7 @@ import React from 'react'
import { omit } from '../../utils'
-interface IProps extends Omit, 'type'> {
+interface IProps extends Omit, 'type'> {
size?: string
plain?: boolean
hoverClass?: string
diff --git a/packages/taro-components-react/src/components/input/index.tsx b/packages/taro-components-react/src/components/input/index.tsx
index a914973f075d..68a7739fd0d6 100644
--- a/packages/taro-components-react/src/components/input/index.tsx
+++ b/packages/taro-components-react/src/components/input/index.tsx
@@ -77,7 +77,7 @@ class Input extends React.Component {
}
UNSAFE_componentWillReceiveProps (nextProps: Readonly) {
- if(!this.props.focus && nextProps.focus && this.inputRef) this.inputRef.focus()
+ if (!this.props.focus && nextProps.focus && this.inputRef) this.inputRef.focus()
}
diff --git a/packages/taro-components/__mocks__/swiper/swiper-bundle.esm.js.ts b/packages/taro-components/__mocks__/swiper/swiper-bundle.esm.js.ts
index f8314d4e6287..b5824eba07cd 100644
--- a/packages/taro-components/__mocks__/swiper/swiper-bundle.esm.js.ts
+++ b/packages/taro-components/__mocks__/swiper/swiper-bundle.esm.js.ts
@@ -115,7 +115,7 @@ export default class Swiper implements ISwiper {
return false
}
- getBreakpoint (breakpoints: { [width: number]: SwiperOptions,[ratio: string]: SwiperOptions } | undefined): string {
+ getBreakpoint (breakpoints: { [width: number]: SwiperOptions, [ratio: string]: SwiperOptions } | undefined): string {
return ''
}
diff --git a/packages/taro-components/__tests__/checkbox.e2e.ts b/packages/taro-components/__tests__/checkbox.e2e.ts
index 71fa58b2f25a..eebd6e39140f 100644
--- a/packages/taro-components/__tests__/checkbox.e2e.ts
+++ b/packages/taro-components/__tests__/checkbox.e2e.ts
@@ -42,7 +42,7 @@ describe('Checkbox', () => {
/>`).join('')}
`,
})
-
+
await page.waitForChanges()
const el = await page.find('taro-checkbox-group-core')
const inputList = await page.findAll('input')
diff --git a/packages/taro-components/__tests__/video.spec.tsx b/packages/taro-components/__tests__/video.spec.tsx
index 6cf358ae6678..55cd745f504b 100644
--- a/packages/taro-components/__tests__/video.spec.tsx
+++ b/packages/taro-components/__tests__/video.spec.tsx
@@ -130,7 +130,7 @@ describe('Video', () => {
video.play = play
await video?.play()
await page.waitForChanges()
-
+
expect(play.mock.calls.length).toBe(1)
expect(page.root).toMatchSnapshot()
@@ -150,7 +150,7 @@ describe('Video', () => {
video.pause = pause
await video?.pause()
await page.waitForChanges()
-
+
expect(pause.mock.calls.length).toBe(1)
expect(page.root).toMatchSnapshot()
diff --git a/packages/taro-components/scripts/json-schema-to-types.ts b/packages/taro-components/scripts/json-schema-to-types.ts
index 66cd8f075d19..8dd934f7efad 100644
--- a/packages/taro-components/scripts/json-schema-to-types.ts
+++ b/packages/taro-components/scripts/json-schema-to-types.ts
@@ -279,7 +279,8 @@ class GenerateTypes {
this.formatJSDoc(ast)
const result = generator(ast)
const code = prettify(result.code, {
- parser: 'typescript', semi: false,
+ parser: 'typescript',
+ semi: false,
singleQuote: true,
printWidth: 120
})
diff --git a/packages/taro-components/scripts/stencil/plugin/sass-plugin.ts b/packages/taro-components/scripts/stencil/plugin/sass-plugin.ts
index e6fad2595bb7..76d0e93d49d6 100644
--- a/packages/taro-components/scripts/stencil/plugin/sass-plugin.ts
+++ b/packages/taro-components/scripts/stencil/plugin/sass-plugin.ts
@@ -31,8 +31,8 @@ export default function sassPlugin (opts: d.PluginOptions = {}): d.Plugin {
*/
transform (sourceText: string, fileName: string, context: d.PluginCtx): Promise {
if (
- !usePlugin(fileName)
- || typeof sourceText !== 'string'
+ !usePlugin(fileName) ||
+ typeof sourceText !== 'string'
) {
// @ts-ignore
return null
diff --git a/packages/taro-components/src/utils/index.ts b/packages/taro-components/src/utils/index.ts
index 702773d04c65..a17b3ed5db95 100755
--- a/packages/taro-components/src/utils/index.ts
+++ b/packages/taro-components/src/utils/index.ts
@@ -34,7 +34,7 @@ export * from './style'
export * from './url'
export function isVisible (e: HTMLElement) {
- return !!( e.offsetWidth || e.offsetHeight || e.getClientRects().length )
+ return !!(e.offsetWidth || e.offsetHeight || e.getClientRects().length)
}
export function isElement (e: HTMLElement) {
diff --git a/packages/taro-h5/__tests__/base/pxTransform.test.ts b/packages/taro-h5/__tests__/base/pxTransform.test.ts
index 3da61115ca49..ff756296eb4a 100644
--- a/packages/taro-h5/__tests__/base/pxTransform.test.ts
+++ b/packages/taro-h5/__tests__/base/pxTransform.test.ts
@@ -76,5 +76,4 @@ describe('pxtransform', () => {
})
expect(Taro.pxTransform(320)).toBe('50vw')
})
-
})
diff --git a/packages/taro-h5/__tests__/ui/animation.test.ts b/packages/taro-h5/__tests__/ui/animation.test.ts
index 025030d89821..8cde3662a786 100644
--- a/packages/taro-h5/__tests__/ui/animation.test.ts
+++ b/packages/taro-h5/__tests__/ui/animation.test.ts
@@ -5,16 +5,16 @@ describe('createAnimation', () => {
const ani: any = Taro.createAnimation()
const { rules, transform } = ani
ani.left(10)
- expect(rules[0]).toEqual({ 'key': 'left', 'rule': 'left: 10px' })
+ expect(rules[0]).toEqual({ key: 'left', rule: 'left: 10px' })
ani.top('10')
- expect(rules[1]).toEqual({ 'key': 'top', 'rule': 'top: 10px' })
+ expect(rules[1]).toEqual({ key: 'top', rule: 'top: 10px' })
ani.right('10%')
- expect(rules[2]).toEqual({ 'key': 'right', 'rule': 'right: 10%' })
+ expect(rules[2]).toEqual({ key: 'right', rule: 'right: 10%' })
ani.translate(10, '10%')
- expect(transform[0]).toEqual({ 'key': 'translate', 'transform': 'translate(10px, 10%)' })
+ expect(transform[0]).toEqual({ key: 'translate', transform: 'translate(10px, 10%)' })
ani.translateX('10')
- expect(transform[1]).toEqual({ 'key': 'translateX', 'transform': 'translateX(10px)' })
+ expect(transform[1]).toEqual({ key: 'translateX', transform: 'translateX(10px)' })
ani.translate3d('10', 10, '20%')
- expect(transform[2]).toEqual({ 'key': 'translate3d', 'transform': 'translate3d(10px, 10px, 20%)' })
+ expect(transform[2]).toEqual({ key: 'translate3d', transform: 'translate3d(10px, 10px, 20%)' })
})
})
diff --git a/packages/taro-h5/__tests__/ui/navigation.test.ts b/packages/taro-h5/__tests__/ui/navigation.test.ts
index f72757b085f6..cac40c9ba0dc 100644
--- a/packages/taro-h5/__tests__/ui/navigation.test.ts
+++ b/packages/taro-h5/__tests__/ui/navigation.test.ts
@@ -86,7 +86,7 @@ describe('navigation', () => {
expect(res.errMsg).toBe('showNavigationBarLoading:ok')
const loadingElement = document.querySelector('.taro-navigation-bar-loading-show')
expect(loadingElement).toBeTruthy()
-
+
Taro.hideNavigationBarLoading().then(res => {
expect(res.errMsg).toBe('hideNavigationBarLoading:ok')
const loadingElement = document.querySelector('.taro-navigation-bar-loading-show')
diff --git a/packages/taro-h5/src/api/device/calendar.ts b/packages/taro-h5/src/api/device/calendar.ts
index 888d47619549..bef70c815e5e 100644
--- a/packages/taro-h5/src/api/device/calendar.ts
+++ b/packages/taro-h5/src/api/device/calendar.ts
@@ -102,7 +102,7 @@ export const addPhoneRepeatCalendar: typeof Taro.addPhoneRepeatCalendar = (optio
return handle.success()
}
-export const addPhoneCalendar: typeof Taro.addPhoneCalendar = (options) => {
+export const addPhoneCalendar: typeof Taro.addPhoneCalendar = (options) => {
const methodName = 'addPhoneCalendar'
// options must be an Object
const isObject = shouldBeObject(options)
diff --git a/packages/taro-h5/src/api/location/chooseLocation.ts b/packages/taro-h5/src/api/location/chooseLocation.ts
index 193d22ea09ce..5d9b112bfc32 100644
--- a/packages/taro-h5/src/api/location/chooseLocation.ts
+++ b/packages/taro-h5/src/api/location/chooseLocation.ts
@@ -82,7 +82,7 @@ export const chooseLocation: typeof Taro.chooseLocation = ({ success, fail, comp
errMsg: 'LOCATION_APIKEY needed'
}, { resolve, reject })
}
-
+
const key = LOCATION_APIKEY
const onMessage = event => {
diff --git a/packages/taro-h5/src/api/location/locationChange.ts b/packages/taro-h5/src/api/location/locationChange.ts
index af0b433ddf3a..a97cddb94032 100644
--- a/packages/taro-h5/src/api/location/locationChange.ts
+++ b/packages/taro-h5/src/api/location/locationChange.ts
@@ -1,4 +1,4 @@
-import { processOpenApi,shouldBeObject } from '../../utils'
+import { processOpenApi, shouldBeObject } from '../../utils'
import { CallbackManager, MethodHandler } from '../../utils/handler'
import { isGeolocationSupported } from './utils'
@@ -23,7 +23,7 @@ export function offLocationChange (callback: Taro.onLocationChange.Callback): vo
export function onLocationChangeError (callback: Taro.onLocationChange.Callback): void {
_errorCbManager.add(callback)
}
-
+
export function offLocationChangeError (callback: Taro.onLocationChange.Callback): void {
if (callback && typeof callback === 'function') {
_errorCbManager.remove(callback)
@@ -36,8 +36,8 @@ export function offLocationChangeError (callback: Taro.onLocationChange.Callback
/**
* 开始监听位置信息
- * @param opts
- * @returns
+ * @param opts
+ * @returns
*/
function startLocationUpdateByW3CApi (opts: Taro.startLocationUpdate.Option): Promise {
// 断言 options 必须是 Object
@@ -93,8 +93,8 @@ function startLocationUpdateByW3CApi (opts: Taro.startLocationUpdate.Option): Pr
/**
* 停止监听位置信息
- * @param opts
- * @returns
+ * @param opts
+ * @returns
*/
function stopLocationUpdateByW3CApi (opts: Taro.stopLocationUpdate.Option): Promise {
const isObject = shouldBeObject(opts)
@@ -103,7 +103,7 @@ function stopLocationUpdateByW3CApi (opts: Taro.stopLocationUpdate.Option): Prom
console.error(res.errMsg)
return Promise.reject(res)
}
-
+
const { success, fail, complete } = opts
const handle = new MethodHandler({ name: 'stopLocationUpdate', success, fail, complete })
diff --git a/packages/taro-h5/src/api/media/audio/InnerAudioContext.ts b/packages/taro-h5/src/api/media/audio/InnerAudioContext.ts
index 550ebeca17de..0c10670adb86 100644
--- a/packages/taro-h5/src/api/media/audio/InnerAudioContext.ts
+++ b/packages/taro-h5/src/api/media/audio/InnerAudioContext.ts
@@ -31,7 +31,7 @@ export class InnerAudioContext implements Taro.InnerAudioContext {
const { currentTime = 0, buffered: timeRange } = this.Instance || {}
if (timeRange) {
for (let i = 0; i < timeRange.length; i++) {
- if(timeRange.start(i) <= currentTime && timeRange.end(i) >= currentTime) {
+ if (timeRange.start(i) <= currentTime && timeRange.end(i) >= currentTime) {
return timeRange.end(i)
}
}
diff --git a/packages/taro-h5/src/api/media/background-audio/BackgroundAudioManager.ts b/packages/taro-h5/src/api/media/background-audio/BackgroundAudioManager.ts
index 71ab568bde36..5942278a9f62 100644
--- a/packages/taro-h5/src/api/media/background-audio/BackgroundAudioManager.ts
+++ b/packages/taro-h5/src/api/media/background-audio/BackgroundAudioManager.ts
@@ -47,7 +47,7 @@ export class BackgroundAudioManager implements Taro.BackgroundAudioManager {
const { currentTime = 0, buffered: timeRange } = this.Instance || {}
if (timeRange) {
for (let i = 0; i < timeRange.length; i++) {
- if(timeRange.start(i) <= currentTime && timeRange.end(i) >= currentTime) {
+ if (timeRange.start(i) <= currentTime && timeRange.end(i) >= currentTime) {
return timeRange.end(i)
}
}
diff --git a/packages/taro-h5/src/api/media/video/chooseMedia.ts b/packages/taro-h5/src/api/media/video/chooseMedia.ts
index 6d7ce9a2df3c..8810258cf541 100644
--- a/packages/taro-h5/src/api/media/video/chooseMedia.ts
+++ b/packages/taro-h5/src/api/media/video/chooseMedia.ts
@@ -33,8 +33,8 @@ export const chooseMedia = async function (
complete,
} = options
const handle = new MethodHandler({ name: methodName, success, fail, complete })
- const withImage = mediaType.length < 1 || mediaType.indexOf('image') > -1
- const withVideo = mediaType.length < 1 || mediaType.indexOf('video') > -1
+ const withImage = mediaType.length < 1 || mediaType.indexOf('image') > -1
+ const withVideo = mediaType.length < 1 || mediaType.indexOf('video') > -1
const res: Partial = {
tempFiles: [],
type: withImage && withVideo ? 'mix' : withImage ? 'image' : 'video',
diff --git a/packages/taro-h5/src/api/network/upload.ts b/packages/taro-h5/src/api/network/upload.ts
index 4ed787aff570..5346e4ca0b09 100644
--- a/packages/taro-h5/src/api/network/upload.ts
+++ b/packages/taro-h5/src/api/network/upload.ts
@@ -138,7 +138,7 @@ const createUploadTask = ({ url, filePath, formData = {}, name, header, timeout,
/**
* 将本地资源上传到服务器。客户端发起一个 HTTPS POST 请求,其中 content-type 为 multipart/form-data。使用前请注意阅读相关说明。
*/
-export const uploadFile: typeof Taro.uploadFile = ({ url, filePath, name, header, formData, timeout, fileName,withCredentials, success, fail, complete }) => {
+export const uploadFile: typeof Taro.uploadFile = ({ url, filePath, name, header, formData, timeout, fileName, withCredentials, success, fail, complete }) => {
let task!: Taro.UploadTask
const result: ReturnType = new Promise((resolve, reject) => {
task = createUploadTask({
diff --git a/packages/taro-h5/src/api/taro.ts b/packages/taro-h5/src/api/taro.ts
index 607affe4ed02..6fe5903fa3d8 100644
--- a/packages/taro-h5/src/api/taro.ts
+++ b/packages/taro-h5/src/api/taro.ts
@@ -79,9 +79,9 @@ const pxTransform = function (size = 0) {
const config = getConfig.call(this)
const baseFontSize = config.baseFontSize || defaultBaseFontSize
const deviceRatio = config.deviceRatio || defaultDesignRatio
- const designWidth = (((input = 0) => isFunction(config.designWidth)
+ const designWidth = ((input = 0) => isFunction(config.designWidth)
? config.designWidth(input)
- : config.designWidth))(size)
+ : config.designWidth)(size)
if (!(designWidth in config.deviceRatio)) {
throw new Error(`deviceRatio 配置中不存在 ${designWidth} 的设置!`)
}
diff --git a/packages/taro-h5/src/api/wxml/IntersectionObserver.ts b/packages/taro-h5/src/api/wxml/IntersectionObserver.ts
index d0092e2873ff..f6569bbc04f4 100644
--- a/packages/taro-h5/src/api/wxml/IntersectionObserver.ts
+++ b/packages/taro-h5/src/api/wxml/IntersectionObserver.ts
@@ -10,7 +10,6 @@ type TListener = {
}
export class TaroH5IntersectionObserver implements Taro.IntersectionObserver {
-
// 自定义组件实例
private _component: TaroGeneral.IAnyObject
// 选项
@@ -131,5 +130,4 @@ export class TaroH5IntersectionObserver implements Taro.IntersectionObserver {
const listener = this._listeners.find(listener => listener.element === element)
return listener ? listener.callback : null
}
-
}
diff --git a/packages/taro-h5/src/api/wxml/MediaQueryObserver.ts b/packages/taro-h5/src/api/wxml/MediaQueryObserver.ts
index 3a18986a1361..5bcbfa7b9b7a 100644
--- a/packages/taro-h5/src/api/wxml/MediaQueryObserver.ts
+++ b/packages/taro-h5/src/api/wxml/MediaQueryObserver.ts
@@ -57,5 +57,4 @@ export class MediaQueryObserver implements Taro.MediaQueryObserver {
}
}
}
-
}
diff --git a/packages/taro-helper/scripts/backup.js b/packages/taro-helper/scripts/backup.js
index 22f2a4800c97..84fd129d0975 100644
--- a/packages/taro-helper/scripts/backup.js
+++ b/packages/taro-helper/scripts/backup.js
@@ -7,7 +7,7 @@ if (process.env.CI &&
process.env.CI.toLowerCase() !== 'false')
) {
// 判断是否为 CI 环境,CI 环境不走 backup 逻辑,否则两个 wasm 会被覆盖
- return
+ return
}
plugins.forEach(plugin => {
diff --git a/packages/taro-helper/src/dotenv.ts b/packages/taro-helper/src/dotenv.ts
index f8f5bc21faa1..9b8171b90b23 100644
--- a/packages/taro-helper/src/dotenv.ts
+++ b/packages/taro-helper/src/dotenv.ts
@@ -18,7 +18,7 @@ export const dotenvParse = (root: string, prefixs: string | string[] = ['TARO_AP
/** local file */ `.env.local`,
])
- if(mode) {
+ if (mode) {
envFiles.add(/** mode file */ `.env.${mode}`)
envFiles.add(/** mode local file */ `.env.${mode}.local`)
}
@@ -26,7 +26,7 @@ export const dotenvParse = (root: string, prefixs: string | string[] = ['TARO_AP
let parseTemp = {}
const load = envPath => {
// file doesn'et exist
- if(!fs.existsSync(envPath)) return
+ if (!fs.existsSync(envPath)) return
const env = parse(fs.readFileSync(envPath))
parseTemp = {
...parseTemp,
@@ -40,7 +40,7 @@ export const dotenvParse = (root: string, prefixs: string | string[] = ['TARO_AP
const parsed = {}
Object.entries(parseTemp).forEach(([key, value]) => {
- if(prefixsArr.some(prefix => key.startsWith(prefix)) || ['TARO_APP_ID'].includes(key)) {
+ if (prefixsArr.some(prefix => key.startsWith(prefix)) || ['TARO_APP_ID'].includes(key)) {
parsed[key] = value
}
})
diff --git a/packages/taro-jd/src/apis.ts b/packages/taro-jd/src/apis.ts
index ee88bdab9b7b..c6d3c9bf509b 100644
--- a/packages/taro-jd/src/apis.ts
+++ b/packages/taro-jd/src/apis.ts
@@ -4,7 +4,7 @@ declare const jd: any
export function initNativeApi (taro) {
processApis(taro, jd)
-
+
taro.getTabBar = function (pageCtx) {
if (typeof pageCtx?.getTabBar === 'function') {
return pageCtx.getTabBar()?.$taroInstances
diff --git a/packages/taro-loader/src/native-component.ts b/packages/taro-loader/src/native-component.ts
index 1a6aa0af8774..da39bdee7ec5 100644
--- a/packages/taro-loader/src/native-component.ts
+++ b/packages/taro-loader/src/native-component.ts
@@ -8,7 +8,7 @@ import type * as webpack from 'webpack'
export default function (this: webpack.LoaderContext, source: string) {
const options = getOptions(this)
- const { loaderMeta = {}, config: loaderConfig, isNewBlended = false, runtimePath } = options
+ const { loaderMeta = {}, config: loaderConfig, isNewBlended = false, runtimePath } = options
const { importFrameworkStatement, frameworkArgs, isNeedRawLoader, creatorLocation } = loaderMeta
const config = getPageConfig(loaderConfig, this.resourcePath)
config.isNewBlended = isNewBlended
diff --git a/packages/taro-mini-runner/src/loaders/miniXScriptLoader.ts b/packages/taro-mini-runner/src/loaders/miniXScriptLoader.ts
index 680ae363e7b2..340c97638e76 100644
--- a/packages/taro-mini-runner/src/loaders/miniXScriptLoader.ts
+++ b/packages/taro-mini-runner/src/loaders/miniXScriptLoader.ts
@@ -1,6 +1,6 @@
import { isUrlRequest, urlToRequest } from 'loader-utils'
-export default async function (source) {
+export default async function (source) {
const REG_REQUIRE = /require\(['"](.+\.wxs)['"]\)/g
const callback = this.async()
@@ -26,7 +26,7 @@ export default async function (source) {
)
}
}
-
+
await Promise.all(importings)
callback(null, source)
} catch (error) {
diff --git a/packages/taro-mini-runner/src/plugins/MiniPlugin.ts b/packages/taro-mini-runner/src/plugins/MiniPlugin.ts
index 91ca4547d41c..b68f76809762 100644
--- a/packages/taro-mini-runner/src/plugins/MiniPlugin.ts
+++ b/packages/taro-mini-runner/src/plugins/MiniPlugin.ts
@@ -713,9 +713,9 @@ export default class TaroMiniPlugin {
// 判断是否为第三方依赖的正则,如果 test 为 false 则为第三方依赖
const notNpmPkgReg = /^[.\\/]/
if (
- !this.options.skipProcessUsingComponents
- && !compPath.startsWith('plugin://')
- && !notNpmPkgReg.test(compPath)
+ !this.options.skipProcessUsingComponents &&
+ !compPath.startsWith('plugin://') &&
+ !notNpmPkgReg.test(compPath)
) {
const tempCompPath = getNpmPackageAbsolutePath(compPath)
@@ -1109,7 +1109,7 @@ export default class TaroMiniPlugin {
})
this.adjustConfigContent(config)
-
+
const fileConfigStr = JSON.stringify(config)
compilation.assets[fileConfigName] = {
size: () => fileConfigStr.length,
diff --git a/packages/taro-platform-h5/build/definition-json/parser.ts b/packages/taro-platform-h5/build/definition-json/parser.ts
index a601e3d1de32..193bb1c10db8 100644
--- a/packages/taro-platform-h5/build/definition-json/parser.ts
+++ b/packages/taro-platform-h5/build/definition-json/parser.ts
@@ -14,7 +14,7 @@ const tsconfig: ts.CompilerOptions = {
paths: {
'@tarojs/api': ['node_modules/@tarojs/taro/types']
},
- 'types': ['@tarojs/taro-h5/types']
+ types: ['@tarojs/taro-h5/types']
}
const CompRGX = /^Taro(.*)Core$/
const IgnoreSymbols = [
diff --git a/packages/taro-platform-h5/build/utils/ast.ts b/packages/taro-platform-h5/build/utils/ast.ts
index 70a625e2287f..1fa7d2021792 100644
--- a/packages/taro-platform-h5/build/utils/ast.ts
+++ b/packages/taro-platform-h5/build/utils/ast.ts
@@ -43,12 +43,12 @@ export function generateDocumentation (
function visitAST (node: ts.Node, o: DocEntry[]) {
// Only consider exported nodes
- if (!isNodeExported(node as ts.Declaration) || node.kind === ts.SyntaxKind.EndOfFileToken || node.kind === ts.SyntaxKind.DeclareKeyword
- || ts.isImportDeclaration(node) || ts.isImportEqualsDeclaration(node) || ts.isImportClause(node)
- || ts.isExportAssignment(node) || ts.isExportDeclaration(node)
- || ts.isExpressionStatement(node) || ts.isEmptyStatement(node)
- || ts.isStringLiteral(node)
- || node.kind === ts.SyntaxKind.ExportKeyword) {
+ if (!isNodeExported(node as ts.Declaration) || node.kind === ts.SyntaxKind.EndOfFileToken || node.kind === ts.SyntaxKind.DeclareKeyword ||
+ ts.isImportDeclaration(node) || ts.isImportEqualsDeclaration(node) || ts.isImportClause(node) ||
+ ts.isExportAssignment(node) || ts.isExportDeclaration(node) ||
+ ts.isExpressionStatement(node) || ts.isEmptyStatement(node) ||
+ ts.isStringLiteral(node) ||
+ node.kind === ts.SyntaxKind.ExportKeyword) {
return
}
@@ -136,7 +136,7 @@ export function generateDocumentation (
}
/** Serialize a types (type or interface) symbol information */
- function serializeType (symbol: ts.Symbol, name?: string, type?: keyof typeof ts.SyntaxKind): DocEntry {
+ function serializeType (symbol: ts.Symbol, name?: string, type?: keyof typeof ts.SyntaxKind): DocEntry {
// console.log(type, Object.keys(symbol))
const doc: DocEntry = serializeSymbol(symbol, name, type)
symbol.exports && symbol.exports.forEach((value) => {
diff --git a/packages/taro-platform-h5/build/utils/helper.ts b/packages/taro-platform-h5/build/utils/helper.ts
index 0705f7dcdaf3..2e7d7d233c81 100644
--- a/packages/taro-platform-h5/build/utils/helper.ts
+++ b/packages/taro-platform-h5/build/utils/helper.ts
@@ -47,8 +47,8 @@ export function isNotAPI (flags?: ts.SymbolFlags): flags is ts.SymbolFlags.Signa
}
export function isFunction (flags?: ts.SymbolFlags): flags is ts.SymbolFlags.Function | ts.SymbolFlags.Method {
- return SymbolFlags.includes((flags || -1) - ts.SymbolFlags.Function)
- || SymbolFlags.includes((flags || -1) - ts.SymbolFlags.Method)
+ return SymbolFlags.includes((flags || -1) - ts.SymbolFlags.Function) ||
+ SymbolFlags.includes((flags || -1) - ts.SymbolFlags.Method)
}
export function isOptional (flags?: ts.SymbolFlags): flags is ts.SymbolFlags.Optional {
diff --git a/packages/taro-platform-h5/src/program.ts b/packages/taro-platform-h5/src/program.ts
index f98356f366d5..63ce83c64c2c 100644
--- a/packages/taro-platform-h5/src/program.ts
+++ b/packages/taro-platform-h5/src/program.ts
@@ -6,8 +6,8 @@ import { resolveSync } from './utils'
import type { IPluginContext, TConfig } from '@tarojs/service'
const compLibraryAlias = {
- 'vue': 'vue2',
- 'vue3': 'vue3'
+ vue: 'vue2',
+ vue3: 'vue3'
}
const PACKAGE_NAME = '@tarojs/plugin-platform-h5'
diff --git a/packages/taro-platform-harmony-hybrid/build/definition-json/parseApis.ts b/packages/taro-platform-harmony-hybrid/build/definition-json/parseApis.ts
index 627085ab4c3c..c0afbee2c1cd 100644
--- a/packages/taro-platform-harmony-hybrid/build/definition-json/parseApis.ts
+++ b/packages/taro-platform-harmony-hybrid/build/definition-json/parseApis.ts
@@ -3,7 +3,7 @@ import * as pathModule from 'path'
/**
* 解析API注释信息
- *
+ *
* @returns { object } apisDefinition - 返回api支持情况对象
*/
export function parseApis () {
diff --git a/packages/taro-platform-harmony-hybrid/build/definition-json/parseCommponents.ts b/packages/taro-platform-harmony-hybrid/build/definition-json/parseCommponents.ts
index 3cf2f748b16b..272bceb487c7 100644
--- a/packages/taro-platform-harmony-hybrid/build/definition-json/parseCommponents.ts
+++ b/packages/taro-platform-harmony-hybrid/build/definition-json/parseCommponents.ts
@@ -1,7 +1,7 @@
import * as fsExtra from 'fs-extra'
import * as pathModule from 'path'
-import { capitalizeFirstLetter, convertCamelToDash,removeComments } from '../utils/helper'
+import { capitalizeFirstLetter, convertCamelToDash, removeComments } from '../utils/helper'
export function parseComponents () {
const entryPath = require.resolve('@tarojs/components/types/index.d.ts')
@@ -39,9 +39,9 @@ export function parseComponents () {
* 包括基本类型、基本类型数组、Aarry、Record、某些数组类型、对象类型或者单个对象等
* 例如MapProps.marker[]、('push' | 'pop')[]、{ [key: string]: number | string | any }、MapProps
*/
- if (baseType.includes(type) || baseTypeArray.includes(type) || type.includes('Array<')
- || type.includes('Record<') || type.includes('[]') || /^\{[\s\S]*?\}$/.test(type)
- || /^[A-Z][a-zA-Z]*?$/.test(type)) {
+ if (baseType.includes(type) || baseTypeArray.includes(type) || type.includes('Array<') ||
+ type.includes('Record<') || type.includes('[]') || /^\{[\s\S]*?\}$/.test(type) ||
+ /^[A-Z][a-zA-Z]*?$/.test(type)) {
return false
}
return true
@@ -164,14 +164,14 @@ export function parseComponents () {
.map(item => item.replace(/ +/g, ' '))
.map(item => item.replace(/([^:]+):\s?(.*)/g, '"$1":"$2"')) // 冒号前后的内容用双引号括起来以便进行JSON字符串转换
.join(',') // 将转换后的数组元素用逗号拼接起来
-
+
let propsObject: object
try {
propsObject = JSON.parse(`{${JSONStr}}`)
} catch (error) {
propsObject = {}
}
-
+
const result: object = {}
for (const [key, value] of Object.entries(propsObject)) {
const newKey = convertCamelToDash(key)
diff --git a/packages/taro-platform-harmony-hybrid/build/utils/getAnnotatedApis.ts b/packages/taro-platform-harmony-hybrid/build/utils/getAnnotatedApis.ts
index d60f89ed74e7..0fc80612303f 100644
--- a/packages/taro-platform-harmony-hybrid/build/utils/getAnnotatedApis.ts
+++ b/packages/taro-platform-harmony-hybrid/build/utils/getAnnotatedApis.ts
@@ -2,7 +2,7 @@ import * as fsExtra from 'fs-extra'
/**
* 获取comments.ts中注释的API列表
- *
+ *
* @returns api列表
*/
export function getAnnotatedApis () {
diff --git a/packages/taro-platform-harmony-hybrid/build/utils/getDeclaredApis.ts b/packages/taro-platform-harmony-hybrid/build/utils/getDeclaredApis.ts
index 562458529fc8..8df0d6a1d3e8 100644
--- a/packages/taro-platform-harmony-hybrid/build/utils/getDeclaredApis.ts
+++ b/packages/taro-platform-harmony-hybrid/build/utils/getDeclaredApis.ts
@@ -53,7 +53,7 @@ function getApisObj (declareContent: string) {
/**
* 获取taro已声明的API,不含Hooks/拓展API以及Taro官网的env/cloud/console
- *
+ *
* @returns 返回一个key为API名字,value为支持平台数组的对象
*/
export function getDeclaredApis () {
diff --git a/packages/taro-platform-harmony-hybrid/build/utils/getH5ExportApis.ts b/packages/taro-platform-harmony-hybrid/build/utils/getH5ExportApis.ts
index 5ebcdd6daa52..65a89a49ac67 100644
--- a/packages/taro-platform-harmony-hybrid/build/utils/getH5ExportApis.ts
+++ b/packages/taro-platform-harmony-hybrid/build/utils/getH5ExportApis.ts
@@ -5,7 +5,7 @@ import { removeComments } from './helper'
/**
* 匹配API定义文件,提取H5导出的API名字
- *
+ *
* @param h5ApiFiles 传入API定义文件列表
* @returns 返回api列表
*/
diff --git a/packages/taro-platform-harmony-hybrid/build/utils/helper.ts b/packages/taro-platform-harmony-hybrid/build/utils/helper.ts
index 6bff5e6fc806..6df6e4bc7552 100644
--- a/packages/taro-platform-harmony-hybrid/build/utils/helper.ts
+++ b/packages/taro-platform-harmony-hybrid/build/utils/helper.ts
@@ -60,7 +60,7 @@ export function removeFalseProperties (obj: object) {
/**
* 将属性值全部赋值为false
- * @param obj
+ * @param obj
*/
export function setPropertiesValue (obj: object) {
for (const prop in obj) {
diff --git a/packages/taro-platform-harmony-hybrid/src/api/apis/utils/index.ts b/packages/taro-platform-harmony-hybrid/src/api/apis/utils/index.ts
index f2264ae1a407..ae1af2a14e56 100644
--- a/packages/taro-platform-harmony-hybrid/src/api/apis/utils/index.ts
+++ b/packages/taro-platform-harmony-hybrid/src/api/apis/utils/index.ts
@@ -181,7 +181,7 @@ export function processOpenApi, TResult exten
const opts = formatOptions(Object.assign({}, defaultOptions, options))
if (isFunction(targetApi)) {
return new Promise((resolve, reject) => {
- ;['fail', 'success', 'complete'].forEach((k) => {
+ ['fail', 'success', 'complete'].forEach((k) => {
opts[k] = (preRef) => {
const res = formatResult(preRef)
options[k] && options[k](res)
diff --git a/packages/taro-plugin-html/src/constant.ts b/packages/taro-plugin-html/src/constant.ts
index 9b8c83411a9b..15f09df81097 100644
--- a/packages/taro-plugin-html/src/constant.ts
+++ b/packages/taro-plugin-html/src/constant.ts
@@ -44,7 +44,7 @@ export const specialElements = new Map([
['canvas', 'canvas'],
['a', {
mapName (props) {
- if(props.as && isString(props.as)) return props.as.toLowerCase()
+ if (props.as && isString(props.as)) return props.as.toLowerCase()
return !props.href || (/^javascript/.test(props.href)) ? 'view' : 'navigator'
},
mapNameCondition: ['href'],
diff --git a/packages/taro-plugin-http/src/__tests__/cookie.spec.js b/packages/taro-plugin-http/src/__tests__/cookie.spec.js
index 53bb61778813..075519519df3 100644
--- a/packages/taro-plugin-http/src/__tests__/cookie.spec.js
+++ b/packages/taro-plugin-http/src/__tests__/cookie.spec.js
@@ -85,5 +85,4 @@ describe('cookie', () => {
expect(cookie.getCookie(url1)).toBe('aaa=bbb; abc=cba; ggg=hhh; kkk=lll; ooo=ppp')
expect(cookie.getCookie(url4)).toBe('aaa=bbb; abc=cba; ggg=hhh; kkk=lll; mmm=nnn')
})
-
})
diff --git a/packages/taro-plugin-http/src/__tests__/dom.spec.js b/packages/taro-plugin-http/src/__tests__/dom.spec.js
index 54e994a74166..a90dab4d37cc 100644
--- a/packages/taro-plugin-http/src/__tests__/dom.spec.js
+++ b/packages/taro-plugin-http/src/__tests__/dom.spec.js
@@ -5,7 +5,6 @@ describe('DOM', () => {
global.document = runtime.document
describe('document', () => {
-
it('document setCookie', async () => {
expect(document.cookie).toBe('')
document.cookie = 'aaa=1111-2222-33-444-abcdefgasd; path=/; expires=Mon, 18 Jan 2038 19:14:07 GMT; secure;'
diff --git a/packages/taro-plugin-http/src/runtime/Cookie.ts b/packages/taro-plugin-http/src/runtime/Cookie.ts
index 91ee3bd7d3e1..70c75e33d064 100644
--- a/packages/taro-plugin-http/src/runtime/Cookie.ts
+++ b/packages/taro-plugin-http/src/runtime/Cookie.ts
@@ -1,5 +1,5 @@
/******************************************************************************
-Copyright (c) 2019 wechat-miniprogram.
+Copyright (c) 2019 wechat-miniprogram.
Reference and modify code by miniprogram-render/src/bom/cookie.js.
Permission to use, copy, modify, and/or distribute this software for any
diff --git a/packages/taro-plugin-http/src/runtime/XMLHttpRequest.ts b/packages/taro-plugin-http/src/runtime/XMLHttpRequest.ts
index 6614b4a321cc..6a050cfcdd36 100644
--- a/packages/taro-plugin-http/src/runtime/XMLHttpRequest.ts
+++ b/packages/taro-plugin-http/src/runtime/XMLHttpRequest.ts
@@ -63,20 +63,20 @@ function createXMLHttpRequestEvent (event: string, target:XMLHttpRequest, loaded
const e = createEvent(event) as XMLHttpRequestEvent
try {
Object.defineProperties(e, {
- 'currentTarget': {
+ currentTarget: {
enumerable: true,
value: target
},
- 'target': {
+ target: {
enumerable: true,
value: target
},
- 'loaded': {
+ loaded: {
enumerable: true,
value: loaded || 0
},
// 读 Content-Range 字段,目前来说作用不大,先和 loaded 保持一致
- 'total': {
+ total: {
enumerable: true,
value: loaded || 0
}
@@ -425,8 +425,7 @@ export class XMLHttpRequest extends Events {
}
getAllResponseHeaders () {
- if (this.#readyState === XMLHttpRequest.UNSENT || this.#readyState === XMLHttpRequest.OPENED || !this.#resHeader)
- return ''
+ if (this.#readyState === XMLHttpRequest.UNSENT || this.#readyState === XMLHttpRequest.OPENED || !this.#resHeader) { return '' }
return Object.keys(this.#resHeader)
.map((key) => `${key}: ${this.#resHeader![key]}`)
@@ -434,8 +433,7 @@ export class XMLHttpRequest extends Events {
}
getResponseHeader (name) {
- if (this.#readyState === XMLHttpRequest.UNSENT || this.#readyState === XMLHttpRequest.OPENED || !this.#resHeader)
- return null
+ if (this.#readyState === XMLHttpRequest.UNSENT || this.#readyState === XMLHttpRequest.OPENED || !this.#resHeader) { return null }
// 处理大小写不敏感
const key = Object.keys(this.#resHeader).find((item) => item.toLowerCase() === name.toLowerCase())
diff --git a/packages/taro-plugin-inject/src/index.ts b/packages/taro-plugin-inject/src/index.ts
index ac53c4030d1a..6ce0fe1f319a 100644
--- a/packages/taro-plugin-inject/src/index.ts
+++ b/packages/taro-plugin-inject/src/index.ts
@@ -35,7 +35,7 @@ export default (ctx: IPluginContext, options: IOptions) => {
} = options
const template = platform.template
- if(!template) return
+ if (!template) return
if (isArray(voidComponents)) {
voidComponents.forEach(el => template.voidElements.add(el))
diff --git a/packages/taro-plugin-inject/src/runtime.ts b/packages/taro-plugin-inject/src/runtime.ts
index e202fbe2acad..058a048f996a 100644
--- a/packages/taro-plugin-inject/src/runtime.ts
+++ b/packages/taro-plugin-inject/src/runtime.ts
@@ -1,6 +1,6 @@
import { mergeInternalComponents, mergeReconciler, processApis } from '@tarojs/shared'
-import { needPromiseApis,noPromiseApis } from './apis-list'
+import { needPromiseApis, noPromiseApis } from './apis-list'
import { components } from './components'
const hostConfig = {
diff --git a/packages/taro-plugin-mini-ci/src/AlipayCI.ts b/packages/taro-plugin-mini-ci/src/AlipayCI.ts
index 0cb143481d86..58d2d1700f68 100644
--- a/packages/taro-plugin-mini-ci/src/AlipayCI.ts
+++ b/packages/taro-plugin-mini-ci/src/AlipayCI.ts
@@ -19,7 +19,7 @@ export default class AlipayCI extends BaseCI {
}
const { fs, printLog, processTypeEnum, chalk } = this.ctx.helper
try {
- this.minidev = getNpmPkgSync('minidev',process.cwd())
+ this.minidev = getNpmPkgSync('minidev', process.cwd())
} catch (error) {
printLog(processTypeEnum.ERROR, chalk.red('请安装依赖:minidev'))
process.exit(1)
@@ -32,7 +32,7 @@ export default class AlipayCI extends BaseCI {
if (!privateKey) {
const privateKeyPath = path.isAbsolute(_privateKeyPath) ? _privateKeyPath : path.join(appPath, _privateKeyPath)
if (!fs.pathExistsSync(privateKeyPath)) {
- printLog(processTypeEnum.ERROR, chalk.red(`"alipay.privateKeyPath"选项配置的路径"${ privateKeyPath }"不存在,本次上传终止`))
+ printLog(processTypeEnum.ERROR, chalk.red(`"alipay.privateKeyPath"选项配置的路径"${privateKeyPath}"不存在,本次上传终止`))
process.exit(1)
} else {
privateKey = fs.readFileSync(privateKeyPath, 'utf-8')
@@ -47,7 +47,6 @@ export default class AlipayCI extends BaseCI {
}
}
})
-
}
async open () {
@@ -87,7 +86,7 @@ export default class AlipayCI extends BaseCI {
const qrcodeContent = await readQrcodeImageContent(qrcodeUrl)
// console.log('qrcodeContent', qrcodeContent)
await generateQrcodeImageFile(previewQrcodePath, qrcodeContent)
- printLog(processTypeEnum.REMIND, `预览版二维码已生成,存储在:"${ previewQrcodePath }",二维码内容是:"${ qrcodeContent }"`)
+ printLog(processTypeEnum.REMIND, `预览版二维码已生成,存储在:"${previewQrcodePath}",二维码内容是:"${qrcodeContent}"`)
this.triggerPreviewHooks({
success: true,
@@ -98,7 +97,7 @@ export default class AlipayCI extends BaseCI {
}
})
} catch (error) {
- printLog(processTypeEnum.ERROR, chalk.red(`预览上传失败 ${ new Date().toLocaleString() } \n${ error.message }`))
+ printLog(processTypeEnum.ERROR, chalk.red(`预览上传失败 ${new Date().toLocaleString()} \n${error.message}`))
this.triggerPreviewHooks({
success: false,
@@ -119,12 +118,12 @@ export default class AlipayCI extends BaseCI {
// SDK上传不支持设置描述信息; 版本号必须大于现有版本号
try {
- const lasterVersion = await this.minidev.minidev.app.getUploadedVersion({
+ const lasterVersion = await this.minidev.minidev.app.getUploadedVersion({
appId,
clientType
})
- if (this.version && compareVersion(this.version, lasterVersion) <=0) {
- printLog(processTypeEnum.ERROR, chalk.red(`上传版本号 "${ this.version }" 必须大于最新上传版本 "${ lasterVersion }"`))
+ if (this.version && compareVersion(this.version, lasterVersion) <= 0) {
+ printLog(processTypeEnum.ERROR, chalk.red(`上传版本号 "${this.version}" 必须大于最新上传版本 "${lasterVersion}"`))
}
const result = await this.minidev.minidev.upload({
project: this.projectPath,
@@ -152,7 +151,7 @@ export default class AlipayCI extends BaseCI {
},
})
} catch (error) {
- printLog(processTypeEnum.ERROR, chalk.red(`体验版上传失败 ${ new Date().toLocaleString() } \n${ error }`))
+ printLog(processTypeEnum.ERROR, chalk.red(`体验版上传失败 ${new Date().toLocaleString()} \n${error}`))
this.triggerUploadHooks({
success: false,
@@ -165,5 +164,4 @@ export default class AlipayCI extends BaseCI {
})
}
}
-
}
diff --git a/packages/taro-plugin-mini-ci/src/BaseCi.ts b/packages/taro-plugin-mini-ci/src/BaseCi.ts
index 5cc269dc10e1..20b627b758be 100644
--- a/packages/taro-plugin-mini-ci/src/BaseCi.ts
+++ b/packages/taro-plugin-mini-ci/src/BaseCi.ts
@@ -176,7 +176,6 @@ export default abstract class BaseCI {
)
this.version = pluginOpts.version || packageInfo.taroConfig?.version
this.desc = pluginOpts.desc || packageInfo.taroConfig?.desc || `CI构建自动构建于${new Date().toLocaleTimeString()}`
-
}
setProjectPath (path: string) {
@@ -204,7 +203,7 @@ export default abstract class BaseCI {
},
})
- if(!success) {
+ if (!success) {
process.exit(1)
}
}
@@ -230,7 +229,7 @@ export default abstract class BaseCI {
},
})
- if(!success) {
+ if (!success) {
process.exit(1)
}
}
diff --git a/packages/taro-plugin-mini-ci/src/DingtalkCI.ts b/packages/taro-plugin-mini-ci/src/DingtalkCI.ts
index 4e416102369f..cbe17741953c 100644
--- a/packages/taro-plugin-mini-ci/src/DingtalkCI.ts
+++ b/packages/taro-plugin-mini-ci/src/DingtalkCI.ts
@@ -24,7 +24,7 @@ export default class DingtalkCI extends BaseCI {
try {
this.dingtalkSDK = getNpmPkgSync('dingtalk-miniapp-opensdk', process.cwd()).sdk
} catch (error) {
- printLog( processTypeEnum.ERROR, chalk.red('请安装依赖:dingtalk-miniapp-opensdk , 该依赖用于CI预览、上传钉钉小程序'))
+ printLog(processTypeEnum.ERROR, chalk.red('请安装依赖:dingtalk-miniapp-opensdk , 该依赖用于CI预览、上传钉钉小程序'))
process.exit(1)
}
@@ -45,7 +45,7 @@ export default class DingtalkCI extends BaseCI {
// 和支付宝小程序共用ide
async open () {
- const { devToolsInstallPath, projectType = 'dingtalk-biz' } = this.pluginOpts.dd!
+ const { devToolsInstallPath, projectType = 'dingtalk-biz' } = this.pluginOpts.dd!
const { chalk, printLog, processTypeEnum } = this.ctx.helper
let minidev: AlipayInstance
try {
@@ -73,8 +73,8 @@ export default class DingtalkCI extends BaseCI {
// 特性: CI 内部会自己打印二维码; 预览版不会上传到后台,只有预览码作为入口访问
async preview () {
const { chalk, printLog, processTypeEnum } = this.ctx.helper
- const { appid, } = this.pluginOpts.dd!
-
+ const { appid, } = this.pluginOpts.dd!
+
try {
const previewUrl = await this.dingtalkSDK.previewBuild({
@@ -100,7 +100,7 @@ export default class DingtalkCI extends BaseCI {
const previewQrcodePath = path.join(this.projectPath, 'preview.png')
await generateQrcodeImageFile(previewQrcodePath, previewUrl)
- printLog(processTypeEnum.REMIND, `预览版二维码已生成,存储在:"${ previewQrcodePath }",二维码内容是:"${ previewUrl }"`)
+ printLog(processTypeEnum.REMIND, `预览版二维码已生成,存储在:"${previewQrcodePath}",二维码内容是:"${previewUrl}"`)
this.triggerPreviewHooks({
success: true,
@@ -111,7 +111,7 @@ export default class DingtalkCI extends BaseCI {
}
})
} catch (error) {
- printLog(processTypeEnum.ERROR, chalk.red(`预览失败 ${ new Date().toLocaleString() } \n${ error.message }`))
+ printLog(processTypeEnum.ERROR, chalk.red(`预览失败 ${new Date().toLocaleString()} \n${error.message}`))
this.triggerPreviewHooks({
success: false,
@@ -128,7 +128,7 @@ export default class DingtalkCI extends BaseCI {
// 特性: CI内部暂时未支持上传后返回体验码,等待官方支持: https://github.com/open-dingtalk/dingtalk-design-cli/issues/34
async upload () {
const { chalk, printLog, processTypeEnum } = this.ctx.helper
- const { appid } = this.pluginOpts.dd!
+ const { appid } = this.pluginOpts.dd!
printLog(processTypeEnum.START, '上传代码到钉钉小程序后台')
let hasDone = false
@@ -170,7 +170,7 @@ export default class DingtalkCI extends BaseCI {
})
// 体验码规则:dingtalk://dingtalkclient/action/open_micro_app?corpId=xxx&miniAppId=yyy&source=trial&version=构建id&agentId=xxx&pVersion=1&packageType=1
- console.log(chalk.green(`版本 ${ result.packageVersion } 上传成功 ${new Date().toLocaleString()}`))
+ console.log(chalk.green(`版本 ${result.packageVersion} 上传成功 ${new Date().toLocaleString()}`))
this.triggerUploadHooks({
success: true,
diff --git a/packages/taro-plugin-mini-ci/src/JdCI.ts b/packages/taro-plugin-mini-ci/src/JdCI.ts
index a5b8fc800646..49f0230d67c7 100644
--- a/packages/taro-plugin-mini-ci/src/JdCI.ts
+++ b/packages/taro-plugin-mini-ci/src/JdCI.ts
@@ -53,7 +53,7 @@ export default class JdCI extends BaseCI {
qrCodeLocalPath: previewQrcodePath
},
})
- } catch(error) {
+ } catch (error) {
console.log(chalk.red(`预览失败 ${new Date().toLocaleString()} \n${error.message}`))
this.triggerPreviewHooks({
success: false,
@@ -97,7 +97,7 @@ export default class JdCI extends BaseCI {
qrCodeLocalPath: uploadQrcodePath
},
})
- } catch(error) {
+ } catch (error) {
console.log(chalk.red(`上传失败 ${new Date().toLocaleString()} \n${error.message}`))
this.triggerUploadHooks({
success: false,
diff --git a/packages/taro-plugin-mini-ci/src/SwanCI.ts b/packages/taro-plugin-mini-ci/src/SwanCI.ts
index f19c11f9a7ab..0359c3346964 100644
--- a/packages/taro-plugin-mini-ci/src/SwanCI.ts
+++ b/packages/taro-plugin-mini-ci/src/SwanCI.ts
@@ -3,7 +3,7 @@ import * as path from 'path'
import * as shell from 'shelljs'
import BaseCI from './BaseCi'
-import { resolveNpmSync } from './utils/npm'
+import { resolveNpmSync } from './utils/npm'
import { generateQrcodeImageFile, printQrcode2Terminal } from './utils/qrcode'
export default class SwanCI extends BaseCI {
@@ -15,7 +15,7 @@ export default class SwanCI extends BaseCI {
}
const { chalk, printLog, processTypeEnum } = this.ctx.helper
try {
- this.swanBin = resolveNpmSync('swan-toolkit/bin/swan',process.cwd())
+ this.swanBin = resolveNpmSync('swan-toolkit/bin/swan', process.cwd())
} catch (error) {
printLog(processTypeEnum.ERROR, chalk.red('请安装依赖:swan-toolkit'))
process.exit(1)
@@ -50,7 +50,7 @@ export default class SwanCI extends BaseCI {
await generateQrcodeImageFile(previewQrcodePath, qrContent)
printLog(
processTypeEnum.REMIND,
- `预览二维码已生成,存储在:"${ previewQrcodePath }",二维码内容是:${ qrContent }`
+ `预览二维码已生成,存储在:"${previewQrcodePath}",二维码内容是:${qrContent}`
)
this.triggerPreviewHooks({
@@ -61,7 +61,6 @@ export default class SwanCI extends BaseCI {
qrCodeLocalPath: previewQrcodePath
}
})
-
} else {
this.triggerPreviewHooks({
success: false,
@@ -83,7 +82,7 @@ export default class SwanCI extends BaseCI {
shell.exec(`${this.swanBin} upload --project-path ${this.projectPath} --token ${this.pluginOpts.swan!.token} --release-version ${this.version} --min-swan-version ${this.pluginOpts.swan!.minSwanVersion || '3.350.6'} --desc ${this.desc} --json`, async (_code, stdout, stderr) => {
if (!stderr) {
console.log(chalk.green(`上传成功 ${new Date().toLocaleString()}`))
-
+
const stdoutRes = JSON.parse(stdout) as UploadResponse
const qrContent = stdoutRes.schemeUrl
const uploadQrcodePath = path.join(this.projectPath, 'upload.png')
@@ -92,9 +91,9 @@ export default class SwanCI extends BaseCI {
await generateQrcodeImageFile(uploadQrcodePath, qrContent)
printLog(
processTypeEnum.REMIND,
- `体验版二维码已生成,存储在:"${ uploadQrcodePath }",二维码内容是:${ qrContent }`
+ `体验版二维码已生成,存储在:"${uploadQrcodePath}",二维码内容是:${qrContent}`
)
-
+
this.triggerUploadHooks({
success: true,
data: {
@@ -116,7 +115,6 @@ export default class SwanCI extends BaseCI {
}
})
}
-
}
interface UploadResponse {
diff --git a/packages/taro-plugin-mini-ci/src/TTCI.ts b/packages/taro-plugin-mini-ci/src/TTCI.ts
index b8ed7702a02c..89d683a54df5 100644
--- a/packages/taro-plugin-mini-ci/src/TTCI.ts
+++ b/packages/taro-plugin-mini-ci/src/TTCI.ts
@@ -17,7 +17,7 @@ export default class TTCI extends BaseCI {
}
try {
// 调试使用版本是: tt-ide-cli@0.1.13
- this.tt = getNpmPkgSync('tt-ide-cli',process.cwd())
+ this.tt = getNpmPkgSync('tt-ide-cli', process.cwd())
} catch (error) {
printLog(processTypeEnum.ERROR, chalk.red('请安装依赖:tt-ide-cli'))
process.exit(1)
@@ -68,12 +68,12 @@ export default class TTCI extends BaseCI {
copyToClipboard: true,
cache: true
})
- console.log(chalk.green(`开发版上传成功 ${ new Date().toLocaleString() }\n`))
+ console.log(chalk.green(`开发版上传成功 ${new Date().toLocaleString()}\n`))
const qrContent = previewResult.shortUrl
await printQrcode2Terminal(qrContent)
printLog(
processTypeEnum.REMIND,
- `预览二维码已生成,存储在:"${ previewQrcodePath }",二维码内容是:${ qrContent },过期时间:${ new Date(previewResult.expireTime * 1000).toLocaleString() }`
+ `预览二维码已生成,存储在:"${previewQrcodePath}",二维码内容是:${qrContent},过期时间:${new Date(previewResult.expireTime * 1000).toLocaleString()}`
)
this.triggerPreviewHooks({
@@ -84,9 +84,8 @@ export default class TTCI extends BaseCI {
qrCodeLocalPath: previewQrcodePath
}
})
-
} catch (error) {
- printLog(processTypeEnum.ERROR, chalk.red(`上传失败 ${ new Date().toLocaleString() } \n${ error }`))
+ printLog(processTypeEnum.ERROR, chalk.red(`上传失败 ${new Date().toLocaleString()} \n${error}`))
this.triggerPreviewHooks({
success: false,
@@ -105,7 +104,7 @@ export default class TTCI extends BaseCI {
const { chalk, printLog, processTypeEnum } = this.ctx.helper
try {
printLog(processTypeEnum.START, '上传代码到字节跳动后台')
- printLog(processTypeEnum.REMIND, `本次上传版本号为:"${ this.version }",上传描述为:“${ this.desc }”`)
+ printLog(processTypeEnum.REMIND, `本次上传版本号为:"${this.version}",上传描述为:“${this.desc}”`)
const uploadQrcodePath = path.join(this.projectPath, 'upload.png')
const uploadResult = await this.tt.upload({
project: {
@@ -120,12 +119,12 @@ export default class TTCI extends BaseCI {
needUploadSourcemap: true,
copyToClipboard: false
})
- console.log(chalk.green(`体验版版上传成功 ${ new Date().toLocaleString() }\n`))
+ console.log(chalk.green(`体验版版上传成功 ${new Date().toLocaleString()}\n`))
const qrContent = uploadResult.shortUrl
await printQrcode2Terminal(qrContent)
printLog(
processTypeEnum.REMIND,
- `体验版二维码已生成,存储在:"${ uploadQrcodePath }",二维码内容是:"${ qrContent}", 过期时间:${ new Date(uploadResult.expireTime * 1000).toLocaleString() }`
+ `体验版二维码已生成,存储在:"${uploadQrcodePath}",二维码内容是:"${qrContent}", 过期时间:${new Date(uploadResult.expireTime * 1000).toLocaleString()}`
)
this.triggerUploadHooks({
@@ -137,7 +136,7 @@ export default class TTCI extends BaseCI {
}
})
} catch (error) {
- printLog(processTypeEnum.ERROR, chalk.red(`上传失败 ${ new Date().toLocaleString() } \n${ error }`))
+ printLog(processTypeEnum.ERROR, chalk.red(`上传失败 ${new Date().toLocaleString()} \n${error}`))
this.triggerUploadHooks({
success: false,
diff --git a/packages/taro-plugin-mini-ci/src/WeappCI.ts b/packages/taro-plugin-mini-ci/src/WeappCI.ts
index a67aeaa99a21..be1a58ca5d0e 100644
--- a/packages/taro-plugin-mini-ci/src/WeappCI.ts
+++ b/packages/taro-plugin-mini-ci/src/WeappCI.ts
@@ -1,7 +1,7 @@
/* eslint-disable no-console */
import * as crypto from 'crypto'
import * as ci from 'miniprogram-ci'
-import { Project }from 'miniprogram-ci'
+import { Project } from 'miniprogram-ci'
import * as os from 'os'
import * as path from 'path'
import * as shell from 'shelljs'
diff --git a/packages/taro-plugin-mini-ci/src/index.ts b/packages/taro-plugin-mini-ci/src/index.ts
index 8a70d1fe74ac..411489011e74 100644
--- a/packages/taro-plugin-mini-ci/src/index.ts
+++ b/packages/taro-plugin-mini-ci/src/index.ts
@@ -11,13 +11,13 @@ import WeappCI from './WeappCI'
import type { IPluginContext } from '@tarojs/service'
-const enum EnumAction {
+const enum EnumAction {
/** 自动打开预览工具 */
- 'open' = 'open' ,
+ 'open' = 'open',
/** 预览小程序(上传代码,作为“开发版”小程序) */
'preview' = 'preview',
/** 上传小程序(上传代码,可设置为“体验版”小程序) */
- 'upload' = 'upload' ,
+ 'upload' = 'upload',
}
interface MinimistArgs {
@@ -34,7 +34,7 @@ interface MinimistArgs {
export { CIOptions } from './BaseCi'
export default (ctx: IPluginContext, _pluginOpts: CIOptions | (() => CIOptions)) => {
const args = minimist(process.argv.slice(2), {
- boolean: [EnumAction.open,EnumAction.preview, EnumAction.upload],
+ boolean: [EnumAction.open, EnumAction.preview, EnumAction.upload],
string: ['projectPath'],
default: {
projectPath: ''
@@ -63,7 +63,7 @@ export default (ctx: IPluginContext, _pluginOpts: CIOptions | (() => CIOptions))
password: joi.string().required()
}),
/** 阿里小程序上传配置 */
- alipay:joi.alternatives().try(
+ alipay: joi.alternatives().try(
joi.object({
appid: joi.string().required(),
toolId: joi.string().required(),
@@ -211,5 +211,4 @@ export default (ctx: IPluginContext, _pluginOpts: CIOptions | (() => CIOptions))
}
})
})
-
}
diff --git a/packages/taro-plugin-react/src/loader-meta.ts b/packages/taro-plugin-react/src/loader-meta.ts
index e6fc3d528c19..abacc0d7a2a5 100644
--- a/packages/taro-plugin-react/src/loader-meta.ts
+++ b/packages/taro-plugin-react/src/loader-meta.ts
@@ -111,10 +111,10 @@ class App extends React.Component {
}
if (process.env.TARO_PLATFORM === 'web') {
- if(framework === 'react') {
+ if (framework === 'react') {
const react = require('react')
const majorVersion = Number((react.version || '18').split('.')[0])
- if( majorVersion >= 18) {
+ if (majorVersion >= 18) {
// Note: In react 18 or above, should using react-dom/client
loaderMeta.importFrameworkStatement = loaderMeta.importFrameworkStatement.replace('\'react-dom\'', '\'react-dom/client\'')
loaderMeta.extraImportForWeb += `import { findDOMNode, render, unstable_batchedUpdates } from 'react-dom'\n`
diff --git a/packages/taro-plugin-react/src/runtime/connect.ts b/packages/taro-plugin-react/src/runtime/connect.ts
index 135639d952fb..878af8a9337e 100644
--- a/packages/taro-plugin-react/src/runtime/connect.ts
+++ b/packages/taro-plugin-react/src/runtime/connect.ts
@@ -198,7 +198,7 @@ export function createReactApp (
appId = config?.appId || appId
}
const container = document.getElementById(appId)
- if((react.version || '').startsWith('18')){
+ if ((react.version || '').startsWith('18')) {
const root = ReactDOM.createRoot(container)
root.render?.(h(AppWrapper))
} else {
diff --git a/packages/taro-plugin-react/src/webpack.h5.ts b/packages/taro-plugin-react/src/webpack.h5.ts
index 732379b0d260..c086550299d9 100644
--- a/packages/taro-plugin-react/src/webpack.h5.ts
+++ b/packages/taro-plugin-react/src/webpack.h5.ts
@@ -46,7 +46,6 @@ export function modifyH5WebpackChain (ctx: IPluginContext, framework: Frameworks
}
},
})
-
}
function setLoader (framework: Frameworks, chain) {
diff --git a/packages/taro-plugin-vue3/src/webpack.mini.ts b/packages/taro-plugin-vue3/src/webpack.mini.ts
index 863fab2704e3..49c9a8ea36cf 100644
--- a/packages/taro-plugin-vue3/src/webpack.mini.ts
+++ b/packages/taro-plugin-vue3/src/webpack.mini.ts
@@ -64,7 +64,7 @@ function setVueLoader (ctx: IPluginContext, chain, data, config: IConfig) {
// v-html
const props = node.props
- if(props.find(prop => prop.type === 7 && prop.name === 'html')) {
+ if (props.find(prop => prop.type === 7 && prop.name === 'html')) {
['input', 'textarea', 'video', 'audio'].forEach(item => data.componentConfig.includes.add(item))
}
diff --git a/packages/taro-qq/src/components.ts b/packages/taro-qq/src/components.ts
index a75f41e70853..d4fd180d23f7 100644
--- a/packages/taro-qq/src/components.ts
+++ b/packages/taro-qq/src/components.ts
@@ -16,7 +16,7 @@ export const components = {
bindAddGroupApp: ''
},
Ad: {
- 'type': 'banner',
+ type: 'banner',
'ad-left': '',
'ad-top': '',
'ad-width': '',
diff --git a/packages/taro-react/src/event.ts b/packages/taro-react/src/event.ts
index 0c6355346057..bfda8ca37576 100644
--- a/packages/taro-react/src/event.ts
+++ b/packages/taro-react/src/event.ts
@@ -5,10 +5,10 @@ import { getFiberCurrentPropsFromNode, getInstanceFromNode, getNodeFromInstance
import { isTextInputElement, ReactDOMInputRestoreControlledState, ReactDOMTextareaRestoreControlledState, toString } from './domInput'
import { updateValueIfChanged } from './inputValueTracking'
import { Props } from './props'
-import { TaroReconciler } from './reconciler'
+import { TaroReconciler } from './reconciler'
-export type RestoreType = string | number | boolean | any[]
+export type RestoreType = string | number | boolean | any[]
interface RestoreItem {
target: TaroElement
diff --git a/packages/taro-react/src/index.ts b/packages/taro-react/src/index.ts
index 99560cc442b9..edf48cff3ef2 100644
--- a/packages/taro-react/src/index.ts
+++ b/packages/taro-react/src/index.ts
@@ -16,7 +16,7 @@ const unstable_batchedUpdates = (fn, a) => {
}
isInsideEventHandler = true
-
+
try {
return TaroReconciler.batchedUpdates(fn, a)
} finally {
diff --git a/packages/taro-react/src/props.ts b/packages/taro-react/src/props.ts
index 21956db1106a..8c4ac5051e7c 100644
--- a/packages/taro-react/src/props.ts
+++ b/packages/taro-react/src/props.ts
@@ -11,19 +11,19 @@ const IS_NON_DIMENSIONAL = /aspect|acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine
export function updateProps (dom: TaroElement, oldProps: Props, newProps: Props) {
const updatePayload = getUpdatePayload(dom, oldProps, newProps)
- if(updatePayload){
+ if (updatePayload) {
updatePropsByPayload(dom, oldProps, updatePayload)
}
}
-export function updatePropsByPayload (dom: TaroElement, oldProps: Props, updatePayload: any[]){
- for(let i = 0; i < updatePayload.length; i += 2){ // key, value 成对出现
- const key = updatePayload[i]; const newProp = updatePayload[i+1]; const oldProp = oldProps[key]
+export function updatePropsByPayload (dom: TaroElement, oldProps: Props, updatePayload: any[]) {
+ for (let i = 0; i < updatePayload.length; i += 2) { // key, value 成对出现
+ const key = updatePayload[i]; const newProp = updatePayload[i + 1]; const oldProp = oldProps[key]
setProperty(dom, key, newProp, oldProp)
}
}
-export function getUpdatePayload (dom: TaroElement, oldProps: Props, newProps: Props){
+export function getUpdatePayload (dom: TaroElement, oldProps: Props, newProps: Props) {
let i: string
let updatePayload: any[] | null = null
diff --git a/packages/taro-rn-runner/src/index.ts b/packages/taro-rn-runner/src/index.ts
index e8094cf7e39b..cb5f0e14e740 100644
--- a/packages/taro-rn-runner/src/index.ts
+++ b/packages/taro-rn-runner/src/index.ts
@@ -63,13 +63,13 @@ export default async function build (_appPath: string, config: any): Promise {
previewProd({
out: bundleOutput,
@@ -120,7 +120,7 @@ export default async function build (_appPath: string, config: any): Promise ext !== 'svg')
resolver.sourceExts.push('svg')
}
- if(blockList.length > 0){
+ if (blockList.length > 0) {
resolver.blockList = blockList
}
// 兼容0.60
diff --git a/packages/taro-rn-supporter/src/babel.ts b/packages/taro-rn-supporter/src/babel.ts
index dba90a029c53..8ac3d2113c31 100644
--- a/packages/taro-rn-supporter/src/babel.ts
+++ b/packages/taro-rn-supporter/src/babel.ts
@@ -41,7 +41,7 @@ function getEnv (config: IProjectConfig) {
function getDefineConstants (config: IProjectConfig) {
const env = getEnv(config)
const constantsToParse = config.rnconfig?.defineConstants || config?.defineConstants
-
+
return {
...(constantsToParse ? parseDefineConst(constantsToParse) : {}),
...env
diff --git a/packages/taro-rn-supporter/src/index.ts b/packages/taro-rn-supporter/src/index.ts
index 2b6eb60a2b90..33234d1035d0 100644
--- a/packages/taro-rn-supporter/src/index.ts
+++ b/packages/taro-rn-supporter/src/index.ts
@@ -1,6 +1,6 @@
export { getBabelConfig } from './babel'
export { entryFilePath } from './defaults'
-export { previewDev,previewProd } from './preview'
+export { previewDev, previewProd } from './preview'
export { default as rollupResolver } from './rollupResolver'
export { getMetroConfig } from './Support'
export { resolveExtFile } from './utils'
\ No newline at end of file
diff --git a/packages/taro-rn-supporter/src/rollupResolver.ts b/packages/taro-rn-supporter/src/rollupResolver.ts
index 52f8a7dc09b7..0c81d002dfd9 100644
--- a/packages/taro-rn-supporter/src/rollupResolver.ts
+++ b/packages/taro-rn-supporter/src/rollupResolver.ts
@@ -16,7 +16,7 @@ const DEFAULT_ALIAS = {
'@tarojs/components': '@tarojs/components-rn'
}
-const isInclude = (_moduleName, originModulePath, config: IProjectConfig ) => {
+const isInclude = (_moduleName, originModulePath, config: IProjectConfig) => {
return originModulePath.indexOf('node_modules') < 0 || includes(originModulePath, config)
}
diff --git a/packages/taro-rn-supporter/src/taroResolver.ts b/packages/taro-rn-supporter/src/taroResolver.ts
index be455d5b68e6..d1b9b3f18f2c 100644
--- a/packages/taro-rn-supporter/src/taroResolver.ts
+++ b/packages/taro-rn-supporter/src/taroResolver.ts
@@ -79,7 +79,7 @@ function handleFile (context: ResolutionContext, moduleName, platform, config) {
// rn runner调用
function handleTaroFile (context: ResolutionContext, moduleName, platform, config) {
const newContext = { ...context }
- if(context.originModulePath === require.resolve(entryFilePath)) {
+ if (context.originModulePath === require.resolve(entryFilePath)) {
newContext.originModulePath = path.join(context.projectRoot, './index.js')
}
return handleFile(newContext, moduleName, platform, config)
diff --git a/packages/taro-rn-supporter/src/terminal-reporter.ts b/packages/taro-rn-supporter/src/terminal-reporter.ts
index ade96dbf70b6..668e4f400e7d 100644
--- a/packages/taro-rn-supporter/src/terminal-reporter.ts
+++ b/packages/taro-rn-supporter/src/terminal-reporter.ts
@@ -22,7 +22,7 @@ export class TerminalReporter {
this.qr = qr ?? false
this.entry = entry || 'app'
const argvs = yargs(process.argv).argv as any
- if(this.qr && argvs._.includes('bundle')) {
+ if (this.qr && argvs._.includes('bundle')) {
process.on('beforeExit', () => {
previewProd({
out: argvs.bundleOutput as string,
@@ -49,7 +49,7 @@ export class TerminalReporter {
case 'initialize_done':
process.stdin.on('keypress', (_key, data) => {
const { name } = data
- if(name === 'q') {
+ if (name === 'q') {
previewDev(args)
}
})
@@ -92,12 +92,12 @@ export class TerminalReporter {
// 监听DeltaCalculator的change事件,把入口文件也加入到_modifiedFiles集合中
bundler.getDependencyGraph().then(dependencyGraph => {
dependencyGraph.getWatcher().on('change', ({ eventsQueue }) => {
- const changedFiles = eventsQueue.filter( item => {
+ const changedFiles = eventsQueue.filter(item => {
// APP配置文件变更和页面配置文件新增或删除时,重新编译入口文件
- if(item.filePath.includes(`${this.entry}.config`)) {
+ if (item.filePath.includes(`${this.entry}.config`)) {
return true
}
- return item.type !=='change'
+ return item.type !== 'change'
}).map(item => item.filePath)
// 如果配置文件修改之后,把入口文件添加到修改列表中
const deltaCalculator = deltaBundler._deltaCalculators.get(entryGraphVersion.graph)
diff --git a/packages/taro-rn-supporter/src/utils.ts b/packages/taro-rn-supporter/src/utils.ts
index a5e9ffc021dd..345c243b8f97 100644
--- a/packages/taro-rn-supporter/src/utils.ts
+++ b/packages/taro-rn-supporter/src/utils.ts
@@ -180,7 +180,7 @@ function getBlockList (config: IProjectConfig) {
const path = `${process.cwd()}/${srcDir}/app.config`
const configPath = helper.resolveMainFilePath(path)
const appConfig = helper.readConfig(configPath, config)
- if( appConfig?.pages?.length === 1 && !!appConfig?.rn?.singleMode){
+ if (appConfig?.pages?.length === 1 && !!appConfig?.rn?.singleMode) {
regExp.push(/@tarojs\/router-rn/)
}
return regExp
@@ -194,7 +194,8 @@ export {
isTaroRunner,
resolveExtFile,
resolvePathFromAlias,
- setFromRunner }
+ setFromRunner
+}
export function getOpenHost () {
let result
diff --git a/packages/taro-rn-transformer/src/app.ts b/packages/taro-rn-transformer/src/app.ts
index 0c729ba3f658..6e5b4a4cc2be 100644
--- a/packages/taro-rn-transformer/src/app.ts
+++ b/packages/taro-rn-transformer/src/app.ts
@@ -37,7 +37,7 @@ function getPagesResource (appPath: string, basePath: string, pathPrefix: string
}
}
-function getPageComponent (pagePath: string){
+function getPageComponent (pagePath: string) {
const screen = camelCase(pagePath)
const screenConfigName = `${screen}Config`
return `createPageConfig(${screen},{...${screenConfigName},pagePath:'${pagePath}'})`
diff --git a/packages/taro-router-rn/src/provider.ts b/packages/taro-router-rn/src/provider.ts
index d7945ac96e60..70b887400a00 100644
--- a/packages/taro-router-rn/src/provider.ts
+++ b/packages/taro-router-rn/src/provider.ts
@@ -25,7 +25,7 @@ export class PageProvider extends React.Component {
componentDidMount (): void {
const { navigation } = this.props
- if(navigation){
+ if (navigation) {
this.unSubscribleFocus = this.props.navigation.addListener('focus', () => {
if (navigationRef && navigationRef?.current) {
navigationRef.current.setOptions = navigation.setOptions
diff --git a/packages/taro-router-rn/src/router.tsx b/packages/taro-router-rn/src/router.tsx
index 48e4d2f51566..d5430491a07a 100644
--- a/packages/taro-router-rn/src/router.tsx
+++ b/packages/taro-router-rn/src/router.tsx
@@ -89,20 +89,20 @@ export interface RouterOption{
export function createRouter (config: RouterConfig, options:RouterOption) {
if (config?.tabBar?.list?.length) {
- return createTabNavigate(config,options)
+ return createTabNavigate(config, options)
} else {
- return createStackNavigate(config,options)
+ return createStackNavigate(config, options)
}
}
-// 初始化路由相关,入口组件,onLaunch,onShow
-export function getInitOptions (config){
+// 初始化路由相关,入口组件,onLaunch,onShow
+export function getInitOptions (config) {
const initRouteName = getInitRouteName(config)
const initParams = getInitParams(config, initRouteName)
const initPath = config.pages.find(p => p.name === initRouteName)?.pagePath
return {
path: initPath,
- query:initParams,
+ query: initParams,
}
}
@@ -343,7 +343,7 @@ function getLinkingConfig (config: RouterConfig) {
}
}
-function defaultOnUnhandledAction (action){
+function defaultOnUnhandledAction (action) {
// @ts-ignore
if (process.env.NODE_ENV === 'production') {
return
@@ -380,9 +380,9 @@ function defaultOnUnhandledAction (action){
console.error(message)
}
-function handlePageNotFound (action, options){
- const routeObj:Record = action?.payload ?? {}
- if(routeObj?.name){
+function handlePageNotFound (action, options) {
+ const routeObj:Record = action?.payload ?? {}
+ if (routeObj?.name) {
options?.onUnhandledAction && options?.onUnhandledAction({
path: getCurrentJumpUrl() ?? routeObj?.name,
query: routeObj?.params ?? {}
@@ -402,7 +402,7 @@ function createTabNavigate (config: RouterConfig, options: RouterOption) {
return handlePageNotFound(action, options)}
+ onUnhandledAction = {(action) => handlePageNotFound(action, options)}
>
handlePageNotFound(action, options)}
+ onUnhandledAction = {(action) => handlePageNotFound(action, options)}
>
{
}
}
-export function hasJumpAnimate () :boolean{
- if(globalAny.__taroJumpAnimate === false){
+export function hasJumpAnimate () :boolean {
+ if (globalAny.__taroJumpAnimate === false) {
return false
}
return true
}
-export function updateJumpAnimate (needAnimate: boolean){
+export function updateJumpAnimate (needAnimate: boolean) {
globalAny.__taroJumpAnimate = needAnimate
}
-export function updateCurrentJumpUrl (path: string){
+export function updateCurrentJumpUrl (path: string) {
globalAny.__taroJumpUrl = path
}
-export function getCurrentJumpUrl (): string{
- return globalAny?.__taroJumpUrl ?? ''
+export function getCurrentJumpUrl (): string {
+ return globalAny?.__taroJumpUrl ?? ''
}
\ No newline at end of file
diff --git a/packages/taro-router-rn/src/view/TabBar.tsx b/packages/taro-router-rn/src/view/TabBar.tsx
index 100ac93988c2..e49b69cd14b1 100644
--- a/packages/taro-router-rn/src/view/TabBar.tsx
+++ b/packages/taro-router-rn/src/view/TabBar.tsx
@@ -123,7 +123,7 @@ export class TabBar extends React.PureComponent
@@ -19,8 +19,8 @@ const loading_svg_str = `
`
export function initNavigationBar (config: SpaRouterConfig | MpaRouterConfig, container: HTMLElement) {
- if(config.router.mode === 'multi') return
-
+ if (config.router.mode === 'multi') return
+
const navigationBar = document.createElement('div')
navigationBar.classList.add('taro-navigation-bar-no-icon')
diff --git a/packages/taro-router/src/router/navigation-bar.ts b/packages/taro-router/src/router/navigation-bar.ts
index cc889b4d5f30..8830d8ccbf34 100644
--- a/packages/taro-router/src/router/navigation-bar.ts
+++ b/packages/taro-router/src/router/navigation-bar.ts
@@ -1,6 +1,6 @@
import { eventCenter } from '@tarojs/runtime'
-import { navigateBack,reLaunch } from '../api'
+import { navigateBack, reLaunch } from '../api'
import { isDingTalk } from '../utils'
import stacks from './stack'
@@ -20,8 +20,8 @@ export default class NavigationBarHandler {
cache: Record
isLoadDdEntry = false
- constructor (pageContext: PageHandler){
- this.cache ={}
+ constructor (pageContext: PageHandler) {
+ this.cache = {}
this.pageContext = pageContext
this.init()
@@ -75,7 +75,7 @@ export default class NavigationBarHandler {
this.backBtnElement?.addEventListener('click', this.backFn.bind(this))
}
- setNavigationBarElement (){
+ setNavigationBarElement () {
this.navigationBarElement = document.getElementById('taro-navigation-bar') as HTMLElement
}
@@ -89,7 +89,7 @@ export default class NavigationBarHandler {
this.setNavigationLoading()
}
- setCacheValue (){
+ setCacheValue () {
const currentPage = this.pageContext.currentPage
if (typeof this.cache[currentPage] !== 'object') {
this.cache[currentPage] = {}
@@ -214,25 +214,25 @@ export default class NavigationBarHandler {
this.titleElement.innerHTML = proceedTitle
}
- fnBtnToggleToHome (){
+ fnBtnToggleToHome () {
if (!this.navigationBarElement) return
this.navigationBarElement.classList.add('taro-navigation-bar-home-icon')
this.navigationBarElement.classList.remove('taro-navigation-bar-back-icon')
}
- fnBtnToggleToBack (){
+ fnBtnToggleToBack () {
if (!this.navigationBarElement) return
this.navigationBarElement.classList.remove('taro-navigation-bar-home-icon')
this.navigationBarElement.classList.add('taro-navigation-bar-back-icon')
}
- fnBtnToggleToNone (){
+ fnBtnToggleToNone () {
if (!this.navigationBarElement) return
this.navigationBarElement.classList.remove('taro-navigation-bar-home-icon')
this.navigationBarElement.classList.remove('taro-navigation-bar-back-icon')
}
- setNavigationBarVisible (show?){
+ setNavigationBarVisible (show?) {
if (!this.navigationBarElement) return
let shouldShow
@@ -240,7 +240,7 @@ export default class NavigationBarHandler {
shouldShow = show
} else {
shouldShow = this.pageContext.config.window?.navigationStyle
- if (typeof this.pageContext.pageConfig?.navigationStyle === 'string'){
+ if (typeof this.pageContext.pageConfig?.navigationStyle === 'string') {
shouldShow = this.pageContext.pageConfig.navigationStyle
}
}
diff --git a/packages/taro-router/src/router/page.ts b/packages/taro-router/src/router/page.ts
index b7025fa64f58..d77c7a9ca4d6 100644
--- a/packages/taro-router/src/router/page.ts
+++ b/packages/taro-router/src/router/page.ts
@@ -38,7 +38,7 @@ export default class PageHandler {
return routePath === '/' ? this.homePage : routePath
}
- get appId () { return this.config.appId ||'app' }
+ get appId () { return this.config.appId || 'app' }
get router () { return this.config.router || {} }
get routerMode () { return this.router.mode || 'hash' }
get customRoutes () { return this.router.customRoutes || {} }
diff --git a/packages/taro-router/src/router/spa.ts b/packages/taro-router/src/router/spa.ts
index d1f3126369d0..af03d54fc53f 100644
--- a/packages/taro-router/src/router/spa.ts
+++ b/packages/taro-router/src/router/spa.ts
@@ -62,7 +62,7 @@ export function createRouter (
const render: LocationListener = async ({ location, action }) => {
handler.pathname = decodeURI(location.pathname)
- if ((window as any).__taroAppConfig?.usingWindowScroll) window.scrollTo(0,0)
+ if ((window as any).__taroAppConfig?.usingWindowScroll) window.scrollTo(0, 0)
eventCenter.trigger('__taroRouterChange', {
toLocation: {
path: handler.pathname
diff --git a/packages/taro-router/src/style.ts b/packages/taro-router/src/style.ts
index 7a025b4e2b3f..3c297dfc3db1 100644
--- a/packages/taro-router/src/style.ts
+++ b/packages/taro-router/src/style.ts
@@ -62,7 +62,7 @@ ${
max-height: calc(100vh - var(--taro-tabbar-height) - env(safe-area-inset-bottom));
}
-`: ''}
+` : ''}
.taro_page_shade,
.taro_router > .taro_page.taro_page_show.taro_page_stationed:not(.taro_page_shade):not(.taro_tabbar_page):not(:last-child) {
display: none;
diff --git a/packages/taro-runtime-rn/src/compute.ts b/packages/taro-runtime-rn/src/compute.ts
index 4d70b0e64a75..d1438acdcac1 100644
--- a/packages/taro-runtime-rn/src/compute.ts
+++ b/packages/taro-runtime-rn/src/compute.ts
@@ -23,9 +23,9 @@ export function pxTransform (size: number): number {
const deviceWidthDp = Dimensions.get('window').width
const config: AppConfig = globalAny.__taroAppConfig?.appConfig || {}
const deviceRatio = config.deviceRatio || defaultRadio
- const designWidth = (((input = 0) => isFunction(config.designWidth)
+ const designWidth = ((input = 0) => isFunction(config.designWidth)
? config.designWidth(input)
- : config.designWidth || defaultWidth))(size)
+ : config.designWidth || defaultWidth)(size)
if (!(designWidth in deviceRatio)) {
throw new Error(`deviceRatio 配置中不存在 ${designWidth} 的设置!`)
}
diff --git a/packages/taro-runtime-rn/src/hooks.ts b/packages/taro-runtime-rn/src/hooks.ts
index 5cb634b523bb..fe517d977710 100644
--- a/packages/taro-runtime-rn/src/hooks.ts
+++ b/packages/taro-runtime-rn/src/hooks.ts
@@ -72,7 +72,7 @@ export const useTabItemTap = taroHooks('onTabItemTap')
export const useLaunch = taroHooks('onLaunch')
-export const usePageNotFound= taroHooks('onPageNotFound')
+export const usePageNotFound = taroHooks('onPageNotFound')
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export const useRouter = (dynamic = false) => {
diff --git a/packages/taro-runtime-rn/src/router.ts b/packages/taro-runtime-rn/src/router.ts
index 02536c098be8..f3580301180f 100644
--- a/packages/taro-runtime-rn/src/router.ts
+++ b/packages/taro-runtime-rn/src/router.ts
@@ -1,6 +1,6 @@
/**
* router-rn 接口都改为require 引入, 单页不引用的router
- *
+ *
*/
let routerObj: any = {}
try {
@@ -8,7 +8,7 @@ try {
// eslint-disable-next-line
} catch (e) {}
-function getApi (key){
+function getApi (key) {
if (!routerObj?.[key]) {
return () => {
console.error(`Single page can not support ${key}, if you have multiple pages configured, you can try restart and reset cache`)
@@ -17,25 +17,25 @@ function getApi (key){
return routerObj?.[key]
}
-export const rnNavigationRef = routerObj?.navigationRef ?? null
-export const PageProvider = routerObj?.PageProvider ?? null
+export const rnNavigationRef = routerObj?.navigationRef ?? null
+export const PageProvider = routerObj?.PageProvider ?? null
-export const getRouteEventChannel = getApi('getRouteEventChannel')
+export const getRouteEventChannel = getApi('getRouteEventChannel')
export const getCurrentRoute = getApi('getCurrentRoute')
export const isTabPage = getApi('isTabPage')
export const createRouter = getApi('createRouter')
-export const getInitOptions = getApi('getInitOptions')
+export const getInitOptions = getApi('getInitOptions')
export const hideNavigationBarLoading = getApi('hideNavigationBarLoading')
export const hideTabBar = getApi('hideTabBar')
export const hideTabBarRedDot = getApi('hideTabBarRedDot')
export const navigateBack = getApi('navigateBack')
export const navigateTo = getApi('navigateTo')
-export const redirectTo = getApi('redirectTo')
+export const redirectTo = getApi('redirectTo')
export const reLaunch = getApi('reLaunch')
export const switchTab = getApi('switchTab')
-export const removeTabBarBadge = getApi('removeTabBarBadge')
+export const removeTabBarBadge = getApi('removeTabBarBadge')
export const setNavigationBarColor = getApi('setNavigationBarColor')
export const setNavigationBarTitle = getApi('setNavigationBarTitle')
export const setTabBarBadge = getApi('setTabBarBadge')
diff --git a/packages/taro-runtime-rn/src/utils.ts b/packages/taro-runtime-rn/src/utils.ts
index b7b66a0bb7e1..49371b93fff0 100644
--- a/packages/taro-runtime-rn/src/utils.ts
+++ b/packages/taro-runtime-rn/src/utils.ts
@@ -61,6 +61,6 @@ export function errorHandler (fail: OptionsFunc | undefined, complete: OptionsFu
}
}
-export function getPageStr (path: string):string{
- return path.replace(/\//g,'')
+export function getPageStr (path: string):string {
+ return path.replace(/\//g, '')
}
\ No newline at end of file
diff --git a/packages/taro-runtime/src/__tests__/class.spec.js b/packages/taro-runtime/src/__tests__/class.spec.js
index fec3cf1acf7b..7b8cecbe338e 100644
--- a/packages/taro-runtime/src/__tests__/class.spec.js
+++ b/packages/taro-runtime/src/__tests__/class.spec.js
@@ -13,7 +13,7 @@ describe('Class', () => {
div.className = 'test1 test2'
expect(div.className).toBe('test1 test2')
})
-
+
it('removeAttribute: class', () => {
const div = document.createElement('div')
div.className = 'test'
@@ -23,7 +23,7 @@ describe('Class', () => {
})
describe('classList', () => {
- it('get value', () => {
+ it('get value', () => {
const div = document.createElement('div')
expect(div.classList.value).toBe('')
div.classList.add('test1')
@@ -38,7 +38,7 @@ describe('Class', () => {
expect(div.classList.value).toBe('test1 test2')
})
- it('get length', () => {
+ it('get length', () => {
const div = document.createElement('div')
div.classList.add('test1')
expect(div.classList.length).toBe(1)
@@ -55,7 +55,7 @@ describe('Class', () => {
div.classList.add('test2')
expect(div.className).toBe('test1 test2')
})
-
+
it('trigger remove function', () => {
const div = document.createElement('div')
div.classList.add('test1')
@@ -67,7 +67,7 @@ describe('Class', () => {
div.classList.remove('test1')
expect(div.className).toBe('')
})
-
+
it('trigger toggle function', () => {
const div = document.createElement('div')
div.classList.toggle('test')
@@ -85,7 +85,7 @@ describe('Class', () => {
div.classList.replace('test4', 'test5')
expect(div.className).toBe('test3 test2')
})
-
+
it('trigger contains function', () => {
const div = document.createElement('div')
div.classList.add('test1')
diff --git a/packages/taro-runtime/src/__tests__/nerv.spec.js b/packages/taro-runtime/src/__tests__/nerv.spec.js
index e3796b93f297..c278bd3454e0 100644
--- a/packages/taro-runtime/src/__tests__/nerv.spec.js
+++ b/packages/taro-runtime/src/__tests__/nerv.spec.js
@@ -21,18 +21,18 @@ describe.skip('nerv', () => {
componentDidShow (...arg) {
appDidShow(...arg)
}
-
+
componentDidHide (...arg) {
appDidHide(...arg)
}
-
+
render () {
return this.props.children
}
}
-
+
app = runtime.createReactApp(App, React, ReactDOM, {})
-
+
app.onLaunch()
})
@@ -59,71 +59,71 @@ describe.skip('nerv', () => {
let homeContainer
beforeAll(() => {
homeContainer = React.createRef()
-
+
class Home extends React.Component {
componentDidShow (...arg) {
onShow(...arg)
}
-
+
componentDidHide (...arg) {
onHide(...arg)
}
-
+
componentDidMount () {
onLoad()
}
-
+
onReachBottom () {
onReachBottom()
}
-
+
onPageScroll () {
onPageScroll.apply(this, arguments)
}
-
+
onShareAppMessage () {
onShareAppMessage.apply(this, arguments)
}
-
+
onResize () {
onResize.apply(this, arguments)
}
-
+
onTabItemTap () {
onTabItemTap.apply(this, arguments)
}
-
+
onTitleClick () {
onTitleClick()
}
-
+
onOptionMenuClick () {
onOptionMenuClick()
}
-
+
onPopMenuClick () {
onPopMenuClick()
}
-
+
onPullIntercept () {
onPullIntercept()
}
-
+
onPullDownRefresh () {
onPullDownRefresh()
}
-
+
componentWillUnmount () {
onUnload()
}
-
+
render () {
return home
}
}
-
+
home = runtime.createPageConfig(Home, '/page/home')
-
+
home.setData = function (_, cb) {
cb()
}
@@ -382,25 +382,25 @@ describe.skip('nerv', () => {
let homeContainer
beforeAll(() => {
homeContainer = React.createRef()
-
+
class Home extends React.Component {
constructor (props) {
super(props)
// eslint-disable-next-line @typescript-eslint/no-this-alias
homeInst = this
}
-
+
state = {
render: 'home'
}
-
+
render () {
return {this.state.render}
}
}
-
+
home = runtime.createPageConfig(Home, '/page/home')
-
+
home.setData = function (data, cb) {
dataSpy(data)
cb()
diff --git a/packages/taro-runtime/src/bom/URLSearchParams.ts b/packages/taro-runtime/src/bom/URLSearchParams.ts
index a3689e2e214c..1bdc86847806 100644
--- a/packages/taro-runtime/src/bom/URLSearchParams.ts
+++ b/packages/taro-runtime/src/bom/URLSearchParams.ts
@@ -36,7 +36,7 @@ function encode (str: string) {
return encodeURIComponent(str).replace(findReg, replacer)
}
-export const URLSearchParams = process.env.TARO_PLATFORM === 'web' ? env.window.URLSearchParams : class {
+export const URLSearchParams = process.env.TARO_PLATFORM === 'web' ? env.window.URLSearchParams : class {
#dict = Object.create(null)
constructor (query) {
@@ -95,7 +95,7 @@ export const URLSearchParams = process.env.TARO_PLATFORM === 'web' ? env.window.
return name in this.#dict
}
- keys (){
+ keys () {
return Object.keys(this.#dict)
}
diff --git a/packages/taro-runtime/src/dom/anchor-element.ts b/packages/taro-runtime/src/dom/anchor-element.ts
index b86dc99fbaa2..d4cdd546405b 100644
--- a/packages/taro-runtime/src/dom/anchor-element.ts
+++ b/packages/taro-runtime/src/dom/anchor-element.ts
@@ -59,5 +59,4 @@ export class AnchorElement extends TaroElement {
super.setAttribute(qualifiedName, value)
}
}
-
}
diff --git a/packages/taro-runtime/src/dom/class-list.ts b/packages/taro-runtime/src/dom/class-list.ts
index 3c7ac4dbc297..e9a28d24562f 100644
--- a/packages/taro-runtime/src/dom/class-list.ts
+++ b/packages/taro-runtime/src/dom/class-list.ts
@@ -53,7 +53,7 @@ export class ClassList {
const token = tokens[i] + ''
if (!this.checkTokenIsValid(token)) continue
-
+
const index = tokenList.indexOf(token)
if (~tokenList.indexOf(token)) {
@@ -92,22 +92,22 @@ export class ClassList {
replace (token: string, replacement_token: string) {
if (!this.checkTokenIsValid(token) || !this.checkTokenIsValid(replacement_token)) return
-
+
const index = this.tokenList.indexOf(token)
if (~index) {
this.tokenList.splice(index, 1, replacement_token)
- this._update()
+ this._update()
}
}
toString () {
- return this.tokenList.filter(v => v !== '').join(' ')
+ return this.tokenList.filter(v => v !== '').join(' ')
}
private checkTokenIsValid (token: string) {
if (token === '' || /\s/.test(token)) return false
-
+
return true
}
diff --git a/packages/taro-runtime/src/dom/form.ts b/packages/taro-runtime/src/dom/form.ts
index 166bbeccf76b..d1c7258c7d94 100644
--- a/packages/taro-runtime/src/dom/form.ts
+++ b/packages/taro-runtime/src/dom/form.ts
@@ -2,7 +2,8 @@ import {
CHANGE,
INPUT,
TYPE,
- VALUE } from '../constants'
+ VALUE
+} from '../constants'
import { TaroElement } from './element'
import type { TaroEvent } from './event'
diff --git a/packages/taro-runtime/src/dom/root.ts b/packages/taro-runtime/src/dom/root.ts
index 60cce51b63f4..0c3963414be9 100644
--- a/packages/taro-runtime/src/dom/root.ts
+++ b/packages/taro-runtime/src/dom/root.ts
@@ -1,4 +1,4 @@
-import { hooks,isArray, isFunction, isUndefined, Shortcuts } from '@tarojs/shared'
+import { hooks, isArray, isFunction, isUndefined, Shortcuts } from '@tarojs/shared'
import {
CUSTOM_WRAPPER,
diff --git a/packages/taro-runtime/src/dsl/common.ts b/packages/taro-runtime/src/dsl/common.ts
index 72096f6142e8..d5c6c6b99263 100644
--- a/packages/taro-runtime/src/dsl/common.ts
+++ b/packages/taro-runtime/src/dsl/common.ts
@@ -288,7 +288,7 @@ export function createPageConfig (component: any, pageName?: string, data?: Reco
export function createComponentConfig (component: React.ComponentClass, componentName?: string, data?: Record) {
const id = componentName ?? `taro_component_${pageId()}`
let componentElement: TaroRootElement | null = null
- const [ ATTACHED, DETACHED ] = hooks.call('getMiniLifecycleImpl')!.component
+ const [ATTACHED, DETACHED] = hooks.call('getMiniLifecycleImpl')!.component
const config: any = {
[ATTACHED] () {
@@ -336,7 +336,7 @@ export function createComponentConfig (component: React.ComponentClass, componen
export function createRecursiveComponentConfig (componentName?: string) {
const isCustomWrapper = componentName === CUSTOM_WRAPPER
- const [ ATTACHED, DETACHED ] = hooks.call('getMiniLifecycleImpl')!.component
+ const [ATTACHED, DETACHED] = hooks.call('getMiniLifecycleImpl')!.component
const lifeCycles = isCustomWrapper
? {
@@ -384,5 +384,6 @@ export function createRecursiveComponentConfig (componentName?: string) {
methods: {
eh: eventHandler
},
- ...lifeCycles }, { isCustomWrapper })
+ ...lifeCycles
+ }, { isCustomWrapper })
}
diff --git a/packages/taro-service/src/Config.ts b/packages/taro-service/src/Config.ts
index 8f40d373186a..20fd7c5e0247 100644
--- a/packages/taro-service/src/Config.ts
+++ b/packages/taro-service/src/Config.ts
@@ -48,7 +48,7 @@ export default class Config {
this.isInitSuccess = false
this.configPath = resolveScriptPath(path.join(this.appPath, CONFIG_DIR_NAME, DEFAULT_CONFIG_FILE))
if (!fs.existsSync(this.configPath)) {
- if(this.disableGlobalConfig) return
+ if (this.disableGlobalConfig) return
this.initGlobalConfig()
} else {
createSwcRegister({
@@ -68,14 +68,14 @@ export default class Config {
initGlobalConfig () {
const homedir = getUserHomeDir()
- if(!homedir) return console.error('获取不到用户 home 路径')
+ if (!homedir) return console.error('获取不到用户 home 路径')
const globalPluginConfigPath = path.join(getUserHomeDir(), TARO_GLOBAL_CONFIG_DIR, TARO_GLOBAL_CONFIG_FILE)
const spinner = ora(`开始获取 taro 全局配置文件: ${globalPluginConfigPath}`).start()
if (!fs.existsSync(globalPluginConfigPath)) return spinner.warn(`获取 taro 全局配置文件失败,不存在全局配置文件:${globalPluginConfigPath}`)
try {
this.initialGlobalConfig = fs.readJSONSync(globalPluginConfigPath) || {}
spinner.succeed('获取 taro 全局配置成功')
- }catch(e){
+ } catch (e) {
spinner.stop()
console.warn(`获取全局配置失败,如果需要启用全局插件请查看配置文件: ${globalPluginConfigPath} `)
}
diff --git a/packages/taro-service/src/Kernel.ts b/packages/taro-service/src/Kernel.ts
index da5a3b4de134..658b40dcc111 100644
--- a/packages/taro-service/src/Kernel.ts
+++ b/packages/taro-service/src/Kernel.ts
@@ -130,7 +130,7 @@ export default class Kernel extends EventEmitter {
}
const globalConfigRootPath = path.join(helper.getUserHomeDir(), helper.TARO_GLOBAL_CONFIG_DIR)
- const resolvedGlobalPresets = resolvePresetsOrPlugins(globalConfigRootPath , globalPresets, PluginType.Plugin, true)
+ const resolvedGlobalPresets = resolvePresetsOrPlugins(globalConfigRootPath, globalPresets, PluginType.Plugin, true)
while (resolvedGlobalPresets.length) {
this.initPreset(resolvedGlobalPresets.shift()!, true)
}
@@ -142,7 +142,7 @@ export default class Kernel extends EventEmitter {
globalPlugins = merge(this.globalExtraPlugins, globalPlugins)
const globalConfigRootPath = path.join(helper.getUserHomeDir(), helper.TARO_GLOBAL_CONFIG_DIR)
- const resolvedGlobalPlugins = resolvePresetsOrPlugins(globalConfigRootPath , globalPlugins, PluginType.Plugin, true)
+ const resolvedGlobalPlugins = resolvePresetsOrPlugins(globalConfigRootPath, globalPlugins, PluginType.Plugin, true)
const resolvedPlugins = resolvedCliAndProjectPlugins.concat(resolvedGlobalPlugins)
@@ -184,14 +184,14 @@ export default class Kernel extends EventEmitter {
applyCliCommandPlugin (commandNames: string[] = []) {
const existsCliCommand: string[] = []
- for( let i = 0; i < commandNames.length; i++ ) {
+ for (let i = 0; i < commandNames.length; i++) {
const commandName = commandNames[i]
const commandFilePath = path.resolve(this.cliCommandsPath, `${commandName}.js`)
- if(this.cliCommands.includes(commandName)) existsCliCommand.push(commandFilePath)
+ if (this.cliCommands.includes(commandName)) existsCliCommand.push(commandFilePath)
}
const commandPlugins = convertPluginsToObject(existsCliCommand || [])()
- helper.createSwcRegister({ only: [ ...Object.keys(commandPlugins) ] })
- const resolvedCommandPlugins = resolvePresetsOrPlugins(this.appPath , commandPlugins, PluginType.Plugin)
+ helper.createSwcRegister({ only: [...Object.keys(commandPlugins)] })
+ const resolvedCommandPlugins = resolvePresetsOrPlugins(this.appPath, commandPlugins, PluginType.Plugin)
while (resolvedCommandPlugins.length) {
this.initPlugin(resolvedCommandPlugins.shift()!)
}
diff --git a/packages/taro-service/src/platform-plugin-base/platform.ts b/packages/taro-service/src/platform-plugin-base/platform.ts
index 2d2b17c199e6..910eb5c4b53a 100644
--- a/packages/taro-service/src/platform-plugin-base/platform.ts
+++ b/packages/taro-service/src/platform-plugin-base/platform.ts
@@ -64,7 +64,7 @@ export default abstract class TaroPlatform {
*/
private updateOutputPath (config: TConfig) {
const platformPath = config.output?.path
- if(platformPath) {
+ if (platformPath) {
this.ctx.paths.outputPath = platformPath
}
}
diff --git a/packages/taro-service/src/utils/index.ts b/packages/taro-service/src/utils/index.ts
index 60443eeaf297..2336981492b1 100644
--- a/packages/taro-service/src/utils/index.ts
+++ b/packages/taro-service/src/utils/index.ts
@@ -44,9 +44,9 @@ export function mergePlugins (dist: PluginItem[], src: PluginItem[]) {
// getModuleDefaultExport
export function resolvePresetsOrPlugins (root: string, args: IPluginsObject, type: PluginType, skipError?: boolean): IPlugin[] {
// 全局的插件引入报错,不抛出 Error 影响主流程,而是通过 log 提醒然后把插件 filter 掉,保证主流程不变
- const resolvedPresetsOrPlugins: IPlugin[] = []
+ const resolvedPresetsOrPlugins: IPlugin[] = []
const presetsOrPluginsNames = Object.keys(args) || []
- for( let i = 0; i < presetsOrPluginsNames.length; i++ ) {
+ for (let i = 0; i < presetsOrPluginsNames.length; i++) {
const item = presetsOrPluginsNames[i]
let fPath
try {
@@ -78,7 +78,7 @@ export function resolvePresetsOrPlugins (root: string, args: IPluginsObject, typ
} catch (error) {
console.error(error)
// 全局的插件运行报错,不抛出 Error 影响主流程,而是通过 log 提醒然后把插件 filter 掉,保证主流程不变
- if(skipError) {
+ if (skipError) {
console.error(`插件依赖 "${item}" 加载失败,请检查插件配置`)
} else {
throw new Error(`插件依赖 "${item}" 加载失败,请检查插件配置`)
diff --git a/packages/taro-tt/src/components.ts b/packages/taro-tt/src/components.ts
index d2b4a32c3c23..c119da7c6a79 100644
--- a/packages/taro-tt/src/components.ts
+++ b/packages/taro-tt/src/components.ts
@@ -43,7 +43,7 @@ export const components = {
'enable-play-gesture': _false,
'show-playback-rate-btn': _false,
'enable-play-in-background': _false,
- 'signature': _empty,
+ signature: _empty,
bindProgress: _empty,
bindSeekComplete: _empty,
bindAdLoad: _empty,
diff --git a/packages/taro-weapp/src/apis.ts b/packages/taro-weapp/src/apis.ts
index 1fc789d79dc9..e3d25ec04201 100644
--- a/packages/taro-weapp/src/apis.ts
+++ b/packages/taro-weapp/src/apis.ts
@@ -28,7 +28,7 @@ export function initNativeApi (taro) {
return pageCtx.getTabBar()?.$taroInstances
}
}
- taro.getRenderer = function (){
+ taro.getRenderer = function () {
return taro.getCurrentInstance()?.page?.renderer ?? 'webview'
}
}
diff --git a/packages/taro-weapp/src/components.ts b/packages/taro-weapp/src/components.ts
index 934a4aa0448e..566f8681d95b 100644
--- a/packages/taro-weapp/src/components.ts
+++ b/packages/taro-weapp/src/components.ts
@@ -87,7 +87,7 @@ export const components = {
},
Picker: {
'header-text': _empty,
- 'level': 'region'
+ level: 'region'
},
PickerView: {
'immediate-change': _false,
@@ -415,7 +415,7 @@ export const components = {
ChannelVideo: {
'feed-id': _empty,
'finder-user-name': _empty,
- 'feed-token':_empty,
+ 'feed-token': _empty,
autoplay: _false,
loop: _false,
muted: _false,
diff --git a/packages/taro-weapp/src/template.ts b/packages/taro-weapp/src/template.ts
index 726ebaa2e366..2dec0bd8cd64 100644
--- a/packages/taro-weapp/src/template.ts
+++ b/packages/taro-weapp/src/template.ts
@@ -111,7 +111,7 @@ export class Template extends UnRecursiveTemplate {
if (pageConfig?.enablePageMeta) {
const getComponentAttrs = (componentName: string, dataPath: string) => {
return Object.entries(this.transferComponents[componentName]).reduce((sum, [key, value]) => {
- sum +=`${key}="${value === 'eh' ? value : `{{${value.replace('i.', dataPath)}}}`}" `
+ sum += `${key}="${value === 'eh' ? value : `{{${value.replace('i.', dataPath)}}}`}" `
return sum
}, '')
}
diff --git a/packages/taro-webpack-runner/src/utils/chain.ts b/packages/taro-webpack-runner/src/utils/chain.ts
index 953def5e4e13..9a6aa56d0b40 100644
--- a/packages/taro-webpack-runner/src/utils/chain.ts
+++ b/packages/taro-webpack-runner/src/utils/chain.ts
@@ -449,9 +449,9 @@ export const parseModule = (appPath: string, {
* 除了包含 taro 和 inversify 的第三方依赖均不经过 babel-loader 处理
*/
scriptRule.exclude = [filename =>
- /css-loader/.test(filename)
+ /css-loader/.test(filename) ||
// || /@tarojs[\\/]components/.test(filename) Note: stencil 2.14 开始使用了 import.meta.url 需要额外处理
- || (/node_modules/.test(filename) && !(/taro/.test(filename) || /inversify/.test(filename)))]
+ (/node_modules/.test(filename) && !(/taro/.test(filename) || /inversify/.test(filename)))]
}
const rule: {
diff --git a/packages/taro-webpack-runner/src/utils/index.ts b/packages/taro-webpack-runner/src/utils/index.ts
index dcfdc76063bd..1f92eb4d639c 100644
--- a/packages/taro-webpack-runner/src/utils/index.ts
+++ b/packages/taro-webpack-runner/src/utils/index.ts
@@ -44,7 +44,7 @@ export const formatOpenHost = host => {
}
export function parsePublicPath (publicPath = '/') {
- return ['', 'auto'].includes(publicPath) ? publicPath : addTrailingSlash(publicPath)
+ return ['', 'auto'].includes(publicPath) ? publicPath : addTrailingSlash(publicPath)
}
export function parseHtmlScript (pxtransformOption: IPostcssOption['pxtransform'] = {}) {
diff --git a/packages/taro-webpack5-prebundle/src/prebundle/index.ts b/packages/taro-webpack5-prebundle/src/prebundle/index.ts
index f47ea399e6a1..e4f77e4d5711 100644
--- a/packages/taro-webpack5-prebundle/src/prebundle/index.ts
+++ b/packages/taro-webpack5-prebundle/src/prebundle/index.ts
@@ -71,8 +71,8 @@ export default class BasePrebundle e === env) as TMode
- || (!isWatch || process.env.NODE_ENV === 'production' ? 'production' : 'development')
+ this.mode = ['production', 'development', 'none'].find(e => e === env) as TMode ||
+ (!isWatch || process.env.NODE_ENV === 'production' ? 'production' : 'development')
this.prebundleCacheDir = path.resolve(cacheDir, './prebundle')
this.remoteCacheDir = path.resolve(cacheDir, './remote')
this.metadataPath = path.join(cacheDir, 'metadata.json')
@@ -210,7 +210,7 @@ export default class BasePrebundle 0) {
console.log(
chalk.yellowBright(
- `检测到依赖编译错误,已跳过`, deps.sort(sortDeps).map(e => chalk.bold(e)).join('、'),`依赖预编译。`,
+ `检测到依赖编译错误,已跳过`, deps.sort(sortDeps).map(e => chalk.bold(e)).join('、'), `依赖预编译。`,
`\n > 可以通过手动配置 ${
terminalLink('compiler.prebundle.exclude', 'https://nervjs.github.io/taro-docs/docs/next/config-detail#compilerprebundleexclude')
} 忽略该提示`
diff --git a/packages/taro-webpack5-prebundle/src/utils/path.ts b/packages/taro-webpack5-prebundle/src/utils/path.ts
index 28495851bbb5..8d7b49c56e55 100644
--- a/packages/taro-webpack5-prebundle/src/utils/path.ts
+++ b/packages/taro-webpack5-prebundle/src/utils/path.ts
@@ -1,5 +1,5 @@
export const addLeadingSlash = (url = '') => (url.charAt(0) === '/' ? url : '/' + url)
export const addTrailingSlash = (url = '') => (url.charAt(url.length - 1) === '/' ? url : url + '/')
export function parsePublicPath (publicPath = '/') {
- return ['', 'auto'].includes(publicPath) ? publicPath : addTrailingSlash(publicPath)
+ return ['', 'auto'].includes(publicPath) ? publicPath : addTrailingSlash(publicPath)
}
\ No newline at end of file
diff --git a/packages/taro-webpack5-runner/src/__tests__/mini-split-chunks.spec.ts b/packages/taro-webpack5-runner/src/__tests__/mini-split-chunks.spec.ts
index 38d93575a59e..b66fc007fca0 100644
--- a/packages/taro-webpack5-runner/src/__tests__/mini-split-chunks.spec.ts
+++ b/packages/taro-webpack5-runner/src/__tests__/mini-split-chunks.spec.ts
@@ -70,7 +70,7 @@ describe('mini-split-chunks', () => {
const chunkPaths: string[] = []
const matchChunks = (fileContent || '').match(new RegExp(regexp, 'g'))
;(matchChunks || []).forEach(chunkPath => {
- const regex =new RegExp(regexp, 'g')
+ const regex = new RegExp(regexp, 'g')
const matches = [...chunkPath.matchAll(regex)]
const paths: string[] = matches.map(match => {
// @ts-ignore
diff --git a/packages/taro-webpack5-runner/src/loaders/miniCompilerLoader.ts b/packages/taro-webpack5-runner/src/loaders/miniCompilerLoader.ts
index ea4dbeb076f9..11bca2540932 100644
--- a/packages/taro-webpack5-runner/src/loaders/miniCompilerLoader.ts
+++ b/packages/taro-webpack5-runner/src/loaders/miniCompilerLoader.ts
@@ -2,7 +2,7 @@ import { swc } from '@tarojs/helper'
import { getComponentsAlias } from '@tarojs/shared'
import { getOptions, isUrlRequest, urlToRequest } from 'loader-utils'
-import { templatesCache,XMLDependency } from '../plugins/MiniCompileModePlugin'
+import { templatesCache, XMLDependency } from '../plugins/MiniCompileModePlugin'
import type { RecursiveTemplate, UnRecursiveTemplate } from '@tarojs/shared/dist/template'
import type { LoaderContext } from 'webpack'
@@ -72,7 +72,7 @@ export default async function (this: LoaderContext, source) {
// 抓取模板内容
let res
- while((res = RE_TEMPLATES.exec(code)) !== null) {
+ while ((res = RE_TEMPLATES.exec(code)) !== null) {
const [, , raw] = res
// 小程序 xml 不支持 unescape,在此处对被 SWC 转义后的字符作还原
const content: string = unescape(raw)
@@ -118,7 +118,7 @@ export default async function (this: LoaderContext, source) {
function unescape (raw: string): string {
let temp = raw.replace(/\\([xu])([a-fA-F0-9]{2,4})/g, (_, $1: string, $2: string) => {
const isUnicode = $1 === 'u'
- const num = isUnicode ? $2 : $2.substring(0,2)
+ const num = isUnicode ? $2 : $2.substring(0, 2)
const charCode = parseInt(num, 16)
return String.fromCharCode(charCode) + (!isUnicode ? $2.substring(2) : '')
})
diff --git a/packages/taro-webpack5-runner/src/loaders/miniXScriptLoader.ts b/packages/taro-webpack5-runner/src/loaders/miniXScriptLoader.ts
index ac28c5794186..030e5b092a74 100644
--- a/packages/taro-webpack5-runner/src/loaders/miniXScriptLoader.ts
+++ b/packages/taro-webpack5-runner/src/loaders/miniXScriptLoader.ts
@@ -1,6 +1,6 @@
import { isUrlRequest, urlToRequest } from 'loader-utils'
-export default async function (source) {
+export default async function (source) {
const REG_REQUIRE = /require\(['"](.+\.wxs)['"]\)/g
const callback = this.async()
const importings: any[] = []
diff --git a/packages/taro-webpack5-runner/src/plugins/MiniCompileModePlugin.ts b/packages/taro-webpack5-runner/src/plugins/MiniCompileModePlugin.ts
index e5bccf040497..f492c0a9495c 100644
--- a/packages/taro-webpack5-runner/src/plugins/MiniCompileModePlugin.ts
+++ b/packages/taro-webpack5-runner/src/plugins/MiniCompileModePlugin.ts
@@ -26,7 +26,7 @@
*/
import path from 'path'
-import webpack, { type Compiler,Dependency, Module, } from 'webpack'
+import webpack, { type Compiler, Dependency, Module, } from 'webpack'
import type { MiniCombination } from '../webpack/MiniCombination'
@@ -221,7 +221,6 @@ interface IPluginOptions {
}
export default class MiniCompileModePlugin {
-
// eslint-disable-next-line no-useless-constructor
constructor (private options: IPluginOptions) {}
diff --git a/packages/taro-webpack5-runner/src/plugins/MiniPlugin.ts b/packages/taro-webpack5-runner/src/plugins/MiniPlugin.ts
index fd367d1d5a00..560ad086377a 100644
--- a/packages/taro-webpack5-runner/src/plugins/MiniPlugin.ts
+++ b/packages/taro-webpack5-runner/src/plugins/MiniPlugin.ts
@@ -811,9 +811,9 @@ export default class TaroMiniPlugin {
// 判断是否为第三方依赖的正则,如果 test 为 false 则为第三方依赖
const notNpmPkgReg = /^[.\\/]/
if (
- !this.options.skipProcessUsingComponents
- && !compPath.startsWith('plugin://')
- && !notNpmPkgReg.test(compPath)
+ !this.options.skipProcessUsingComponents &&
+ !compPath.startsWith('plugin://') &&
+ !notNpmPkgReg.test(compPath)
) {
const tempCompPath = getNpmPackageAbsolutePath(compPath)
@@ -1150,7 +1150,7 @@ export default class TaroMiniPlugin {
...config.content.usingComponents
}
- if(isUsingCustomWrapper) {
+ if (isUsingCustomWrapper) {
config.content.usingComponents[customWrapperName] = importCustomWrapperPath
}
if (!template.isSupportRecursive && !page.isNative) {
@@ -1252,7 +1252,7 @@ export default class TaroMiniPlugin {
...config.content.usingComponents
}
- if(isUsingCustomWrapper) {
+ if (isUsingCustomWrapper) {
config.content.usingComponents[customWrapperName] = importCustomWrapperPath
}
if (!template.isSupportRecursive && !page.isNative) {
@@ -1435,10 +1435,10 @@ export default class TaroMiniPlugin {
Object.keys(assets).forEach(assetName => {
const fileName = path.basename(assetName, path.extname(assetName))
if (
- (REG_STYLE.test(assetName) || REG_STYLE_EXT.test(assetName))
- && this.options.commonChunks.includes(fileName)
+ (REG_STYLE.test(assetName) || REG_STYLE_EXT.test(assetName)) &&
+ this.options.commonChunks.includes(fileName) &&
// app.wxss 不能引入独立分包中的 common 样式文件
- && independentPackageNames.every(name => !assetName.includes(name))
+ independentPackageNames.every(name => !assetName.includes(name))
) {
commons.add('\n')
commons.add(`@import ${JSON.stringify(urlToRequest(assetName))};`)
diff --git a/packages/taro-webpack5-runner/src/plugins/TaroNormalModule.ts b/packages/taro-webpack5-runner/src/plugins/TaroNormalModule.ts
index 3629b83901c8..e59237512d7d 100644
--- a/packages/taro-webpack5-runner/src/plugins/TaroNormalModule.ts
+++ b/packages/taro-webpack5-runner/src/plugins/TaroNormalModule.ts
@@ -41,7 +41,7 @@ export class TaroBaseNormalModule extends webpack.NormalModule {
this.collectProps = read()
this.elementNameSet = read()
this.componentNameSet = read()
-
+
if (!isEmpty(this.collectProps)) {
for (const key in this.collectProps) {
const attrs = componentConfig.thirdPartyComponents.get(key)
diff --git a/packages/taro-webpack5-runner/src/utils/index.ts b/packages/taro-webpack5-runner/src/utils/index.ts
index c648d38618ad..4b9a59851fd0 100644
--- a/packages/taro-webpack5-runner/src/utils/index.ts
+++ b/packages/taro-webpack5-runner/src/utils/index.ts
@@ -43,5 +43,5 @@ export const formatOpenHost = (host?: string) => {
}
export function parsePublicPath (publicPath = '/') {
- return ['', 'auto'].includes(publicPath) ? publicPath : addTrailingSlash(publicPath)
+ return ['', 'auto'].includes(publicPath) ? publicPath : addTrailingSlash(publicPath)
}
diff --git a/packages/taro-webpack5-runner/src/webpack/Combination.ts b/packages/taro-webpack5-runner/src/webpack/Combination.ts
index a9224a934be5..3ba2e616c050 100644
--- a/packages/taro-webpack5-runner/src/webpack/Combination.ts
+++ b/packages/taro-webpack5-runner/src/webpack/Combination.ts
@@ -56,8 +56,8 @@ export class Combination e === preMode)
- || (!rawConfig.isWatch || process.env.NODE_ENV === 'production' ? 'production' : 'development')
+ const mode = ['production', 'development', 'none'].find(e => e === preMode) ||
+ (!rawConfig.isWatch || process.env.NODE_ENV === 'production' ? 'production' : 'development')
/** process config.sass options */
const sassLoaderOption = await getSassLoaderOption(rawConfig)
this.config = {
diff --git a/packages/taro-webpack5-runner/src/webpack/H5Combination.ts b/packages/taro-webpack5-runner/src/webpack/H5Combination.ts
index 1df7bfee7020..5dd4d4fde71f 100644
--- a/packages/taro-webpack5-runner/src/webpack/H5Combination.ts
+++ b/packages/taro-webpack5-runner/src/webpack/H5Combination.ts
@@ -94,7 +94,6 @@ export class H5Combination extends Combination {
const plugin = this.webpackPlugin.getPlugins()
if (this.isBuildNativeComp) {
-
if (this.isVirtualEntry) {
plugin.VirtualModule = WebpackPlugin.getPlugin(VirtualModulesPlugin, [virtualEntryMap])
}
diff --git a/packages/taro-webpack5-runner/src/webpack/MiniWebpackModule.ts b/packages/taro-webpack5-runner/src/webpack/MiniWebpackModule.ts
index 6230c47a3bcc..9e9747175b30 100644
--- a/packages/taro-webpack5-runner/src/webpack/MiniWebpackModule.ts
+++ b/packages/taro-webpack5-runner/src/webpack/MiniWebpackModule.ts
@@ -207,7 +207,7 @@ export class MiniWebpackModule {
if (Array.isArray(compile.include)) {
rule.include.unshift(...compile.include)
}
-
+
if (Array.isArray(compile.exclude)) {
rule.exclude = [...compile.exclude]
}
diff --git a/packages/taro-with-weapp/__tests__/lifecycle.jsx b/packages/taro-with-weapp/__tests__/lifecycle.jsx
index b10c54519b44..1dd01502c688 100644
--- a/packages/taro-with-weapp/__tests__/lifecycle.jsx
+++ b/packages/taro-with-weapp/__tests__/lifecycle.jsx
@@ -230,5 +230,4 @@ describe('lifecycle', () => {
expect(spy).toBeCalledWith({})
})
-
})
diff --git a/packages/taro-with-weapp/__tests__/props.jsx b/packages/taro-with-weapp/__tests__/props.jsx
index 4467888a0903..cb86d88afe58 100644
--- a/packages/taro-with-weapp/__tests__/props.jsx
+++ b/packages/taro-with-weapp/__tests__/props.jsx
@@ -157,7 +157,7 @@ describe('lifecycle', () => {
@withWeapp({
attached () {
- this.triggerEvent('fork','a')
+ this.triggerEvent('fork', 'a')
}
})
class A extends TaroComponent {
diff --git a/packages/taro-with-weapp/jest.config.js b/packages/taro-with-weapp/jest.config.js
index d82a4c2727b4..80578f1b90ba 100644
--- a/packages/taro-with-weapp/jest.config.js
+++ b/packages/taro-with-weapp/jest.config.js
@@ -29,10 +29,10 @@ module.exports = {
}],
},
transformIgnorePatterns: ['/node_modules/'],
- coveragePathIgnorePatterns:[
+ coveragePathIgnorePatterns: [
'/__tests__/*'
],
moduleNameMapper: {
- '^@tarojs/api$':'/../taro-api/dist/index.js'
+ '^@tarojs/api$': '/../taro-api/dist/index.js'
}
}
diff --git a/packages/taro-with-weapp/src/index.ts b/packages/taro-with-weapp/src/index.ts
index 532f76aad6b4..e2102383bdcd 100644
--- a/packages/taro-with-weapp/src/index.ts
+++ b/packages/taro-with-weapp/src/index.ts
@@ -1,5 +1,5 @@
import { getCurrentInstance } from '@tarojs/runtime'
-import { ComponentLifecycle, createIntersectionObserver, createMediaQueryObserver,createSelectorQuery, eventCenter, nextTick } from '@tarojs/taro'
+import { ComponentLifecycle, createIntersectionObserver, createMediaQueryObserver, createSelectorQuery, eventCenter, nextTick } from '@tarojs/taro'
import { clone } from './clone'
import { diff } from './diff'
@@ -138,29 +138,26 @@ export default function withWeapp (weappConf: WxOptions, isApp = false) {
const propValue = props[propKey]
// propValue 可能是 null, 构造函数, 对象
const observers = [propToState]
- if(propValue === null || propValue === undefined){ // propValue为null、undefined情况
+ if (propValue === null || propValue === undefined) { // propValue为null、undefined情况
properties[propKey] = null
- }
- else if(isFunction(propValue)) { // propValue为Function,即Array、String、Boolean等情况时
+ } else if (isFunction(propValue)) { // propValue为Function,即Array、String、Boolean等情况时
if (propValue.name === 'Array') {
properties[propKey] = []
- } else if(propValue.name === 'String'){
+ } else if (propValue.name === 'String') {
properties[propKey] = ''
- } else if(propValue.name === 'Boolean'){
+ } else if (propValue.name === 'Boolean') {
properties[propKey] = false
- } else if(propValue.name === 'Number') {
+ } else if (propValue.name === 'Number') {
properties[propKey] = 0
} else {
properties[propKey] = null
}
- }
- else if(typeof propValue === 'object') { // propValue为对象时
+ } else if (typeof propValue === 'object') { // propValue为对象时
properties[propKey] = propValue.value
if (propValue.observer) {
observers.push(propValue.observer)
}
- }
- else {
+ } else {
properties[propKey] = null
}
this._observeProps.push({
@@ -415,7 +412,7 @@ export default function withWeapp (weappConf: WxOptions, isApp = false) {
const nextProp = nextProps[key]
// 小程序是深比较不同之后才 trigger observer
if (!isEqual(prop, nextProp)) {
- observers.forEach((observer)=>{
+ observers.forEach((observer) => {
if (typeof observer === 'string') {
const ob = this[observer]
if (isFunction(ob)) {
diff --git a/packages/taroize/__tests__/event.test.ts b/packages/taroize/__tests__/event.test.ts
index 367662f2c132..988344994c0c 100644
--- a/packages/taroize/__tests__/event.test.ts
+++ b/packages/taroize/__tests__/event.test.ts
@@ -11,8 +11,8 @@ interface Option {
const logFileMap = new Map()
jest.mock('fs', () => ({
...jest.requireActual('fs'), // 保留原始的其他函数
- appendFile: jest.fn((path,content):any => {
- logFileMap.set(path,content)
+ appendFile: jest.fn((path, content):any => {
+ logFileMap.set(path, content)
})
}))
diff --git a/packages/taroize/__tests__/index.test.ts b/packages/taroize/__tests__/index.test.ts
index 5919f9e5fcd8..4617ebc8716f 100644
--- a/packages/taroize/__tests__/index.test.ts
+++ b/packages/taroize/__tests__/index.test.ts
@@ -6,8 +6,8 @@ expect.addSnapshotSerializer(removeBackslashesSerializer)
const logFileMap = new Map()
jest.mock('fs', () => ({
...jest.requireActual('fs'), // 保留原始的其他函数
- appendFile: jest.fn((path,content):any => {
- logFileMap.set(path,content)
+ appendFile: jest.fn((path, content):any => {
+ logFileMap.set(path, content)
})
}))
@@ -18,7 +18,7 @@ describe('parse', () => {
describe('template.ts', () => {
let option: any
-
+
beforeAll(() => {
option = {
script: '',
@@ -35,7 +35,7 @@ describe('parse', () => {
test('公共组件usingComponents的key加到THIRD_PARTY_COMPONENTS', () => {
// app.json的目录结构以及内容
- /*
+ /*
** /app.json:
** "{
** "pages": [
@@ -50,7 +50,7 @@ describe('parse', () => {
option.rootPath = '/wxProject/miniprogram'
option.logFilePath = '/wxProject/taroConvert/.convert/convert.log'
option.script = `app({})`
- option.json =
+ option.json =
`{
"pages":["pages/index/index"],
"usingComponents":
@@ -66,5 +66,4 @@ describe('parse', () => {
expect(code).toMatchSnapshot()
})
})
-
})
\ No newline at end of file
diff --git a/packages/taroize/__tests__/script.test.ts b/packages/taroize/__tests__/script.test.ts
index a9365e972638..309767f81c48 100644
--- a/packages/taroize/__tests__/script.test.ts
+++ b/packages/taroize/__tests__/script.test.ts
@@ -6,8 +6,8 @@ expect.addSnapshotSerializer(removeBackslashesSerializer)
const logFileMap = new Map()
jest.mock('fs', () => ({
...jest.requireActual('fs'), // 保留原始的其他函数
- appendFile: jest.fn((path,content):any => {
- logFileMap.set(path,content)
+ appendFile: jest.fn((path, content):any => {
+ logFileMap.set(path, content)
})
}))
diff --git a/packages/taroize/__tests__/utils.test.ts b/packages/taroize/__tests__/utils.test.ts
index 5e99723a5803..91aebbaa0e41 100644
--- a/packages/taroize/__tests__/utils.test.ts
+++ b/packages/taroize/__tests__/utils.test.ts
@@ -6,8 +6,8 @@ expect.addSnapshotSerializer(removeBackslashesSerializer)
const logFileMap = new Map()
jest.mock('fs', () => ({
...jest.requireActual('fs'), // 保留原始的其他函数
- appendFile: jest.fn((path,content):any => {
- logFileMap.set(path,content)
+ appendFile: jest.fn((path, content):any => {
+ logFileMap.set(path, content)
})
}))
@@ -36,7 +36,7 @@ describe('utils.ts', () => {
expect(codeStr).toMatchSnapshot()
})
- test('flow插件支持flow类型转换',() => {
+ test('flow插件支持flow类型转换', () => {
code = `
// @flow
function square(num: number): number {
@@ -49,7 +49,7 @@ describe('utils.ts', () => {
expect(codeStr).toMatchSnapshot()
})
- test('decorators-legacy插件支持装饰器转换',() => {
+ test('decorators-legacy插件支持装饰器转换', () => {
code = `
class MyClass {
@decorator
@@ -61,16 +61,16 @@ describe('utils.ts', () => {
const ast = parseCode(code, scriptPath)
const codeStr = generateMinimalEscapeCode(ast)
expect(codeStr).toMatchSnapshot()
- })
+ })
- test('optionalChainingAssign插件支持链式赋值语法',() => {
+ test('optionalChainingAssign插件支持链式赋值语法', () => {
code = `x?.prop = 2;`
const ast = parseCode(code, scriptPath)
const codeStr = generateMinimalEscapeCode(ast)
expect(codeStr).toBe('x?.prop = 2;')
})
-
- test('sourcePhaseImports插件支持导入语句放在顶部之外的地方',() => {
+
+ test('sourcePhaseImports插件支持导入语句放在顶部之外的地方', () => {
code = `
const name = options && options.name ? options.name : "Anonymous";
import source x from "./x"
@@ -80,23 +80,23 @@ describe('utils.ts', () => {
expect(codeStr).toMatchSnapshot()
})
- test('throwExpressions插件支持throw表达式',() => {
+ test('throwExpressions插件支持throw表达式', () => {
code = `() => throw new Error("");`
const ast = parseCode(code, scriptPath)
const codeStr = generateMinimalEscapeCode(ast)
expect(codeStr).toBe(`() => throw new Error("");`)
})
- test('deferredImportEvaluation插件支持延迟导入',() => {
+ test('deferredImportEvaluation插件支持延迟导入', () => {
code = `import defer * as ns from "dep"`
- const ast = parseCode(code, scriptPath)
+ const ast = parseCode(code, scriptPath)
const codeStr = generateMinimalEscapeCode(ast)
expect(codeStr).toBe(`import * as ns from "dep";`)
})
- test('exportDefaultFrom插件支持使用 export default from 语法导入默认导出',() => {
+ test('exportDefaultFrom插件支持使用 export default from 语法导入默认导出', () => {
code = `export v from "mod"`
- const ast = parseCode(code, scriptPath)
+ const ast = parseCode(code, scriptPath)
const codeStr = generateMinimalEscapeCode(ast)
expect(codeStr).toBe('export v from "mod";')
})
diff --git a/packages/taroize/src/cache.ts b/packages/taroize/src/cache.ts
index b583afc64f07..f81c68d299a0 100644
--- a/packages/taroize/src/cache.ts
+++ b/packages/taroize/src/cache.ts
@@ -5,8 +5,7 @@ import { Wxml } from './wxml'
const cacheMap = new Map()
export function getCacheWxml (dirpath: string, wxml: any): Wxml | undefined {
- if (wxml === cacheMap.get(dirpath)?.wxml)
- return cloneDeep(cacheMap.get(dirpath))
+ if (wxml === cacheMap.get(dirpath)?.wxml) { return cloneDeep(cacheMap.get(dirpath)) }
}
export function saveCacheWxml (dirpath: string, wxml: Wxml) {