From f40770ad640bf222725bbebfc448ad88276a6f1c Mon Sep 17 00:00:00 2001 From: Ryan Wang Date: Sat, 12 Oct 2024 15:05:09 +0800 Subject: [PATCH] chore: add prettier-plugin-organize-imports plugin to organize imports (#6836) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #### What type of PR is this? /area ui /kind improvement /milestone 2.20.x #### What this PR does / why we need it: 使用 https://github.com/simonhaenisch/prettier-plugin-organize-imports 优化 UI 项目的模块导入,之前我们是通过[配置 VSCode](https://github.com/halo-dev/halo/blob/9468e8741f3ed2d4c225adc8cef6c6145a8b48a9/ui/.vscode/settings.json#L34-L36) 来实现导入优化,但这种方式局限于 VSCode 编辑器,在其他编辑器无法得到统一的支持。 并且我们为 UI 添加了 git pre commit hook,在提交代码前会对已修改的文件执行 prettier,这样能够更好的保证一致性。 image #### Does this PR introduce a user-facing change? ```release-note None ``` --- ui/.vscode/settings.json | 4 ---- .../contents/attachments/AttachmentList.vue | 6 +++--- .../comments/components/CommentListItem.vue | 6 +++--- .../comments/components/ReplyListItem.vue | 6 +++--- .../posts/tags/components/TagEditingModal.vue | 2 +- .../components/entity-fields/ReloadField.vue | 2 +- .../users/components/UserCreationModal.vue | 2 +- ui/package.json | 1 + ui/pnpm-lock.yaml | 20 +++++++++++++++++++ ui/prettier.config.cjs | 5 ++++- ui/src/components/editor/DefaultEditor.vue | 2 +- .../formkit/inputs/select/MultipleSelect.vue | 8 ++++---- .../inputs/select/SelectDropdownContainer.vue | 6 +++--- ui/uc-src/modules/profile/tabs/Devices.vue | 2 +- 14 files changed, 46 insertions(+), 26 deletions(-) diff --git a/ui/.vscode/settings.json b/ui/.vscode/settings.json index 347d413bd..f728502ec 100644 --- a/ui/.vscode/settings.json +++ b/ui/.vscode/settings.json @@ -30,9 +30,5 @@ }, "[yaml]": { "editor.defaultFormatter": "esbenp.prettier-vscode" - }, - "editor.codeActionsOnSave": { - "source.organizeImports": "explicit", - "source.fixAll": "never" } } diff --git a/ui/console-src/modules/contents/attachments/AttachmentList.vue b/ui/console-src/modules/contents/attachments/AttachmentList.vue index bb601a7f5..fd35e78ba 100644 --- a/ui/console-src/modules/contents/attachments/AttachmentList.vue +++ b/ui/console-src/modules/contents/attachments/AttachmentList.vue @@ -1,6 +1,7 @@