From 3dcc92a5c0e75867a950bbe71bff8c3bc4259f83 Mon Sep 17 00:00:00 2001 From: neverland Date: Sat, 22 Jul 2023 14:14:14 +0800 Subject: [PATCH] chore: bump prettier v3 and format all code (#12111) * chore: bump prettier v3 and format all code * chore: mjs config * chore: revert * chore: revert * chore: update lock --- .prettierrc | 4 --- package.json | 2 +- packages/create-vant-cli-app/src/generator.ts | 8 ++--- packages/vant-area-data/src/index.ts | 2 +- packages/vant-cli/cjs/jest.transformer.cjs | 4 +-- packages/vant-cli/cjs/postcss.config.cjs | 12 +++---- packages/vant-cli/package.json | 2 +- packages/vant-cli/site/common/iframe-sync.js | 6 ++-- packages/vant-cli/site/common/style/base.less | 17 ++++++++-- packages/vant-cli/site/desktop/App.vue | 4 +-- .../desktop/components/DemoPlayground.vue | 4 ++- .../site/desktop/components/Header.vue | 2 +- packages/vant-cli/site/index.html | 7 ++-- packages/vant-cli/site/mobile.html | 10 ++---- packages/vant-cli/site/mobile/App.vue | 6 ++-- packages/vant-cli/src/cli.ts | 12 +++---- packages/vant-cli/src/commands/build.ts | 4 +-- packages/vant-cli/src/commands/changelog.ts | 2 +- packages/vant-cli/src/commands/lint.ts | 4 +-- packages/vant-cli/src/common/css.ts | 2 +- packages/vant-cli/src/common/index.ts | 8 ++--- .../vant-cli/src/compiler/compile-bundles.ts | 8 ++--- .../vant-cli/src/compiler/compile-script.ts | 2 +- packages/vant-cli/src/compiler/compile-sfc.ts | 4 +-- .../vant-cli/src/compiler/compile-site.ts | 4 +-- .../src/compiler/gen-component-style.ts | 2 +- .../src/compiler/gen-package-entry.ts | 4 +-- .../src/compiler/gen-site-mobile-shared.ts | 2 +- .../src/compiler/gen-style-deps-map.ts | 4 +-- packages/vant-cli/src/compiler/get-deps.ts | 5 ++- .../src/compiler/web-types/formatter.ts | 2 +- .../vant-cli/src/compiler/web-types/index.ts | 2 +- .../vant-cli/src/compiler/web-types/utils.ts | 2 +- .../vant-cli/template/changelog-commit.hbs | 1 - packages/vant-icons/src/encode-woff2.less | 3 +- packages/vant-icons/src/index.less | 3 +- packages/vant-touch-emulator/src/index.js | 4 +-- packages/vant-use/src/useClickAway/index.ts | 2 +- .../vant-use/src/useEventListener/index.ts | 6 ++-- packages/vant-use/src/useRect/index.ts | 4 +-- .../vant-use/src/useRelation/useChildren.ts | 12 +++---- .../vant-use/src/useScrollParent/index.ts | 4 +-- .../docs/markdown/use-click-away.en-US.md | 4 +-- .../docs/markdown/use-click-away.zh-CN.md | 4 +-- .../docs/markdown/use-event-listener.en-US.md | 4 +-- .../docs/markdown/use-event-listener.zh-CN.md | 4 +-- packages/vant/docs/markdown/use-rect.en-US.md | 2 +- packages/vant/docs/markdown/use-rect.zh-CN.md | 2 +- .../docs/markdown/use-scroll-parent.en-US.md | 4 +-- .../docs/markdown/use-scroll-parent.zh-CN.md | 4 +-- .../vant/docs/markdown/use-toggle.en-US.md | 2 +- .../vant/docs/markdown/use-toggle.zh-CN.md | 2 +- .../vant/src/action-sheet/test/index.spec.ts | 8 ++--- .../vant/src/address-edit/AddressEdit.tsx | 8 ++--- .../vant/src/address-list/AddressList.tsx | 2 +- packages/vant/src/area/Area.tsx | 4 +-- packages/vant/src/area/test/index.spec.ts | 6 ++-- packages/vant/src/area/utils.ts | 6 ++-- packages/vant/src/back-top/BackTop.tsx | 4 +-- packages/vant/src/back-top/README.zh-CN.md | 6 ++-- packages/vant/src/badge/Badge.tsx | 2 +- packages/vant/src/barrage/Barrage.tsx | 12 +++---- packages/vant/src/barrage/index.less | 5 ++- packages/vant/src/barrage/test/index.spec.tsx | 10 +++--- packages/vant/src/calendar/Calendar.tsx | 24 ++++++------- packages/vant/src/calendar/CalendarMonth.tsx | 8 ++--- packages/vant/src/calendar/test/index.spec.ts | 14 ++++---- packages/vant/src/calendar/test/prop.spec.ts | 6 ++-- packages/vant/src/cascader/Cascader.tsx | 16 ++++----- packages/vant/src/cascader/demo/index.vue | 2 +- .../vant/src/checkbox-group/CheckboxGroup.tsx | 2 +- packages/vant/src/checkbox/Checkbox.tsx | 2 +- packages/vant/src/circle/Circle.tsx | 4 +-- .../vant/src/collapse-item/CollapseItem.tsx | 4 +-- packages/vant/src/collapse/Collapse.tsx | 8 ++--- .../vant/src/collapse/test/index.spec.tsx | 2 +- packages/vant/src/composables/use-height.ts | 2 +- .../vant/src/composables/use-lazy-render.ts | 4 +-- .../vant/src/composables/use-lock-scroll.ts | 4 +-- .../vant/src/composables/use-sync-prop-ref.ts | 2 +- .../src/composables/use-visibility-change.ts | 4 +-- .../src/config-provider/ConfigProvider.tsx | 8 ++--- .../src/config-provider/test/index.spec.tsx | 4 +-- .../vant/src/contact-edit/ContactEdit.tsx | 2 +- .../vant/src/contact-edit/test/index.spec.ts | 4 +-- .../vant/src/contact-list/ContactList.tsx | 2 +- .../vant/src/contact-list/README.zh-CN.md | 12 +++---- packages/vant/src/coupon-list/CouponList.tsx | 4 +-- packages/vant/src/coupon/utils.ts | 2 +- packages/vant/src/date-picker/DatePicker.tsx | 12 +++---- .../vant/src/date-picker/test/index.spec.ts | 20 +++++++---- packages/vant/src/date-picker/utils.ts | 4 +-- packages/vant/src/dialog/Dialog.tsx | 2 +- packages/vant/src/dialog/README.zh-CN.md | 2 +- packages/vant/src/dialog/function-call.tsx | 2 +- packages/vant/src/dialog/index.less | 2 +- packages/vant/src/dialog/test/index.spec.js | 4 +-- .../vant/src/dropdown-item/DropdownItem.tsx | 6 ++-- packages/vant/src/dropdown-item/types.ts | 2 +- .../vant/src/dropdown-menu/DropdownMenu.tsx | 2 +- .../src/dropdown-menu/test/index.spec.tsx | 6 ++-- packages/vant/src/field/Field.tsx | 8 ++--- packages/vant/src/field/test/index.spec.js | 6 ++-- packages/vant/src/field/types.ts | 4 +-- packages/vant/src/field/utils.ts | 2 +- .../src/floating-bubble/FloatingBubble.tsx | 6 ++-- .../vant/src/floating-bubble/README.zh-CN.md | 2 +- .../src/floating-bubble/test/index.spec.ts | 34 +++++++++---------- .../vant/src/floating-panel/FloatingPanel.tsx | 6 ++-- .../src/floating-panel/test/index.spec.tsx | 18 +++++----- packages/vant/src/form/Form.tsx | 4 +-- packages/vant/src/form/test/props.spec.tsx | 2 +- packages/vant/src/form/types.ts | 2 +- packages/vant/src/grid/test/index.spec.jsx | 2 +- packages/vant/src/icon/Icon.tsx | 2 +- .../vant/src/image-preview/ImagePreview.tsx | 4 +-- .../src/image-preview/ImagePreviewItem.tsx | 6 ++-- .../vant/src/image-preview/README.zh-CN.md | 2 +- .../vant/src/image-preview/function-call.tsx | 2 +- .../vant/src/image-preview/test/index.spec.ts | 4 +-- .../vant/src/image-preview/test/shared.ts | 4 +-- packages/vant/src/image/Image.tsx | 2 +- packages/vant/src/image/test/index.spec.ts | 2 +- .../vant/src/index-anchor/IndexAnchor.tsx | 4 +-- packages/vant/src/index-bar/IndexBar.tsx | 6 ++-- .../lazyload/vue-lazyload/lazy-component.js | 2 +- .../lazyload/vue-lazyload/lazy-container.js | 2 +- .../src/lazyload/vue-lazyload/lazy-image.js | 6 ++-- .../vant/src/lazyload/vue-lazyload/lazy.js | 6 ++-- .../src/lazyload/vue-lazyload/listener.js | 8 ++--- .../vant/src/lazyload/vue-lazyload/util.js | 2 +- packages/vant/src/loading/Loading.tsx | 2 +- packages/vant/src/nav-bar/test/index.spec.ts | 4 +-- .../vant/src/notice-bar/test/index.spec.tsx | 8 ++--- .../src/number-keyboard/NumberKeyboard.tsx | 8 ++--- packages/vant/src/overlay/Overlay.tsx | 2 +- packages/vant/src/pagination/Pagination.tsx | 2 +- .../vant/src/password-input/PasswordInput.tsx | 2 +- .../vant/src/password-input/demo/index.vue | 2 +- .../src/password-input/test/index.spec.ts | 2 +- .../vant/src/picker-group/PickerGroup.tsx | 6 ++-- packages/vant/src/picker-group/README.md | 6 ++-- .../vant/src/picker-group/README.zh-CN.md | 6 ++-- .../src/picker-group/demo/SelectDateRange.vue | 4 +-- packages/vant/src/picker/Picker.tsx | 29 ++++++++-------- packages/vant/src/picker/PickerColumn.tsx | 4 +-- packages/vant/src/picker/PickerToolbar.tsx | 2 +- packages/vant/src/picker/test/index.spec.tsx | 16 +++++---- packages/vant/src/picker/utils.ts | 16 ++++----- packages/vant/src/popover/Popover.tsx | 4 +-- packages/vant/src/popover/index.less | 4 ++- packages/vant/src/popover/test/index.spec.tsx | 2 +- packages/vant/src/popup/Popup.tsx | 2 +- packages/vant/src/popup/shared.ts | 2 +- packages/vant/src/popup/test/index.spec.jsx | 2 +- packages/vant/src/progress/Progress.tsx | 2 +- .../vant/src/pull-refresh/PullRefresh.tsx | 4 +-- packages/vant/src/radio-group/RadioGroup.tsx | 2 +- packages/vant/src/rate/Rate.tsx | 10 +++--- packages/vant/src/rate/test/index.spec.ts | 2 +- .../vant/src/rolling-text/RollingText.tsx | 6 ++-- .../vant/src/rolling-text/RollingTextItem.tsx | 2 +- .../vant/src/rolling-text/test/index.spec.ts | 6 ++-- packages/vant/src/search/test/index.spec.ts | 2 +- packages/vant/src/share-sheet/ShareSheet.tsx | 2 +- .../vant/src/share-sheet/test/index.spec.ts | 4 +-- .../vant/src/sidebar-item/SidebarItem.tsx | 2 +- .../vant/src/signature/test/index.spec.ts | 4 +-- packages/vant/src/slider/test/index.spec.ts | 4 +-- packages/vant/src/space/Space.tsx | 8 ++--- packages/vant/src/stepper/Stepper.tsx | 9 ++--- packages/vant/src/sticky/Sticky.tsx | 4 +-- packages/vant/src/sticky/test/index.spec.tsx | 6 ++-- packages/vant/src/swipe-cell/SwipeCell.tsx | 8 ++--- packages/vant/src/swipe-item/SwipeItem.tsx | 2 +- packages/vant/src/swipe/Swipe.tsx | 14 ++++---- packages/vant/src/swipe/index.less | 3 +- packages/vant/src/tab/Tab.tsx | 6 ++-- packages/vant/src/tab/test/index.spec.tsx | 2 +- packages/vant/src/tabbar-item/TabbarItem.tsx | 2 +- packages/vant/src/tabbar/test/index.spec.tsx | 6 ++-- packages/vant/src/tabs/Tabs.tsx | 22 ++++++------ packages/vant/src/tabs/utils.ts | 4 +-- .../vant/src/text-ellipsis/README.zh-CN.md | 2 +- .../vant/src/text-ellipsis/TextEllipsis.tsx | 12 +++---- .../vant/src/text-ellipsis/test/index.spec.ts | 2 +- packages/vant/src/time-picker/README.md | 2 +- packages/vant/src/time-picker/README.zh-CN.md | 2 +- packages/vant/src/time-picker/TimePicker.tsx | 12 +++---- packages/vant/src/time-picker/demo/index.vue | 4 +-- .../vant/src/time-picker/test/index.spec.tsx | 4 +-- packages/vant/src/toast/Toast.tsx | 2 +- packages/vant/src/toast/function-call.tsx | 8 ++--- packages/vant/src/toast/test/function.spec.ts | 4 +-- packages/vant/src/toast/test/index.spec.ts | 4 +-- packages/vant/src/uploader/README.md | 2 +- packages/vant/src/uploader/Uploader.tsx | 12 +++---- packages/vant/src/uploader/demo/index.vue | 4 +-- packages/vant/src/uploader/test/index.spec.ts | 20 +++++------ packages/vant/src/uploader/test/utils.spec.ts | 4 +-- packages/vant/src/uploader/types.ts | 4 +-- packages/vant/src/uploader/utils.ts | 4 +-- packages/vant/src/utils/closest.ts | 2 +- packages/vant/src/utils/test/bem.spec.ts | 8 ++--- .../vant/src/utils/test/interceptor.spec.ts | 2 +- packages/vant/src/watermark/Watermark.tsx | 4 +-- packages/vant/test/event.ts | 4 +-- pnpm-lock.yaml | 14 ++++---- prettier.config.mjs | 4 +++ 209 files changed, 565 insertions(+), 543 deletions(-) delete mode 100644 .prettierrc create mode 100644 prettier.config.mjs diff --git a/.prettierrc b/.prettierrc deleted file mode 100644 index c99ac50b3..000000000 --- a/.prettierrc +++ /dev/null @@ -1,4 +0,0 @@ -{ - "singleQuote": true, - "proseWrap": "never" -} diff --git a/package.json b/package.json index a85a507a6..1f48a1525 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,6 @@ "eslint": "^8.31.0", "husky": "^8.0.1", "nano-staged": "^0.8.0", - "prettier": "^2.7.1" + "prettier": "^3.0.0" } } diff --git a/packages/create-vant-cli-app/src/generator.ts b/packages/create-vant-cli-app/src/generator.ts index d73885f53..d9e5d7f28 100644 --- a/packages/create-vant-cli-app/src/generator.ts +++ b/packages/create-vant-cli-app/src/generator.ts @@ -69,14 +69,14 @@ export class VanGenerator { // see https://github.com/mrmlnc/fast-glob#how-to-write-patterns-on-windows const templatePath = join(GENERATOR_DIR, this.inputs.vueVersion).replace( /\\/g, - '/' + '/', ); const templateFiles = glob.sync( join(templatePath, '**', '*').replace(/\\/g, '/'), { dot: true, - } + }, ); templateFiles.forEach((filePath) => { @@ -109,8 +109,8 @@ export class VanGenerator { consola.success(`Successfully created ${color.yellow(name)}.`); consola.success( `Run ${color.yellow( - `cd ${name} && git init && yarn && yarn dev` - )} to start development!` + `cd ${name} && git init && yarn && yarn dev`, + )} to start development!`, ); } } diff --git a/packages/vant-area-data/src/index.ts b/packages/vant-area-data/src/index.ts index 0c23b0b6f..5fb3c49a4 100644 --- a/packages/vant-area-data/src/index.ts +++ b/packages/vant-area-data/src/index.ts @@ -3900,7 +3900,7 @@ type CascaderOption = { const makeOption = ( text: string, value: string, - children?: CascaderOption[] + children?: CascaderOption[], ): CascaderOption => ({ text, value, diff --git a/packages/vant-cli/cjs/jest.transformer.cjs b/packages/vant-cli/cjs/jest.transformer.cjs index d03305cb6..3aaed7441 100644 --- a/packages/vant-cli/cjs/jest.transformer.cjs +++ b/packages/vant-cli/cjs/jest.transformer.cjs @@ -35,7 +35,7 @@ const transformSFC = (code, path) => { if (descriptor.script) { const content = descriptor.script.content.replace( 'export default', - 'const script =' + 'const script =', ); output.push(content); } else if (descriptor.scriptSetup) { @@ -88,7 +88,7 @@ module.exports = { code = transformJsx(code, path); } return { - code: transformScript(code) + code: transformScript(code), }; }, }; diff --git a/packages/vant-cli/cjs/postcss.config.cjs b/packages/vant-cli/cjs/postcss.config.cjs index 4e6f16b9d..6cb3ea6ca 100644 --- a/packages/vant-cli/cjs/postcss.config.cjs +++ b/packages/vant-cli/cjs/postcss.config.cjs @@ -14,14 +14,12 @@ function getPostcssPlugins(rootConfig) { const plugins = rootConfig.plugins || []; if (Array.isArray(plugins)) { - const hasAutoprefixerPlugin = plugins.find( - (plugin) => { - if (typeof plugin === 'object') { - return plugin.postcssPlugin === 'autoprefixer'; - } - return plugin === 'autoprefixer'; + const hasAutoprefixerPlugin = plugins.find((plugin) => { + if (typeof plugin === 'object') { + return plugin.postcssPlugin === 'autoprefixer'; } - ); + return plugin === 'autoprefixer'; + }); if (hasAutoprefixerPlugin) { return plugins; } diff --git a/packages/vant-cli/package.json b/packages/vant-cli/package.json index 0671c03ed..f416f4a55 100644 --- a/packages/vant-cli/package.json +++ b/packages/vant-cli/package.json @@ -81,7 +81,7 @@ "picocolors": "^1.0.0", "postcss": "^8.4.23", "postcss-load-config": "^4.0.1", - "prettier": "^2.7.1", + "prettier": "^3.0.0", "release-it": "^15.4.1", "terser": "^5.16.1", "transliteration": "^2.3.5", diff --git a/packages/vant-cli/site/common/iframe-sync.js b/packages/vant-cli/site/common/iframe-sync.js index f03dd6dce..5329ca8d2 100644 --- a/packages/vant-cli/site/common/iframe-sync.js +++ b/packages/vant-cli/site/common/iframe-sync.js @@ -40,7 +40,7 @@ export function syncPathToParent() { type: 'replacePath', value: getCurrentDir(), }, - '*' + '*', ); } @@ -53,7 +53,7 @@ export function syncPathToChild() { type: 'replacePath', value: getCurrentDir(), }, - '*' + '*', ); }); } @@ -68,7 +68,7 @@ export function syncThemeToChild(theme) { type: 'updateTheme', value: theme, }, - '*' + '*', ); }); } diff --git a/packages/vant-cli/site/common/style/base.less b/packages/vant-cli/site/common/style/base.less index 57e759d2a..4bf6304b4 100644 --- a/packages/vant-cli/site/common/style/base.less +++ b/packages/vant-cli/site/common/style/base.less @@ -6,9 +6,20 @@ body { overflow-x: auto; color: var(--van-doc-text-color-2); font-size: 16px; - font-family: 'Open Sans', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', - Helvetica, Segoe UI, Arial, Roboto, 'PingFang SC', 'miui', - 'Hiragino Sans GB', 'Microsoft Yahei', sans-serif; + font-family: + 'Open Sans', + -apple-system, + BlinkMacSystemFont, + 'Helvetica Neue', + Helvetica, + Segoe UI, + Arial, + Roboto, + 'PingFang SC', + 'miui', + 'Hiragino Sans GB', + 'Microsoft Yahei', + sans-serif; background-color: var(--van-doc-background); -webkit-font-smoothing: antialiased; } diff --git a/packages/vant-cli/site/desktop/App.vue b/packages/vant-cli/site/desktop/App.vue index c0b58dfc0..5140cbc2a 100644 --- a/packages/vant-cli/site/desktop/App.vue +++ b/packages/vant-cli/site/desktop/App.vue @@ -107,11 +107,11 @@ export default { const navItems = this.config.nav.reduce( (result, nav) => [...result, ...nav.items], - [] + [], ); const current = navItems.find( - (item) => item.path === this.$route.meta.name + (item) => item.path === this.$route.meta.name, ); if (current && current.title) { diff --git a/packages/vant-cli/site/desktop/components/DemoPlayground.vue b/packages/vant-cli/site/desktop/components/DemoPlayground.vue index e7d81d9ab..1b9c6f7f8 100644 --- a/packages/vant-cli/site/desktop/components/DemoPlayground.vue +++ b/packages/vant-cli/site/desktop/components/DemoPlayground.vue @@ -108,7 +108,9 @@ export default { cursor: pointer; opacity: 0.6; outline: none; - transition: opacity 0.2s, background 0.2s; + transition: + opacity 0.2s, + background 0.2s; // expand click area &::after { diff --git a/packages/vant-cli/site/desktop/components/Header.vue b/packages/vant-cli/site/desktop/components/Header.vue index 4547b0eb2..3ae7406f7 100644 --- a/packages/vant-cli/site/desktop/components/Header.vue +++ b/packages/vant-cli/site/desktop/components/Header.vue @@ -142,7 +142,7 @@ export default { const action = val ? 'add' : 'remove'; document.body[`${action}EventListener`]( 'click', - this.checkHideVersionPop + this.checkHideVersionPop, ); this.showVersionPop = val; diff --git a/packages/vant-cli/site/index.html b/packages/vant-cli/site/index.html index 20244e936..592b62860 100644 --- a/packages/vant-cli/site/index.html +++ b/packages/vant-cli/site/index.html @@ -1,4 +1,4 @@ - + @@ -15,10 +15,7 @@ - <% if (headHtml) { %> - <%= headHtml %> - <% } %> - <% if (baiduAnalytics) { %> + <% if (headHtml) { %> <%= headHtml %> <% } %> <% if (baiduAnalytics) { %> - <% } %> - <% if (baiduAnalytics) { %> + <% } %> <% if (baiduAnalytics) { %>