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 { ? `