From d2803282474c17fb3d732988639e6203b46a3853 Mon Sep 17 00:00:00 2001 From: Hyouka Date: Mon, 20 Jan 2025 12:46:26 +0800 Subject: [PATCH] =?UTF-8?q?ci:=20=E4=BC=98=E5=8C=96=E4=B8=AD=E6=96=87?= =?UTF-8?q?=E6=96=87=E6=9C=AC=E6=A3=80=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/check-zh.yml | 56 ++++++++++++++++++++++++++++++++++ .github/workflows/check.yml | 3 -- .vscode/settings.json | 9 +++--- .zhlintcaseignore | 17 +++++++++++ .zhlintrc | 13 ++++++++ package.json | 5 +-- 6 files changed, 93 insertions(+), 10 deletions(-) create mode 100644 .github/workflows/check-zh.yml create mode 100644 .zhlintcaseignore create mode 100644 .zhlintrc diff --git a/.github/workflows/check-zh.yml b/.github/workflows/check-zh.yml new file mode 100644 index 000000000..4c79d3402 --- /dev/null +++ b/.github/workflows/check-zh.yml @@ -0,0 +1,56 @@ +name: Check Chinese text + +env: + NODE_OPTIONS: --max-old-space-size=6144 + +on: + push: + branches: [main] + paths: + - '**/zh/**/*.md' + pull_request: + branches: [main] + types: [opened] + + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.event.number || github.sha }} + cancel-in-progress: true + +jobs: + test: + runs-on: ubuntu-latest + + strategy: + matrix: + node_version: + - 20 + + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + # “最近更新时间” 等 git 日志相关信息,需要拉取全部提交记录 + fetch-depth: 0 + - name: Cache pnpm modules + uses: actions/cache@v2 + with: + path: ~/.pnpm-store + key: ${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}- + + - name: Install pnpm + uses: pnpm/action-setup@v2 + with: + run_install: true + + - name: Set node version to ${{ matrix.node_version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node_version }} + cache: pnpm + + - name: Linter zh markdown + run: pnpm run lint:zh diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 77a1277d2..8eb49bc23 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -53,6 +53,3 @@ jobs: env: NODE_OPTIONS: --max_old_space_size=4096 run: pnpm build-mpa - - - name: Linter test - run: pnpm run lint diff --git a/.vscode/settings.json b/.vscode/settings.json index b6b9231f0..ba68670d4 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -4,18 +4,17 @@ "Aliyun", "axline", "bilibili", + "Gitee", + "GITEE", "ISPROD", "qrcode", + "qzone", "unocss", "vitepress", "wechat", "wechatpay", "wxtl", - "Gitee", - "GITEE", - "bilibili", - "qzone", - "wechat" + "zhlint" ], "vue.codeActions.enabled": false, "files.trimTrailingWhitespace": true, diff --git a/.zhlintcaseignore b/.zhlintcaseignore new file mode 100644 index 000000000..4813e30d7 --- /dev/null +++ b/.zhlintcaseignore @@ -0,0 +1,17 @@ +> {# +? {# +! {# +[^ ]: +]: +[! +# 1. +# 2. +# 3. +# 4. +# 5. +# 6. +# 7. +# 8. +# 9. + + diff --git a/.zhlintrc b/.zhlintrc new file mode 100644 index 000000000..16be81e46 --- /dev/null +++ b/.zhlintrc @@ -0,0 +1,13 @@ +{ + "preset": "default", + "rules": { + "adjustedFullwidthPunctuation": "‘’", + "spaceOutsideHalfQuote": false + }, + "caseIgnores": { + "IgnoredCase": { + "textStart": "[^", + "textEnd": ":" + } + } +} diff --git a/package.json b/package.json index 7137ffe42..3a01f02d8 100644 --- a/package.json +++ b/package.json @@ -11,10 +11,11 @@ "commit": "git-cz", "dev": "vitepress", "lint": "prettier --check . && pnpm lint:zh", - "lint:fix": "prettier --write .", + "lint:fix": "prettier --write . & pnpm lint:zh-fix", "lint:md": "markdownlint **/*.md", "lint:prettier": "prettier --check .", - "lint:zh": "zhlint 'src/zh/**/*.md'", + "lint:zh": "zhlint **/zh/**/*.md", + "lint:zh-fix": "zhlint **/zh/**/*.md --fix", "lunaria:build": "lunaria build", "lunaria:preview": "lunaria preview", "prepare": "husky",