From 1d495073fda50a4486142f204608e05c0a7d8942 Mon Sep 17 00:00:00 2001 From: Eiinu Date: Sun, 31 Mar 2024 11:53:47 +0800 Subject: [PATCH] chore: move to ESLint Flat Config (#3003) * chore: move to ESLint Flat Config * fix: add gitignore --- .editorconfig | 12 - .eslintrc | 7 - .gitignore | 3 + eslint.config.js | 7 + package.json | 8 +- packages/nutui-eslint-config/index.js | 102 +++--- packages/nutui-eslint-config/package.json | 7 +- packages/nutui-playground/src/store.ts | 4 +- .../src/business/pages/address/index.vue | 2 +- .../src/business/pages/category/index.vue | 10 +- .../src/business/pages/comment/index.vue | 4 +- .../src/business/pages/timeselect/basic.vue | 2 +- .../business/pages/timeselect/multiple.vue | 6 +- .../src/business/pages/timeselect/title.vue | 2 +- .../nutui-taro-demo/src/components/header.vue | 2 +- .../src/dentry/pages/calendar/multiple.vue | 2 +- .../src/dentry/pages/checkbox/methods.vue | 8 +- .../src/dentry/pages/datepicker/filter.vue | 2 +- .../src/dentry/pages/input/format.vue | 2 +- .../src/dentry/pages/uploader/index.vue | 8 +- .../exhibition/pages/imagepreview/index.vue | 4 +- .../src/feedback/pages/dialog/index.vue | 2 +- .../src/nav/pages/tabs/custom.vue | 3 +- .../nutui-taro-demo/src/pages/index/index.vue | 2 +- .../nutui-taro-demo/src/utils/useTranslate.ts | 6 +- packages/nutui-vscode-extension/package.json | 98 ++--- .../src/componentMap.ts | 170 ++++----- pnpm-lock.yaml | 335 +++++++++++++++++- src/packages/__VUE/address/demo.vue | 2 +- src/packages/__VUE/address/index.taro.vue | 17 +- src/packages/__VUE/address/index.vue | 17 +- .../components/ItemContents.taro.vue | 8 +- .../addresslist/components/ItemContents.vue | 8 +- src/packages/__VUE/addresslist/index.taro.vue | 2 +- src/packages/__VUE/addresslist/index.vue | 2 +- src/packages/__VUE/audio/index.vue | 22 +- src/packages/__VUE/audiooperate/index.vue | 43 ++- .../__VUE/avatarcropper/index.taro.vue | 32 +- src/packages/__VUE/avatarcropper/index.vue | 2 +- src/packages/__VUE/calendar/demo/multiple.vue | 2 +- .../__VUE/calendarcard/calendar-card.taro.vue | 16 +- .../__VUE/calendarcard/calendar-card.vue | 16 +- src/packages/__VUE/calendarcard/icon.taro.ts | 16 +- .../__VUE/calendaritem/index.taro.vue | 79 +++-- src/packages/__VUE/calendaritem/index.vue | 87 ++--- .../__VUE/cascader/__tests__/cascader.spec.ts | 2 +- .../__VUE/cascader/cascader-item.taro.vue | 10 +- src/packages/__VUE/cascader/cascader-item.vue | 10 +- src/packages/__VUE/cascader/tree.ts | 2 +- src/packages/__VUE/category/demo.vue | 15 +- src/packages/__VUE/category/index.taro.vue | 6 +- src/packages/__VUE/category/index.vue | 6 +- .../__VUE/categorypane/index.taro.vue | 6 +- src/packages/__VUE/categorypane/index.vue | 6 +- src/packages/__VUE/checkbox/demo/methods.vue | 8 +- src/packages/__VUE/checkbox/index.taro.vue | 8 +- src/packages/__VUE/checkbox/index.vue | 8 +- .../__VUE/checkboxgroup/index.taro.vue | 2 +- src/packages/__VUE/checkboxgroup/index.vue | 2 +- .../circleprogress/__tests__/index.spec.ts | 4 +- .../comment/components/CmtBottom.taro.vue | 13 +- .../__VUE/comment/components/CmtBottom.vue | 13 +- src/packages/__VUE/comment/demo.vue | 10 +- src/packages/__VUE/comment/index.taro.vue | 8 +- src/packages/__VUE/comment/index.vue | 8 +- src/packages/__VUE/configprovider/common.ts | 24 +- src/packages/__VUE/countdown/index.taro.vue | 6 +- src/packages/__VUE/countdown/index.vue | 6 +- src/packages/__VUE/countup/index.taro.vue | 78 ++-- src/packages/__VUE/countup/index.vue | 82 +++-- src/packages/__VUE/datepicker/demo/filter.vue | 2 +- src/packages/__VUE/datepicker/index.taro.vue | 4 +- src/packages/__VUE/datepicker/index.vue | 4 +- src/packages/__VUE/dialog/__tests__/dialog.ts | 6 +- src/packages/__VUE/dialog/demo.vue | 2 +- src/packages/__VUE/dialog/index.taro.vue | 2 +- src/packages/__VUE/dialog/index.ts | 2 +- src/packages/__VUE/dialog/index.vue | 2 +- src/packages/__VUE/elevator/index.taro.vue | 4 +- src/packages/__VUE/elevator/index.vue | 12 +- .../__VUE/ellipsis/__tests__/ellipsis.spec.ts | 4 +- src/packages/__VUE/ellipsis/index.taro.vue | 66 ++-- src/packages/__VUE/ellipsis/index.vue | 25 +- src/packages/__VUE/form/form.taro.vue | 2 +- src/packages/__VUE/form/form.vue | 2 +- .../__VUE/formitem/form-item.taro.vue | 5 +- src/packages/__VUE/formitem/form-item.vue | 5 +- src/packages/__VUE/image/index.vue | 2 +- src/packages/__VUE/imagepreview/demo.vue | 4 +- .../__VUE/imagepreview/index.taro.vue | 8 +- .../__tests__/infiniteloading.spec.ts | 4 +- src/packages/__VUE/infiniteloading/index.vue | 4 +- src/packages/__VUE/input/demo/format.vue | 2 +- src/packages/__VUE/input/index.taro.vue | 4 +- src/packages/__VUE/input/index.vue | 4 +- .../__VUE/menu/__tests__/menu.spec.tsx | 6 +- src/packages/__VUE/menu/index.taro.vue | 2 +- src/packages/__VUE/menu/index.vue | 2 +- src/packages/__VUE/menuitem/index.taro.vue | 4 +- src/packages/__VUE/menuitem/index.vue | 4 +- src/packages/__VUE/noticebar/index.taro.vue | 2 +- src/packages/__VUE/noticebar/index.vue | 5 +- src/packages/__VUE/notify/__tests__/notify.ts | 8 +- src/packages/__VUE/notify/index.ts | 8 +- .../__VUE/numberkeyboard/index.taro.vue | 2 +- src/packages/__VUE/numberkeyboard/index.vue | 2 +- .../__VUE/pagination/__tests__/index.spec.ts | 14 +- src/packages/__VUE/pagination/index.taro.vue | 20 +- src/packages/__VUE/pagination/index.vue | 20 +- src/packages/__VUE/picker/Column.vue | 4 +- src/packages/__VUE/picker/index.taro.vue | 24 +- src/packages/__VUE/picker/index.vue | 8 +- src/packages/__VUE/picker/usePicker.ts | 6 +- src/packages/__VUE/popover/index.taro.vue | 10 +- src/packages/__VUE/popover/index.vue | 2 +- src/packages/__VUE/radiogroup/index.taro.vue | 2 +- src/packages/__VUE/radiogroup/index.vue | 2 +- src/packages/__VUE/range/index.taro.vue | 8 +- src/packages/__VUE/range/index.vue | 8 +- src/packages/__VUE/searchbar/index.taro.vue | 2 +- src/packages/__VUE/searchbar/index.vue | 2 +- .../__VUE/shortpassword/index.taro.vue | 2 +- src/packages/__VUE/shortpassword/index.vue | 2 +- src/packages/__VUE/signature/index.vue | 2 +- src/packages/__VUE/skeleton/index.taro.vue | 20 +- src/packages/__VUE/skeleton/index.vue | 20 +- .../__VUE/sku/components/SkuHeader.taro.vue | 6 +- .../__VUE/sku/components/SkuHeader.vue | 6 +- .../__VUE/sku/components/SkuOperate.vue | 3 +- src/packages/__VUE/sku/demo.vue | 6 +- src/packages/__VUE/space/index.taro.vue | 10 +- src/packages/__VUE/space/index.vue | 10 +- src/packages/__VUE/swiper/index.taro.vue | 2 +- src/packages/__VUE/swiper/index.vue | 4 +- .../__VUE/tabbar/__tests__/index.spec.tsx | 26 +- src/packages/__VUE/table/index.taro.vue | 4 +- src/packages/__VUE/table/index.vue | 4 +- .../__VUE/tabs/__tests__/index.spec.tsx | 27 +- src/packages/__VUE/tabs/demo/custom.vue | 3 +- src/packages/__VUE/tabs/index.taro.vue | 12 +- src/packages/__VUE/tabs/index.vue | 14 +- .../__VUE/textarea/__tests__/textarea.spec.ts | 2 +- src/packages/__VUE/textarea/index.vue | 4 +- .../timeselect/__tests__/timeselect.spec.ts | 4 +- src/packages/__VUE/timeselect/demo/basic.vue | 2 +- .../__VUE/timeselect/demo/multiple.vue | 6 +- src/packages/__VUE/timeselect/demo/title.vue | 2 +- src/packages/__VUE/toast/__tests__/toast.ts | 12 +- src/packages/__VUE/toast/index.ts | 12 +- .../__VUE/tour/__tests__/tour.spec.tsx | 3 +- src/packages/__VUE/tour/index.taro.vue | 12 +- src/packages/__VUE/tour/index.vue | 16 +- src/packages/__VUE/uploader/demo.vue | 6 +- src/packages/__VUE/uploader/index.taro.vue | 2 +- src/packages/__VUE/uploader/index.vue | 2 +- src/packages/__VUE/uploader/uploader.ts | 6 +- src/packages/__VUE/video/index.vue | 38 +- src/packages/locale/index.ts | 2 + src/packages/locale/lang/baseLang.ts | 17 + src/packages/locale/lang/en-US.ts | 18 + src/packages/locale/lang/id-ID.ts | 19 + src/packages/locale/lang/zh-CN.ts | 19 + src/packages/locale/lang/zh-TW.ts | 19 + src/packages/utils/Interceptor.ts | 2 +- src/packages/utils/canvas.ts | 6 +- src/packages/utils/create/component.ts | 2 +- src/packages/utils/create/mountComponent.ts | 8 +- src/packages/utils/date.ts | 22 +- src/packages/utils/raf.ts | 6 +- src/packages/utils/throttle.ts | 8 +- src/packages/utils/useRect/index.ts | 12 +- src/packages/utils/useRelation/useChildren.ts | 4 +- src/packages/utils/useTaroRect/index.ts | 12 +- src/packages/utils/util.ts | 8 +- src/sites/assets/util/helper.ts | 58 +-- src/sites/assets/util/ref.ts | 3 +- src/sites/assets/util/useTranslate.ts | 6 +- .../doc/components/demo-block/demoBlock.vue | 19 +- .../doc/components/demo-block/index.html | 13 + src/sites/doc/directive/hover/hover.ts | 2 +- src/sites/doc/views/Index.vue | 4 +- src/sites/mobile/components/Index.vue | 3 +- src/sites/mobile/router.ts | 2 +- src/sites/utils/useTranslate.ts | 6 +- 184 files changed, 1508 insertions(+), 996 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc create mode 100644 eslint.config.js create mode 100644 src/sites/doc/components/demo-block/index.html diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index b3986732eb..0000000000 --- a/.editorconfig +++ /dev/null @@ -1,12 +0,0 @@ -root = true - -[*] -indent_style = space -indent_size = 2 -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = false - -[*.md] -trim_trailing_whitespace = false diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index 1eddb26afd..0000000000 --- a/.eslintrc +++ /dev/null @@ -1,7 +0,0 @@ -{ - "root": true, - "extends": ["@nutui/eslint-config"], - "ignorePatterns": [ - "src/sites/**" - ] -} diff --git a/.gitignore b/.gitignore index 08b003e235..67d35e6bae 100644 --- a/.gitignore +++ b/.gitignore @@ -39,3 +39,6 @@ pnpm-debug.log* # vitest /html + +# packages/nutui-taro-demo +/packages/nutui-taro-demo/src/app.config.ts \ No newline at end of file diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 0000000000..be2bacc939 --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,7 @@ +import NutUI from '@nutui/eslint-config' +import gitignore from 'eslint-config-flat-gitignore' + +export default [ + gitignore(), + ...NutUI +] diff --git a/package.json b/package.json index fd95facaf0..10d21833d6 100644 --- a/package.json +++ b/package.json @@ -55,8 +55,9 @@ "test": "vitest", "test:ui": "vitest --ui --coverage", "test:c": "vitest --coverage", - "lint": "eslint ./src ./packages/**/src --ext .vue,.ts,.tsx,.js,.jsx", + "lint": "eslint ./src ./packages/**/src", "lint:fix": "pnpm lint --fix", + "lint:ui": "pnpm eslint-config-inspector", "copydocs": "node ./scripts/copymd.cjs", "attrs": "node ./scripts/createAttributes.cjs", "attrs:taro": "node ./scripts/createAttributes.cjs taro", @@ -80,6 +81,8 @@ "devDependencies": { "@commitlint/cli": "^19.2.1", "@commitlint/config-conventional": "^19.1.0", + "@eslint/config-inspector": "^0.1.0", + "@eslint/eslintrc": "^3.0.2", "@nutui/eslint-config": "workspace:*", "@nutui/prettier-plugin": "workspace:*", "@nutui/vite-plugins": "workspace:*", @@ -94,6 +97,7 @@ "autoprefixer": "^10.4.19", "codesandbox": "^2.2.3", "eslint": "^8.57.0", + "eslint-config-flat-gitignore": "^0.1.3", "fs-extra": "^11.2.0", "happy-dom": "^14.3.9", "husky": "^9.0.11", @@ -116,7 +120,7 @@ "node": "^18.0.0 || >=20.0.0" }, "nano-staged": { - "*.{ts,tsx,js,jsx,vue,scss,md}": "prettier --write", + "*.{css,scss,md}": "prettier --write", "*.{ts,tsx,js,jsx,vue}": "eslint --fix" }, "repository": { diff --git a/packages/nutui-eslint-config/index.js b/packages/nutui-eslint-config/index.js index cf5ee0877a..4663e43adf 100644 --- a/packages/nutui-eslint-config/index.js +++ b/packages/nutui-eslint-config/index.js @@ -1,46 +1,64 @@ -module.exports = { - extends: ['plugin:vue/base', 'eslint:recommended', 'plugin:vue/vue3-recommended', 'prettier'], - parser: 'vue-eslint-parser', - parserOptions: { - parser: '@typescript-eslint/parser', - ecmaVersion: 2020, - sourceType: 'module', - ecmaFeatures: { - jsx: true +import pluginJs from '@eslint/js' +import pluginVue from 'eslint-plugin-vue' +import pluginTs from 'typescript-eslint' +import stylistic from '@stylistic/eslint-plugin' + +import parserVue from 'vue-eslint-parser' +import parserTs from '@typescript-eslint/parser' + +export default [ + pluginJs.configs.recommended, + stylistic.configs.customize({ + quoteProps: 'as-needed', + commaDangle: 'never', + braceStyle: '1tbs' + }), + ...pluginTs.configs.recommended, + ...pluginVue.configs['flat/recommended'], + { + rules: { + // typescript-eslint + '@typescript-eslint/no-explicit-any': 'off', + '@typescript-eslint/ban-types': 'off', + '@typescript-eslint/no-var-requires': 'off', + 'no-unused-vars': 'off', + '@typescript-eslint/no-unused-vars': 'error', + '@typescript-eslint/ban-ts-comment': 'off', + // eslint-plugin-vue + 'vue/v-on-event-hyphenation': [ + 'error', + 'always', + { + autofix: true + } + ], + 'vue/no-v-html': 'off', + 'vue/max-attributes-per-line': 'off', + 'vue/first-attribute-linebreak': 'off', + 'vue/multi-word-component-names': 'off', + 'vue/no-v-text-v-html-on-component': 'off', + // TODO: will be removed + 'vue/html-self-closing': 'off', + 'vue/html-closing-bracket-newline': 'off', + 'vue/singleline-html-element-content-newline': 'off' } }, - plugins: ['vue', '@typescript-eslint'], - env: { - es6: true, - node: true, - browser: true, - jest: true - }, - globals: { - vi: true, - NodeJS: true, - TaroGeneral: true - }, - rules: { - // basic - semi: [2, 'never'], - // @typescript-eslint - '@typescript-eslint/no-explicit-any': 'off', - '@typescript-eslint/ban-types': 'off', - '@typescript-eslint/no-var-requires': 'off', - 'no-unused-vars': 'off', - '@typescript-eslint/no-unused-vars': 'error', - // eslint-plugin-vue - 'vue/v-on-event-hyphenation': [ - 'error', - 'always', - { - autofix: true + { + languageOptions: { + parser: parserVue, + globals: { + vi: true, + NodeJS: true, + TaroGeneral: true + }, + parserOptions: { + parser: parserTs, + ecmaVersion: 2020, + sourceType: 'module', + ecmaFeatures: { + jsx: true + } } - ], - 'vue/no-v-html': 'off', - 'vue/first-attribute-linebreak': 'off', - 'vue/multi-word-component-names': 'off', - 'vue/no-v-text-v-html-on-component': 'off' + } } -} +] diff --git a/packages/nutui-eslint-config/package.json b/packages/nutui-eslint-config/package.json index b0003b50f5..7c1375d2f2 100644 --- a/packages/nutui-eslint-config/package.json +++ b/packages/nutui-eslint-config/package.json @@ -9,6 +9,7 @@ "jdf2e" ], "author": "jdf2e", + "type": "module", "license": "MIT", "main": "index.js", "publishConfig": { @@ -24,11 +25,13 @@ "url": "https://github.com/jdf2e/nutui/issues" }, "dependencies": { + "@stylistic/eslint-plugin": "^1.7.0", "@typescript-eslint/eslint-plugin": "^7.4.0", "@typescript-eslint/parser": "^7.4.0", - "eslint-config-prettier": "^9.1.0", "eslint-plugin-vue": "^9.24.0", - "vue-eslint-parser": "^9.4.2" + "typescript-eslint": "^7.4.0", + "vue-eslint-parser": "^9.4.2", + "@eslint/js": "^8.57.0" }, "devDependencies": { "eslint": "^8.57.0" diff --git a/packages/nutui-playground/src/store.ts b/packages/nutui-playground/src/store.ts index f4bf8bb219..129e9db061 100644 --- a/packages/nutui-playground/src/store.ts +++ b/packages/nutui-playground/src/store.ts @@ -101,6 +101,7 @@ export class NutUIStore extends ReplStore { this.state.mainFile = CONTAINER_FILE this.setActive(APP_FILE) } + serialize() { const files = this.getFiles() delete files[IMPORTMAP_FILE] @@ -109,11 +110,12 @@ export class NutUIStore extends ReplStore { delete files[INSTALL_FILE.replace('src/', '')] return '#' + utoa(JSON.stringify(files)) } + setNutUIVersion(v: string) { style.value = `https://cdn.jsdelivr.net/npm/@nutui/nutui@${v}/dist/style.css` const install = new File(INSTALL_FILE, installCode.value, true) this.addFile(install) - compileFile(this, install).then((errs) => this.state.errors.push(...errs)) + compileFile(this, install).then(errs => this.state.errors.push(...errs)) this.setImportMap({ imports: { '@nutui/nutui': `https://cdn.jsdelivr.net/npm/@nutui/nutui@${v}/dist/nutui.js`, diff --git a/packages/nutui-taro-demo/src/business/pages/address/index.vue b/packages/nutui-taro-demo/src/business/pages/address/index.vue index e372a41cf2..4452708345 100644 --- a/packages/nutui-taro-demo/src/business/pages/address/index.vue +++ b/packages/nutui-taro-demo/src/business/pages/address/index.vue @@ -244,7 +244,7 @@ const showSelected = () => { const onChange = (cal: CalBack, tag: string) => { const name = (address as any)[cal.next] if (name?.length < 1) { - ;(showPopup as any)[tag] = false + (showPopup as any)[tag] = false } } const close1 = (val: CalResult) => { diff --git a/packages/nutui-taro-demo/src/business/pages/category/index.vue b/packages/nutui-taro-demo/src/business/pages/category/index.vue index 74635d814a..711b0bbac3 100644 --- a/packages/nutui-taro-demo/src/business/pages/category/index.vue +++ b/packages/nutui-taro-demo/src/business/pages/category/index.vue @@ -7,13 +7,13 @@

只显示文字

- + +

自定义分类

- + + + diff --git a/packages/nutui-taro-demo/src/business/pages/comment/index.vue b/packages/nutui-taro-demo/src/business/pages/comment/index.vue index e658451a30..9107a308cc 100644 --- a/packages/nutui-taro-demo/src/business/pages/comment/index.vue +++ b/packages/nutui-taro-demo/src/business/pages/comment/index.vue @@ -79,8 +79,8 @@ const getData = () => { method: 'GET', url: 'https://storage.360buyimg.com/nutui/3x/comment_data.json', success: (res) => { - res.data.Comment.info.avatar = - 'https://img14.360buyimg.com/imagetools/jfs/t1/167902/2/8762/791358/603742d7E9b4275e3/e09d8f9a8bf4c0ef.png' + res.data.Comment.info.avatar + = 'https://img14.360buyimg.com/imagetools/jfs/t1/167902/2/8762/791358/603742d7E9b4275e3/e09d8f9a8bf4c0ef.png' cmt.value = res.data.Comment } }) diff --git a/packages/nutui-taro-demo/src/business/pages/timeselect/basic.vue b/packages/nutui-taro-demo/src/business/pages/timeselect/basic.vue index ddfabf7038..fbe86886ba 100644 --- a/packages/nutui-taro-demo/src/business/pages/timeselect/basic.vue +++ b/packages/nutui-taro-demo/src/business/pages/timeselect/basic.vue @@ -42,7 +42,7 @@ const onChange = (pannelKey) => { } const onSelect = (item) => { - let curTimeIndex = time.value[0]['list'].findIndex((time) => time === item) + let curTimeIndex = time.value[0]['list'].findIndex(time => time === item) if (curTimeIndex === -1) { time.value[0]['list'].push(item) } else { diff --git a/packages/nutui-taro-demo/src/business/pages/timeselect/multiple.vue b/packages/nutui-taro-demo/src/business/pages/timeselect/multiple.vue index 4c2ffbff8a..6b533a7961 100644 --- a/packages/nutui-taro-demo/src/business/pages/timeselect/multiple.vue +++ b/packages/nutui-taro-demo/src/business/pages/timeselect/multiple.vue @@ -34,7 +34,7 @@ const times = ref([ const onChange = (pannelKey) => { key.value = pannelKey - const curTime = time.value.find((item) => item.key == pannelKey) + const curTime = time.value.find(item => item.key == pannelKey) if (!curTime) { time.value.push({ key: pannelKey, @@ -44,8 +44,8 @@ const onChange = (pannelKey) => { } const onSelect = (item) => { - let findIndex = time.value.findIndex((item) => item.key == key.value) - let curTimeIndex = time.value[findIndex]['list'].findIndex((time) => time === item) + let findIndex = time.value.findIndex(item => item.key == key.value) + let curTimeIndex = time.value[findIndex]['list'].findIndex(time => time === item) if (curTimeIndex === -1) { time.value[findIndex]['list'].push(item) } else { diff --git a/packages/nutui-taro-demo/src/business/pages/timeselect/title.vue b/packages/nutui-taro-demo/src/business/pages/timeselect/title.vue index 6cb6e1fab2..3eb5f0826b 100644 --- a/packages/nutui-taro-demo/src/business/pages/timeselect/title.vue +++ b/packages/nutui-taro-demo/src/business/pages/timeselect/title.vue @@ -43,7 +43,7 @@ const onChange = (pannelKey) => { } const onSelect = (item) => { - let curTimeIndex = time.value[0]['list'].findIndex((time) => time === item) + let curTimeIndex = time.value[0]['list'].findIndex(time => time === item) if (curTimeIndex === -1) { time.value[0]['list'].push(item) } else { diff --git a/packages/nutui-taro-demo/src/components/header.vue b/packages/nutui-taro-demo/src/components/header.vue index 077a945c75..ef6fb836fe 100644 --- a/packages/nutui-taro-demo/src/components/header.vue +++ b/packages/nutui-taro-demo/src/components/header.vue @@ -19,7 +19,7 @@ import config from '@/packages/../config.json' const isH5 = Taro.getEnv() === Taro.ENV_TYPE.WEB -//返回demo页 +// 返回demo页 const navigateTo = () => { Taro.navigateBack() } diff --git a/packages/nutui-taro-demo/src/dentry/pages/calendar/multiple.vue b/packages/nutui-taro-demo/src/dentry/pages/calendar/multiple.vue index ee825d7c18..be4565ad6c 100644 --- a/packages/nutui-taro-demo/src/dentry/pages/calendar/multiple.vue +++ b/packages/nutui-taro-demo/src/dentry/pages/calendar/multiple.vue @@ -16,6 +16,6 @@ import { ref } from 'vue' const show = ref(false) const date = ref([]) const choose = (param) => { - date.value = param.map((item) => item[3]) + date.value = param.map(item => item[3]) } diff --git a/packages/nutui-taro-demo/src/dentry/pages/checkbox/methods.vue b/packages/nutui-taro-demo/src/dentry/pages/checkbox/methods.vue index 26143dce92..0de0ea14f4 100644 --- a/packages/nutui-taro-demo/src/dentry/pages/checkbox/methods.vue +++ b/packages/nutui-taro-demo/src/dentry/pages/checkbox/methods.vue @@ -1,9 +1,11 @@ diff --git a/src/packages/__VUE/calendarcard/calendar-card.taro.vue b/src/packages/__VUE/calendarcard/calendar-card.taro.vue index 26a7f8cc34..02f3397d46 100644 --- a/src/packages/__VUE/calendarcard/calendar-card.taro.vue +++ b/src/packages/__VUE/calendarcard/calendar-card.taro.vue @@ -183,17 +183,17 @@ const isActive = (day: CalendarCardDay) => { const isStart = (day: CalendarCardDay) => { return ( - (props.type === 'range' || props.type === 'week') && - innerValue.value.length === 2 && - isSameDay(day, innerValue.value[0]) + (props.type === 'range' || props.type === 'week') + && innerValue.value.length === 2 + && isSameDay(day, innerValue.value[0]) ) } const isEnd = (day: CalendarCardDay) => { return ( - (props.type === 'range' || props.type === 'week') && - innerValue.value.length === 2 && - isSameDay(day, innerValue.value[1]) + (props.type === 'range' || props.type === 'week') + && innerValue.value.length === 2 + && isSameDay(day, innerValue.value[1]) ) } @@ -304,9 +304,9 @@ const handleDayClick = (day: CalendarCardDay) => { break } case 'multiple': { - const t = innerValue.value.find((i) => isSameDay(i, day)) + const t = innerValue.value.find(i => isSameDay(i, day)) if (t) { - change(innerValue.value.filter((i) => i !== t)) + change(innerValue.value.filter(i => i !== t)) } else { change([...innerValue.value, day]) } diff --git a/src/packages/__VUE/calendarcard/calendar-card.vue b/src/packages/__VUE/calendarcard/calendar-card.vue index a926f6df0b..b594887f67 100644 --- a/src/packages/__VUE/calendarcard/calendar-card.vue +++ b/src/packages/__VUE/calendarcard/calendar-card.vue @@ -183,17 +183,17 @@ const isActive = (day: CalendarCardDay) => { const isStart = (day: CalendarCardDay) => { return ( - (props.type === 'range' || props.type === 'week') && - innerValue.value.length === 2 && - isSameDay(day, innerValue.value[0]) + (props.type === 'range' || props.type === 'week') + && innerValue.value.length === 2 + && isSameDay(day, innerValue.value[0]) ) } const isEnd = (day: CalendarCardDay) => { return ( - (props.type === 'range' || props.type === 'week') && - innerValue.value.length === 2 && - isSameDay(day, innerValue.value[1]) + (props.type === 'range' || props.type === 'week') + && innerValue.value.length === 2 + && isSameDay(day, innerValue.value[1]) ) } @@ -304,9 +304,9 @@ const handleDayClick = (day: CalendarCardDay) => { break } case 'multiple': { - const t = innerValue.value.find((i) => isSameDay(i, day)) + const t = innerValue.value.find(i => isSameDay(i, day)) if (t) { - change(innerValue.value.filter((i) => i !== t)) + change(innerValue.value.filter(i => i !== t)) } else { change([...innerValue.value, day]) } diff --git a/src/packages/__VUE/calendarcard/icon.taro.ts b/src/packages/__VUE/calendarcard/icon.taro.ts index 31ab3301ce..8fba4d8eb3 100644 --- a/src/packages/__VUE/calendarcard/icon.taro.ts +++ b/src/packages/__VUE/calendarcard/icon.taro.ts @@ -1,16 +1,16 @@ import { h } from 'vue' -const left = - 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxOCIgaGVpZ2h0PSIxOCIgdmlld0JveD0iMCAwIDE4IDE4Ij48cGF0aCBkPSJNNi42MDUgOS40OWEuNzcxLjc3MSAwIDAgMSAwLS45OGwzLjYtNC4zNzJhLjc3MS43NzEgMCAwIDEgMS4xOS45ODFMOC4yIDlsMy4xOTcgMy44ODFhLjc3MS43NzEgMCAxIDEtMS4xOTEuOThsLTMuNi00LjM3eiIvPjwvc3ZnPg==' +const left + = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxOCIgaGVpZ2h0PSIxOCIgdmlld0JveD0iMCAwIDE4IDE4Ij48cGF0aCBkPSJNNi42MDUgOS40OWEuNzcxLjc3MSAwIDAgMSAwLS45OGwzLjYtNC4zNzJhLjc3MS43NzEgMCAwIDEgMS4xOS45ODFMOC4yIDlsMy4xOTcgMy44ODFhLjc3MS43NzEgMCAxIDEtMS4xOTEuOThsLTMuNi00LjM3eiIvPjwvc3ZnPg==' -const right = - 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxOCIgaGVpZ2h0PSIxOCIgdmlld0JveD0iMCAwIDE4IDE4Ij48cGF0aCBkPSJNMTEuMzk2IDkuNDlhLjc3MS43NzEgMCAwIDAgMC0uOThsLTMuNi00LjM3MmEuNzcxLjc3MSAwIDAgMC0xLjE5MS45ODFMOS44IDlsLTMuMTk2IDMuODgxYS43NzEuNzcxIDAgMCAwIDEuMTkuOThsMy42LTQuMzd6Ii8+PC9zdmc+' +const right + = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxOCIgaGVpZ2h0PSIxOCIgdmlld0JveD0iMCAwIDE4IDE4Ij48cGF0aCBkPSJNMTEuMzk2IDkuNDlhLjc3MS43NzEgMCAwIDAgMC0uOThsLTMuNi00LjM3MmEuNzcxLjc3MSAwIDAgMC0xLjE5MS45ODFMOS44IDlsLTMuMTk2IDMuODgxYS43NzEuNzcxIDAgMCAwIDEuMTkuOThsMy42LTQuMzd6Ii8+PC9zdmc+' -const doubleLeft = - 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxOCIgaGVpZ2h0PSIxOCIgdmlld0JveD0iMCAwIDE4IDE4Ij48cGF0aCBkPSJNMTMuODUzIDQuMDI2YS43NzEuNzcxIDAgMCAxIC4xMiAxLjA4NUwxMC44NjQgOWwzLjExIDMuODg5YS43NzEuNzcxIDAgMSAxLTEuMjA0Ljk2M2wtMy40OTgtNC4zN2EuNzcxLjc3MSAwIDAgMSAwLS45NjRsMy40OTctNC4zNzFhLjc3MS43NzEgMCAwIDEgMS4wODQtLjEyem0tNS4yNDUgMGEuNzcxLjc3MSAwIDAgMSAuMTIgMS4wODVMNS42MTcgOWwzLjExMSAzLjg4OWEuNzcxLjc3MSAwIDAgMS0xLjIwNS45NjNsLTMuNDk3LTQuMzdhLjc3MS43NzEgMCAwIDEgMC0uOTY0bDMuNDk3LTQuMzcxYS43NzEuNzcxIDAgMCAxIDEuMDg1LS4xMnoiLz48L3N2Zz4=' +const doubleLeft + = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxOCIgaGVpZ2h0PSIxOCIgdmlld0JveD0iMCAwIDE4IDE4Ij48cGF0aCBkPSJNMTMuODUzIDQuMDI2YS43NzEuNzcxIDAgMCAxIC4xMiAxLjA4NUwxMC44NjQgOWwzLjExIDMuODg5YS43NzEuNzcxIDAgMSAxLTEuMjA0Ljk2M2wtMy40OTgtNC4zN2EuNzcxLjc3MSAwIDAgMSAwLS45NjRsMy40OTctNC4zNzFhLjc3MS43NzEgMCAwIDEgMS4wODQtLjEyem0tNS4yNDUgMGEuNzcxLjc3MSAwIDAgMSAuMTIgMS4wODVMNS42MTcgOWwzLjExMSAzLjg4OWEuNzcxLjc3MSAwIDAgMS0xLjIwNS45NjNsLTMuNDk3LTQuMzdhLjc3MS43NzEgMCAwIDEgMC0uOTY0bDMuNDk3LTQuMzcxYS43NzEuNzcxIDAgMCAxIDEuMDg1LS4xMnoiLz48L3N2Zz4=' -const doubleRight = - 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxOCIgaGVpZ2h0PSIxOCIgdmlld0JveD0iMCAwIDE4IDE4Ij48cGF0aCBkPSJNNC4xNDcgMTMuOTc0YS43NzEuNzcxIDAgMCAxLS4xMi0xLjA4NUw3LjEzNiA5IDQuMDI4IDUuMTFhLjc3MS43NzEgMCAxIDEgMS4yMDQtLjk2M2wzLjQ5NyA0LjM3MWEuNzcxLjc3MSAwIDAgMSAwIC45NjRsLTMuNDk3IDQuMzcxYS43NzEuNzcxIDAgMCAxLTEuMDg0LjEyem01LjI0NSAwYS43NzEuNzcxIDAgMCAxLS4xMi0xLjA4NUwxMi4zODMgOSA5LjI3MiA1LjExYS43NzEuNzcxIDAgMSAxIDEuMjA1LS45NjNsMy40OTcgNC4zNzFhLjc3MS43NzEgMCAwIDEgMCAuOTY0bC0zLjQ5NyA0LjM3MWEuNzcxLjc3MSAwIDAgMS0xLjA4NS4xMnoiLz48L3N2Zz4=' +const doubleRight + = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxOCIgaGVpZ2h0PSIxOCIgdmlld0JveD0iMCAwIDE4IDE4Ij48cGF0aCBkPSJNNC4xNDcgMTMuOTc0YS43NzEuNzcxIDAgMCAxLS4xMi0xLjA4NUw3LjEzNiA5IDQuMDI4IDUuMTFhLjc3MS43NzEgMCAxIDEgMS4yMDQtLjk2M2wzLjQ5NyA0LjM3MWEuNzcxLjc3MSAwIDAgMSAwIC45NjRsLTMuNDk3IDQuMzcxYS43NzEuNzcxIDAgMCAxLTEuMDg0LjEyem01LjI0NSAwYS43NzEuNzcxIDAgMCAxLS4xMi0xLjA4NUwxMi4zODMgOSA5LjI3MiA1LjExYS43NzEuNzcxIDAgMSAxIDEuMjA1LS45NjNsMy40OTcgNC4zNzFhLjc3MS43NzEgMCAwIDEgMCAuOTY0bC0zLjQ5NyA0LjM3MWEuNzcxLjc3MSAwIDAgMS0xLjA4NS4xMnoiLz48L3N2Zz4=' const Icon = (url: string) => { const style = { diff --git a/src/packages/__VUE/calendaritem/index.taro.vue b/src/packages/__VUE/calendaritem/index.taro.vue index ff09963f5e..195121d1ae 100644 --- a/src/packages/__VUE/calendaritem/index.taro.vue +++ b/src/packages/__VUE/calendaritem/index.taro.vue @@ -19,8 +19,9 @@ :key="index" class="nut-calendar__weekday" :class="{ weekend: item.weekend }" - >{{ item.day }} + {{ item.day }} + @@ -62,9 +63,11 @@ > {{ startText || translate('start') }} - {{ - endText || translate('end') - }} + + {{ + endText || translate('end') + }} + @@ -259,8 +262,8 @@ export default create({ const getClass = (day: Day, month: MonthInfo, index?: number) => { const res = [] if ( - typeof index === 'number' && - ((index + 1 + props.firstDayOfWeek) % 7 === 0 || (index + props.firstDayOfWeek) % 7 === 0) + typeof index === 'number' + && ((index + 1 + props.firstDayOfWeek) % 7 === 0 || (index + props.firstDayOfWeek) % 7 === 0) ) { res.push('weekend') } @@ -268,23 +271,23 @@ export default create({ const { type } = props if (day.type == 'curr') { if ( - Utils.isEqual(state.currDate as string, currDate) || - ((type == 'range' || type == 'week') && (isStart(currDate) || isEnd(currDate))) || - (type == 'multiple' && isMultiple(currDate)) + Utils.isEqual(state.currDate as string, currDate) + || ((type == 'range' || type == 'week') && (isStart(currDate) || isEnd(currDate))) + || (type == 'multiple' && isMultiple(currDate)) ) { res.push(`${state.dayPrefix}--active`) } else if ( - (state.propStartDate && Utils.compareDate(currDate, state.propStartDate)) || - (state.propEndDate && Utils.compareDate(state.propEndDate, currDate)) || - (props.disabledDate && props.disabledDate(currDate)) + (state.propStartDate && Utils.compareDate(currDate, state.propStartDate)) + || (state.propEndDate && Utils.compareDate(state.propEndDate, currDate)) + || (props.disabledDate && props.disabledDate(currDate)) ) { res.push(`${state.dayPrefix}--disabled`) } else if ( - (type == 'range' || type == 'week') && - Array.isArray(state.currDate) && - Object.values(state.currDate).length == 2 && - Utils.compareDate(state.currDate[0], currDate) && - Utils.compareDate(currDate, state.currDate[1]) + (type == 'range' || type == 'week') + && Array.isArray(state.currDate) + && Object.values(state.currDate).length == 2 + && Utils.compareDate(state.currDate[0], currDate) + && Utils.compareDate(currDate, state.currDate[1]) ) { res.push(`${state.dayPrefix}--choose`) } @@ -331,10 +334,10 @@ export default create({ state.chooseData.push([...days]) } else { if (hasIndex !== undefined) { - ;(state.currDate as StringArr).splice(hasIndex, 1) + (state.currDate as StringArr).splice(hasIndex, 1) state.chooseData.splice(hasIndex, 1) } else { - ;(state.currDate as StringArr).push(days[3]) + (state.currDate as StringArr).push(days[3]) state.chooseData.push([...days]) } } @@ -469,7 +472,7 @@ export default create({ preMonth = 12 preYear += 1 } - //当月天数与上个月天数 + // 当月天数与上个月天数 const currMonthDays = Utils.getMonthDays(String(curData[0]), String(curData[1])) const preCurrMonthDays = Utils.getMonthDays(preYear + '', preMonth + '') @@ -505,16 +508,16 @@ export default create({ let cssScrollHeight = 0 if (state.monthsData.length > 0) { - cssScrollHeight = - (state.monthsData[state.monthsData.length - 1] as MonthInfo).cssScrollHeight + - (state.monthsData[state.monthsData.length - 1] as MonthInfo).cssHeight + cssScrollHeight + = (state.monthsData[state.monthsData.length - 1] as MonthInfo).cssScrollHeight + + (state.monthsData[state.monthsData.length - 1] as MonthInfo).cssHeight } monthInfo.cssScrollHeight = cssScrollHeight if (type == 'next') { // 判断当前日期 是否大于 最后一天 if ( - !state.endData || - !Utils.compareDate( + !state.endData + || !Utils.compareDate( `${state.endData[0]}-${state.endData[1]}-${Utils.getMonthDays(state.endData[0], state.endData[1])}`, `${curData[0]}-${curData[1]}-${curData[2]}` ) @@ -524,8 +527,8 @@ export default create({ } else { // 判断当前日期 是否小于 第一天 if ( - !state.startData || - !Utils.compareDate( + !state.startData + || !Utils.compareDate( `${curData[0]}-${curData[1]}-${curData[2]}`, `${state.startData[0]}-${state.startData[1]}-01` ) @@ -549,8 +552,8 @@ export default create({ // 根据是否存在默认时间,初始化当前日期, if (props.defaultValue || (Array.isArray(props.defaultValue) && props.defaultValue.length > 0)) { - state.currDate = - props.type !== 'one' ? ([...props.defaultValue] as StringArr) : (props.defaultValue as string | StringArr) + state.currDate + = props.type !== 'one' ? ([...props.defaultValue] as StringArr) : (props.defaultValue as string | StringArr) } // 判断时间范围内存在多少个月 @@ -595,10 +598,10 @@ export default create({ let obj: any = {} state.currDate.forEach((item: string) => { if ( - propStartDate && - !Utils.compareDate(item, propStartDate) && - propEndDate && - !Utils.compareDate(propEndDate, item) + propStartDate + && !Utils.compareDate(item, propStartDate) + && propEndDate + && !Utils.compareDate(propEndDate, item) ) { if (!Object.hasOwnProperty.call(obj, item)) { defaultArr.push(item) @@ -658,7 +661,7 @@ export default create({ } else if (props.type == 'week') { chooseDay({ day: state.defaultData[2], type: 'curr' }, state.monthsData[state.currentIndex], true) } else if (props.type == 'multiple') { - ;[...state.currDate].forEach((item: string) => { + [...state.currDate].forEach((item: string) => { let dateArr = splitDate(item) let current = state.currentIndex state.monthsData.forEach((item, index) => { @@ -733,9 +736,9 @@ export default create({ // 区间选择&&当前月&&选中态 const isActive = (day: Day, month: MonthInfo) => { return ( - (props.type == 'range' || props.type == 'week') && - day.type == 'curr' && - getClass(day, month).includes('nut-calendar__day--active') + (props.type == 'range' || props.type == 'week') + && day.type == 'curr' + && getClass(day, month).includes('nut-calendar__day--active') ) } @@ -814,7 +817,7 @@ export default create({ }) }) - //监听 默认值更改 + // 监听 默认值更改 watch( () => props.defaultValue, (val) => { diff --git a/src/packages/__VUE/calendaritem/index.vue b/src/packages/__VUE/calendaritem/index.vue index 95eb05b66d..368cab13c5 100644 --- a/src/packages/__VUE/calendaritem/index.vue +++ b/src/packages/__VUE/calendaritem/index.vue @@ -19,8 +19,9 @@ :key="index" class="nut-calendar__weekday" :class="{ weekend: item.weekend }" - >{{ item.day }} + {{ item.day }} + @@ -55,9 +56,11 @@ > {{ startText || translate('start') }} - {{ - endText || translate('end') - }} + + {{ + endText || translate('end') + }} + @@ -245,8 +248,8 @@ export default create({ const getClass = (day: Day, month: MonthInfo, index?: number) => { const res = [] if ( - typeof index === 'number' && - ((index + 1 + props.firstDayOfWeek) % 7 === 0 || (index + props.firstDayOfWeek) % 7 === 0) + typeof index === 'number' + && ((index + 1 + props.firstDayOfWeek) % 7 === 0 || (index + props.firstDayOfWeek) % 7 === 0) ) { res.push('weekend') } @@ -254,23 +257,23 @@ export default create({ const { type } = props if (day.type == 'curr') { if ( - Utils.isEqual(state.currDate as string, currDate) || - ((type == 'range' || type == 'week') && (isStart(currDate) || isEnd(currDate))) || - (type == 'multiple' && isMultiple(currDate)) + Utils.isEqual(state.currDate as string, currDate) + || ((type == 'range' || type == 'week') && (isStart(currDate) || isEnd(currDate))) + || (type == 'multiple' && isMultiple(currDate)) ) { res.push(`${state.dayPrefix}--active`) } else if ( - (state.propStartDate && Utils.compareDate(currDate, state.propStartDate)) || - (state.propEndDate && Utils.compareDate(state.propEndDate, currDate)) || - (props.disabledDate && props.disabledDate(currDate)) + (state.propStartDate && Utils.compareDate(currDate, state.propStartDate)) + || (state.propEndDate && Utils.compareDate(state.propEndDate, currDate)) + || (props.disabledDate && props.disabledDate(currDate)) ) { res.push(`${state.dayPrefix}--disabled`) } else if ( - (type == 'range' || type == 'week') && - Array.isArray(state.currDate) && - Object.values(state.currDate).length == 2 && - Utils.compareDate(state.currDate[0], currDate) && - Utils.compareDate(currDate, state.currDate[1]) + (type == 'range' || type == 'week') + && Array.isArray(state.currDate) + && Object.values(state.currDate).length == 2 + && Utils.compareDate(state.currDate[0], currDate) + && Utils.compareDate(currDate, state.currDate[1]) ) { res.push(`${state.dayPrefix}--choose`) } @@ -320,10 +323,10 @@ export default create({ state.chooseData.push([...days]) } else { if (hasIndex !== undefined) { - ;(state.currDate as StringArr).splice(hasIndex, 1) + (state.currDate as StringArr).splice(hasIndex, 1) state.chooseData.splice(hasIndex, 1) } else { - ;(state.currDate as StringArr).push(days[3]) + (state.currDate as StringArr).push(days[3]) state.chooseData.push([...days]) } } @@ -458,7 +461,7 @@ export default create({ preMonth = 12 preYear += 1 } - //当月天数与上个月天数 + // 当月天数与上个月天数 const currMonthDays = Utils.getMonthDays(String(curData[0]), String(curData[1])) const preCurrMonthDays = Utils.getMonthDays(preYear + '', preMonth + '') @@ -485,16 +488,16 @@ export default create({ let cssScrollHeight = 0 if (state.monthsData.length > 0) { - cssScrollHeight = - (state.monthsData[state.monthsData.length - 1] as MonthInfo).cssScrollHeight + - (state.monthsData[state.monthsData.length - 1] as MonthInfo).cssHeight + cssScrollHeight + = (state.monthsData[state.monthsData.length - 1] as MonthInfo).cssScrollHeight + + (state.monthsData[state.monthsData.length - 1] as MonthInfo).cssHeight } monthInfo.cssScrollHeight = cssScrollHeight if (type == 'next') { // 判断当前日期 是否大于 最后一天 if ( - !state.endData || - !Utils.compareDate( + !state.endData + || !Utils.compareDate( `${state.endData[0]}-${state.endData[1]}-${Utils.getMonthDays(state.endData[0], state.endData[1])}`, `${curData[0]}-${curData[1]}-${curData[2]}` ) @@ -504,8 +507,8 @@ export default create({ } else { // 判断当前日期 是否小于 第一天 if ( - !state.startData || - !Utils.compareDate( + !state.startData + || !Utils.compareDate( `${curData[0]}-${curData[1]}-${curData[2]}`, `${state.startData[0]}-${state.startData[1]}-01` ) @@ -529,8 +532,8 @@ export default create({ // 根据是否存在默认时间,初始化当前日期, if (props.defaultValue || (Array.isArray(props.defaultValue) && props.defaultValue.length > 0)) { - state.currDate = - props.type !== 'one' ? ([...props.defaultValue] as StringArr) : (props.defaultValue as string | StringArr) + state.currDate + = props.type !== 'one' ? ([...props.defaultValue] as StringArr) : (props.defaultValue as string | StringArr) } // 判断时间范围内存在多少个月 @@ -575,10 +578,10 @@ export default create({ let obj: Record = {} state.currDate.forEach((item: string) => { if ( - propStartDate && - !Utils.compareDate(item, propStartDate) && - propEndDate && - !Utils.compareDate(propEndDate, item) + propStartDate + && !Utils.compareDate(item, propStartDate) + && propEndDate + && !Utils.compareDate(propEndDate, item) ) { if (!Object.hasOwnProperty.call(obj, item)) { defaultArr.push(item) @@ -638,7 +641,7 @@ export default create({ } else if (props.type == 'week') { chooseDay({ day: state.defaultData[2], type: 'curr' }, state.monthsData[state.currentIndex], true) } else if (props.type == 'multiple') { - ;[...state.currDate].forEach((item: string) => { + [...state.currDate].forEach((item: string) => { let dateArr = splitDate(item) let current = state.currentIndex state.monthsData.forEach((item, index) => { @@ -727,9 +730,9 @@ export default create({ // 区间选择&&当前月&&选中态 const isActive = (day: Day, month: MonthInfo) => { return ( - (props.type == 'range' || props.type == 'week') && - day.type == 'curr' && - getClass(day, month).includes('nut-calendar__day--active') + (props.type == 'range' || props.type == 'week') + && day.type == 'curr' + && getClass(day, month).includes('nut-calendar__day--active') ) } @@ -777,14 +780,14 @@ export default create({ } else { const viewPosition = Math.round(currentScrollTop + viewHeight.value) if ( - viewPosition < state.monthsData[current].cssScrollHeight + state.monthsData[current].cssHeight && - currentScrollTop > state.monthsData[current - 1].cssScrollHeight + viewPosition < state.monthsData[current].cssScrollHeight + state.monthsData[current].cssHeight + && currentScrollTop > state.monthsData[current - 1].cssScrollHeight ) { current -= 1 } if ( - current + 1 <= state.monthsNum && - viewPosition >= state.monthsData[current + 1].cssScrollHeight + state.monthsData[current + 1].cssHeight + current + 1 <= state.monthsNum + && viewPosition >= state.monthsData[current + 1].cssScrollHeight + state.monthsData[current + 1].cssHeight ) { current += 1 } @@ -812,7 +815,7 @@ export default create({ initData() }) - //监听 默认值更改 + // 监听 默认值更改 watch( () => props.defaultValue, (val) => { diff --git a/src/packages/__VUE/cascader/__tests__/cascader.spec.ts b/src/packages/__VUE/cascader/__tests__/cascader.spec.ts index cfc5c4696f..f5ddad25db 100644 --- a/src/packages/__VUE/cascader/__tests__/cascader.spec.ts +++ b/src/packages/__VUE/cascader/__tests__/cascader.spec.ts @@ -14,7 +14,7 @@ const mountCascader = (options = {}) => }, ...options }) -const later = (t = 0) => new Promise((r) => setTimeout(r, t)) +const later = (t = 0) => new Promise(r => setTimeout(r, t)) const mockOptions = [ { value: '浙江', diff --git a/src/packages/__VUE/cascader/cascader-item.taro.vue b/src/packages/__VUE/cascader/cascader-item.taro.vue index 42b7f7b568..538445c465 100644 --- a/src/packages/__VUE/cascader/cascader-item.taro.vue +++ b/src/packages/__VUE/cascader/cascader-item.taro.vue @@ -145,7 +145,7 @@ export default create({ if (isLazy.value && Array.isArray(currentValue) && currentValue.length) { needToSync = [] - let parent = tree.value.nodes.find((node) => node.value === currentValue[0]) + let parent = tree.value.nodes.find(node => node.value === currentValue[0]) if (parent) { needToSync = [parent.value] @@ -155,7 +155,7 @@ export default create({ const parent = await p await invokeLazyLoad(parent) - const node = parent?.children?.find((item) => item.value === value) + const node = parent?.children?.find(item => item.value === value) if (node) { needToSync.push(value) @@ -220,7 +220,7 @@ export default create({ } const emitChange = (pathNodes: CascaderOption[]) => { - const emitValue = pathNodes.map((node) => node.value) + const emitValue = pathNodes.map(node => node.value) innerValue.value = emitValue emit('change', emitValue, pathNodes) @@ -242,7 +242,7 @@ export default create({ panes.value = panes.value.slice(0, (node.level as number) + 1) if (!silent) { - const pathNodes = panes.value.map((pane) => pane.selectedNode) + const pathNodes = panes.value.map(pane => pane.selectedNode) emitChange(pathNodes as CascaderOption[]) emit('pathChange', pathNodes) @@ -263,7 +263,7 @@ export default create({ tabsCursor.value = level if (!silent) { - const pathNodes = panes.value.map((pane) => pane.selectedNode) + const pathNodes = panes.value.map(pane => pane.selectedNode) emit('pathChange', pathNodes) } return diff --git a/src/packages/__VUE/cascader/cascader-item.vue b/src/packages/__VUE/cascader/cascader-item.vue index 1dee0a8bbf..f087e3ea47 100644 --- a/src/packages/__VUE/cascader/cascader-item.vue +++ b/src/packages/__VUE/cascader/cascader-item.vue @@ -141,7 +141,7 @@ export default create({ if (isLazy.value && Array.isArray(currentValue) && currentValue.length) { needToSync = [] - let parent = tree.value.nodes.find((node) => node.value === currentValue[0]) + let parent = tree.value.nodes.find(node => node.value === currentValue[0]) if (parent) { needToSync = [parent.value] @@ -151,7 +151,7 @@ export default create({ const parent = await p await invokeLazyLoad(parent) - const node = parent?.children?.find((item) => item.value === value) + const node = parent?.children?.find(item => item.value === value) if (node) { needToSync.push(value) @@ -216,7 +216,7 @@ export default create({ } const emitChange = (pathNodes: CascaderOption[]) => { - const emitValue = pathNodes.map((node) => node.value) + const emitValue = pathNodes.map(node => node.value) innerValue.value = emitValue emit('change', emitValue, pathNodes) @@ -238,7 +238,7 @@ export default create({ panes.value = panes.value.slice(0, (node.level as number) + 1) if (!silent) { - const pathNodes = panes.value.map((pane) => pane.selectedNode) + const pathNodes = panes.value.map(pane => pane.selectedNode) emitChange(pathNodes as CascaderOption[]) emit('pathChange', pathNodes) @@ -259,7 +259,7 @@ export default create({ tabsCursor.value = level if (!silent) { - const pathNodes = panes.value.map((pane) => pane.selectedNode) + const pathNodes = panes.value.map(pane => pane.selectedNode) emit('pathChange', pathNodes) } return diff --git a/src/packages/__VUE/cascader/tree.ts b/src/packages/__VUE/cascader/tree.ts index d7d54d6092..9fb5658452 100644 --- a/src/packages/__VUE/cascader/tree.ts +++ b/src/packages/__VUE/cascader/tree.ts @@ -45,7 +45,7 @@ class Tree { let currentNodes: CascaderOption[] | void = this.nodes while (currentNodes && currentNodes.length) { - const foundNode: CascaderOption | void = currentNodes.find((node) => node.value === value[node.level as number]) + const foundNode: CascaderOption | void = currentNodes.find(node => node.value === value[node.level as number]) if (!foundNode) { break diff --git a/src/packages/__VUE/category/demo.vue b/src/packages/__VUE/category/demo.vue index 85654726cb..d2a85f5bc2 100644 --- a/src/packages/__VUE/category/demo.vue +++ b/src/packages/__VUE/category/demo.vue @@ -6,14 +6,13 @@

{{ translate('title2') }}

- + +

{{ translate('title3') }}

- - + + + @@ -49,7 +48,7 @@ onMounted(() => { const getData = () => { fetch('//storage.360buyimg.com/nutui/3x/categoryData.js') - .then((response) => response.json()) + .then(response => response.json()) .then((res) => { const { categoryInfo, categoryChild, customCategory } = res data.categoryInfo1 = categoryInfo @@ -59,7 +58,7 @@ const getData = () => { data.categoryInfo2 = categoryInfo data.categoryChild2 = categoryChild }) - .catch((err) => console.log('Oh, error', err)) + .catch(err => console.log('Oh, error', err)) } const change = (index: any) => { diff --git a/src/packages/__VUE/category/index.taro.vue b/src/packages/__VUE/category/index.taro.vue index 25460d27d0..fa30bd7494 100644 --- a/src/packages/__VUE/category/index.taro.vue +++ b/src/packages/__VUE/category/index.taro.vue @@ -28,13 +28,13 @@ export type CategoryType = { export default create({ props: { - //分类模式 + // 分类模式 type: { type: String, default: 'classify' }, - //左侧导航栏 + // 左侧导航栏 category: { type: Array as PropType, default: () => [] @@ -43,7 +43,7 @@ export default create({ setup(props, { emit }) { const checkIndex = ref(0) - const categoryLeft = ref(false) //是否显示slot + const categoryLeft = ref(false) // 是否显示slot const getChildList = (index: any) => { checkIndex.value = index diff --git a/src/packages/__VUE/category/index.vue b/src/packages/__VUE/category/index.vue index e12f2e3325..be288e468b 100644 --- a/src/packages/__VUE/category/index.vue +++ b/src/packages/__VUE/category/index.vue @@ -28,12 +28,12 @@ export type CategoryType = { export default create({ props: { - //分类模式 + // 分类模式 type: { type: String, default: 'classify' }, - //左侧导航栏 + // 左侧导航栏 category: { type: Array as PropType, default: [] @@ -42,7 +42,7 @@ export default create({ setup(props, { emit }) { const checkIndex = ref(0) - const categoryLeft = ref(false) //是否显示slot + const categoryLeft = ref(false) // 是否显示slot const getChildList = (index: any) => { checkIndex.value = index diff --git a/src/packages/__VUE/categorypane/index.taro.vue b/src/packages/__VUE/categorypane/index.taro.vue index 529696abdd..7c1e8c76c0 100644 --- a/src/packages/__VUE/categorypane/index.taro.vue +++ b/src/packages/__VUE/categorypane/index.taro.vue @@ -62,19 +62,19 @@ export type CustomType = { export default create({ props: { - //分类模式 + // 分类模式 type: { type: String, default: 'classify' }, - //右侧导航数据 + // 右侧导航数据 categoryChild: { type: Array as PropType, default: () => [] }, - //模式传入自定义数据 + // 模式传入自定义数据 customCategory: { type: Array as PropType, default: () => [] diff --git a/src/packages/__VUE/categorypane/index.vue b/src/packages/__VUE/categorypane/index.vue index b06a863b30..55c5ce2009 100644 --- a/src/packages/__VUE/categorypane/index.vue +++ b/src/packages/__VUE/categorypane/index.vue @@ -62,19 +62,19 @@ export type CustomType = { export default create({ props: { - //分类模式 + // 分类模式 type: { type: String, default: 'classify' }, - //右侧导航数据 + // 右侧导航数据 categoryChild: { type: Array as PropType, default: () => [] }, - //模式传入自定义数据 + // 模式传入自定义数据 customCategory: { type: Array as PropType, default: () => [] diff --git a/src/packages/__VUE/checkbox/demo/methods.vue b/src/packages/__VUE/checkbox/demo/methods.vue index 26143dce92..0de0ea14f4 100644 --- a/src/packages/__VUE/checkbox/demo/methods.vue +++ b/src/packages/__VUE/checkbox/demo/methods.vue @@ -1,9 +1,11 @@ @@ -62,7 +65,7 @@ export default create({ if (props.operation) { props.operation.forEach((name: string) => { if (deOp.includes(name)) { - ;(mergeOp.value as any).push(name) + (mergeOp.value as any).push(name) } }) } diff --git a/src/packages/__VUE/comment/components/CmtBottom.vue b/src/packages/__VUE/comment/components/CmtBottom.vue index d17f12614e..e7b5d81a19 100644 --- a/src/packages/__VUE/comment/components/CmtBottom.vue +++ b/src/packages/__VUE/comment/components/CmtBottom.vue @@ -1,7 +1,8 @@ @@ -62,7 +65,7 @@ export default create({ if (props.operation) { props.operation.forEach((name: string) => { if (deOp.includes(name)) { - ;(mergeOp.value as any).push(name) + (mergeOp.value as any).push(name) } }) } diff --git a/src/packages/__VUE/comment/demo.vue b/src/packages/__VUE/comment/demo.vue index 134fdbf9ea..71034d38ab 100644 --- a/src/packages/__VUE/comment/demo.vue +++ b/src/packages/__VUE/comment/demo.vue @@ -89,13 +89,13 @@ onMounted(() => { const getData = () => { fetch('//storage.360buyimg.com/nutui/3x/comment_data.json') - .then((response) => response.json()) + .then(response => response.json()) .then((res) => { - res.Comment.info.avatar = - 'https://img14.360buyimg.com/imagetools/jfs/t1/167902/2/8762/791358/603742d7E9b4275e3/e09d8f9a8bf4c0ef.png' + res.Comment.info.avatar + = 'https://img14.360buyimg.com/imagetools/jfs/t1/167902/2/8762/791358/603742d7E9b4275e3/e09d8f9a8bf4c0ef.png' cmt.value = res.Comment - }) //执行结果是 resolve就调用then方法 - .catch((err) => console.log('Oh, error', err)) //执行结果是 reject就调用catch方法 + }) // 执行结果是 resolve就调用then方法 + .catch(err => console.log('Oh, error', err)) // 执行结果是 reject就调用catch方法 } const clickImages = (imgs: any) => { diff --git a/src/packages/__VUE/comment/index.taro.vue b/src/packages/__VUE/comment/index.taro.vue index 6b89f69223..e39b30f7d0 100644 --- a/src/packages/__VUE/comment/index.taro.vue +++ b/src/packages/__VUE/comment/index.taro.vue @@ -25,8 +25,10 @@ v-if="follow.images && follow.images.length > 0" class="nut-comment__follow-img" @click="clickImages(follow.images)" - >{{ translate('additionalImages', follow.images.length) }} + > + {{ translate('additionalImages', follow.images.length) }} +