diff options
| author | 2026-01-16 09:13:38 +0800 | |
|---|---|---|
| committer | 2026-01-16 09:13:38 +0800 | |
| commit | 73e83b4cb5b1adcd0463fc32d558d71a391b9264 (patch) | |
| tree | f09b18e3b99706aa3762fb7deb17241fed2c8801 | |
| parent | 9688bbd2f1ac5acb4b170dcf4d4908a548746cba (diff) | |
| download | DropOut-73e83b4cb5b1adcd0463fc32d558d71a391b9264.tar.gz DropOut-73e83b4cb5b1adcd0463fc32d558d71a391b9264.zip | |
chore: add UI linter workflow with oxlint and oxfmt
| -rw-r--r-- | .github/workflows/check.yml | 2 | ||||
| -rw-r--r-- | .github/workflows/lint.yml | 93 | ||||
| -rw-r--r-- | ui/package.json | 7 | ||||
| -rw-r--r-- | ui/pnpm-lock.yaml | 179 |
4 files changed, 279 insertions, 2 deletions
diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 0cbcf35..702cc0a 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -4,7 +4,7 @@ on: push: paths: - "ui/**" - - ".github/workflows/ui_check.yml" + - ".github/workflows/check.yml" pull_request: branches: ["main", "master", "dev"] workflow_dispatch: diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..c8d1b27 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,93 @@ +name: UI Linter + +on: + workflow_run: + workflows: ["UI Checker"] + types: + - completed + workflow_dispatch: + inputs: + commit_message: + description: "Commit Message" + type: string + required: false + +jobs: + check: + if: | + (github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success') || + github.event_name == 'workflow_dispatch' + runs-on: ubuntu-latest + steps: + - name: Check if it is a direct push + id: check_push + run: | + if [[ "${{ github.event_name }}" == "workflow_run" ]]; then + if [[ "${{ github.event.workflow_run.event }}" == "pull_request" ]]; then + echo "PR detected. Exiting." + echo "is_pr=True" >> $GITHUB_OUTPUT + else + echo "Direct push or other event detected. Proceeding..." + echo "is_pr=False" >> $GITHUB_OUTPUT + fi + else + echo "Manual trigger detected. Proceeding..." + echo "is_pr=False" >> $GITHUB_OUTPUT + fi + + - name: Checkout repository + if: steps.check_push.outputs.is_pr != 'True' + uses: actions/checkout@v6 + with: + show-progress: false + persist-credentials: false + + - name: Install pnpm + if: steps.check_push.outputs.is_pr != 'True' + uses: pnpm/action-setup@v4 + with: + version: 9 + run_install: true + package_json_file: ui/package.json + + - name: Install Node.js + if: steps.check_push.outputs.is_pr != 'True' + uses: actions/setup-node@v4 + with: + node-version: 22 + cache: "pnpm" + cache-dependency-path: ui/pnpm-lock.yaml + + - run: pnpm format + working-directory: ui + + - run: pnpm lint:fix + working-directory: ui + + - name: Commit changes + id: commit_changes + if: steps.check_push.outputs.is_pr != 'True' + run: | + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + + git add . + + if git diff-index --quiet HEAD --; then + echo "No changes to commit" + else + commit_msg="${{ github.event.inputs.commit_message }}" + if [ -z "$commit_msg" ]; then + commit_msg="chore: Auto Templates Optimization" + fi + git commit -m "$commit_msg" -m "Triggered by ${{github.sha}}" -m "[skip changelog]" + git pull origin $(git rev-parse --abbrev-ref HEAD) --unshallow --rebase + echo "have_commits=True" >> $GITHUB_OUTPUT + fi + + - name: Push changes + if: steps.check_push.outputs.is_pr != 'True' && steps.commit_changes.outputs.have_commits == 'True' && github.repository_owner == 'MAA1999' + uses: ad-m/github-push-action@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + branch: ${{ github.ref }} diff --git a/ui/package.json b/ui/package.json index 2db214a..05dd2b2 100644 --- a/ui/package.json +++ b/ui/package.json @@ -7,7 +7,10 @@ "dev": "vite", "build": "vite build", "preview": "vite preview", - "check": "svelte-check --tsconfig ./tsconfig.app.json && tsc -p tsconfig.node.json" + "check": "svelte-check --tsconfig ./tsconfig.app.json && tsc -p tsconfig.node.json", + "lint": "oxlint .", + "lint:fix": "oxlint . --fix", + "format": "oxfmt . --write" }, "devDependencies": { "@sveltejs/vite-plugin-svelte": "^6.2.1", @@ -15,6 +18,8 @@ "@tsconfig/svelte": "^5.0.6", "@types/node": "^24.10.1", "autoprefixer": "^10.4.23", + "oxfmt": "^0.24.0", + "oxlint": "^1.39.0", "postcss": "^8.5.6", "svelte": "^5.46.4", "svelte-check": "^4.3.4", diff --git a/ui/pnpm-lock.yaml b/ui/pnpm-lock.yaml index df9ddc7..390862c 100644 --- a/ui/pnpm-lock.yaml +++ b/ui/pnpm-lock.yaml @@ -48,6 +48,12 @@ importers: autoprefixer: specifier: ^10.4.23 version: 10.4.23(postcss@8.5.6) + oxfmt: + specifier: ^0.24.0 + version: 0.24.0 + oxlint: + specifier: ^1.39.0 + version: 1.39.0 postcss: specifier: ^8.5.6 version: 8.5.6 @@ -104,6 +110,86 @@ packages: '@oxc-project/types@0.97.0': resolution: {integrity: sha512-lxmZK4xFrdvU0yZiDwgVQTCvh2gHWBJCBk5ALsrtsBWhs0uDIi+FTOnXRQeQfs304imdvTdaakT/lqwQ8hkOXQ==} + '@oxfmt/darwin-arm64@0.24.0': + resolution: {integrity: sha512-aYXuGf/yq8nsyEcHindGhiz9I+GEqLkVq8CfPbd+6VE259CpPEH+CaGHEO1j6vIOmNr8KHRq+IAjeRO2uJpb8A==} + cpu: [arm64] + os: [darwin] + + '@oxfmt/darwin-x64@0.24.0': + resolution: {integrity: sha512-vs3b8Bs53hbiNvcNeBilzE/+IhDTWKjSBB3v/ztr664nZk65j0xr+5IHMBNz3CFppmX7o/aBta2PxY+t+4KoPg==} + cpu: [x64] + os: [darwin] + + '@oxfmt/linux-arm64-gnu@0.24.0': + resolution: {integrity: sha512-ItPDOPoQ0wLj/s8osc5ch57uUcA1Wk8r0YdO8vLRpXA3UNg7KPOm1vdbkIZRRiSUphZcuX5ioOEetEK8H7RlTw==} + cpu: [arm64] + os: [linux] + + '@oxfmt/linux-arm64-musl@0.24.0': + resolution: {integrity: sha512-JkQO3WnQjQTJONx8nxdgVBfl6BBFfpp9bKhChYhWeakwJdr7QPOAWJ/v3FGZfr0TbqINwnNR74aVZayDDRyXEA==} + cpu: [arm64] + os: [linux] + + '@oxfmt/linux-x64-gnu@0.24.0': + resolution: {integrity: sha512-N/SXlFO+2kak5gMt0oxApi0WXQDhwA0PShR0UbkY0PwtHjfSiDqJSOumyNqgQVoroKr1GNnoRmUqjZIz6DKIcw==} + cpu: [x64] + os: [linux] + + '@oxfmt/linux-x64-musl@0.24.0': + resolution: {integrity: sha512-WM0pek5YDCQf50XQ7GLCE9sMBCMPW/NPAEPH/Hx6Qyir37lEsP4rUmSECo/QFNTU6KBc9NnsviAyJruWPpCMXw==} + cpu: [x64] + os: [linux] + + '@oxfmt/win32-arm64@0.24.0': + resolution: {integrity: sha512-vFCseli1KWtwdHrVlT/jWfZ8jP8oYpnPPEjI23mPLW8K/6GEJmmvy0PZP5NpWUFNTzX0lqie58XnrATJYAe9Xw==} + cpu: [arm64] + os: [win32] + + '@oxfmt/win32-x64@0.24.0': + resolution: {integrity: sha512-0tmlNzcyewAnauNeBCq0xmAkmiKzl+H09p0IdHy+QKrTQdtixtf+AOjDAADbRfihkS+heF15Pjc4IyJMdAAJjw==} + cpu: [x64] + os: [win32] + + '@oxlint/darwin-arm64@1.39.0': + resolution: {integrity: sha512-lT3hNhIa02xCujI6YGgjmYGg3Ht/X9ag5ipUVETaMpx5Rd4BbTNWUPif1WN1YZHxt3KLCIqaAe7zVhatv83HOQ==} + cpu: [arm64] + os: [darwin] + + '@oxlint/darwin-x64@1.39.0': + resolution: {integrity: sha512-UT+rfTWd+Yr7iJeSLd/7nF8X4gTYssKh+n77hxl6Oilp3NnG1CKRHxZDy3o3lIBnwgzJkdyUAiYWO1bTMXQ1lA==} + cpu: [x64] + os: [darwin] + + '@oxlint/linux-arm64-gnu@1.39.0': + resolution: {integrity: sha512-qocBkvS2V6rH0t9AT3DfQunMnj3xkM7srs5/Ycj2j5ZqMoaWd/FxHNVJDFP++35roKSvsRJoS0mtA8/77jqm6Q==} + cpu: [arm64] + os: [linux] + + '@oxlint/linux-arm64-musl@1.39.0': + resolution: {integrity: sha512-arZzAc1PPcz9epvGBBCMHICeyQloKtHX3eoOe62B3Dskn7gf6Q14wnDHr1r9Vp4vtcBATNq6HlKV14smdlC/qA==} + cpu: [arm64] + os: [linux] + + '@oxlint/linux-x64-gnu@1.39.0': + resolution: {integrity: sha512-ZVt5qsECpuNprdWxAPpDBwoixr1VTcZ4qAEQA2l/wmFyVPDYFD3oBY/SWACNnWBddMrswjTg9O8ALxYWoEpmXw==} + cpu: [x64] + os: [linux] + + '@oxlint/linux-x64-musl@1.39.0': + resolution: {integrity: sha512-pB0hlGyKPbxr9NMIV783lD6cWL3MpaqnZRM9MWni4yBdHPTKyFNYdg5hGD0Bwg+UP4S2rOevq/+OO9x9Bi7E6g==} + cpu: [x64] + os: [linux] + + '@oxlint/win32-arm64@1.39.0': + resolution: {integrity: sha512-Gg2SFaJohI9+tIQVKXlPw3FsPQFi/eCSWiCgwPtPn5uzQxHRTeQEZKuluz1fuzR5U70TXubb2liZi4Dgl8LJQA==} + cpu: [arm64] + os: [win32] + + '@oxlint/win32-x64@1.39.0': + resolution: {integrity: sha512-sbi25lfj74hH+6qQtb7s1wEvd1j8OQbTaH8v3xTcDjrwm579Cyh0HBv1YSZ2+gsnVwfVDiCTL1D0JsNqYXszVA==} + cpu: [x64] + os: [win32] + '@rolldown/binding-android-arm64@1.0.0-beta.50': resolution: {integrity: sha512-XlEkrOIHLyGT3avOgzfTFSjG+f+dZMw+/qd+Y3HLN86wlndrB/gSimrJCk4gOhr1XtRtEKfszpadI3Md4Z4/Ag==} engines: {node: ^20.19.0 || >=22.12.0} @@ -535,6 +621,21 @@ packages: obug@2.1.1: resolution: {integrity: sha512-uTqF9MuPraAQ+IsnPf366RG4cP9RtUi7MLO1N3KEc+wb0a6yKpeL0lmk2IB1jY5KHPAlTc6T/JRdC/YqxHNwkQ==} + oxfmt@0.24.0: + resolution: {integrity: sha512-UjeM3Peez8Tl7IJ9s5UwAoZSiDRMww7BEc21gDYxLq3S3/KqJnM3mjNxsoSHgmBvSeX6RBhoVc2MfC/+96RdSw==} + engines: {node: ^20.19.0 || >=22.12.0} + hasBin: true + + oxlint@1.39.0: + resolution: {integrity: sha512-wSiLr0wjG+KTU6c1LpVoQk7JZ7l8HCKlAkVDVTJKWmCGazsNxexxnOXl7dsar92mQcRnzko5g077ggP3RINSjA==} + engines: {node: ^20.19.0 || >=22.12.0} + hasBin: true + peerDependencies: + oxlint-tsgolint: '>=0.10.0' + peerDependenciesMeta: + oxlint-tsgolint: + optional: true + picocolors@1.1.1: resolution: {integrity: sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==} @@ -633,6 +734,10 @@ packages: resolution: {integrity: sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ==} engines: {node: '>=12.0.0'} + tinypool@2.0.0: + resolution: {integrity: sha512-/RX9RzeH2xU5ADE7n2Ykvmi9ED3FBGPAjw9u3zucrNNaEBIO0HPSYgL0NT7+3p147ojeSdaVu08F6hjpv31HJg==} + engines: {node: ^20.0.0 || >=22.0.0} + tslib@2.8.1: resolution: {integrity: sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==} @@ -713,6 +818,54 @@ snapshots: '@oxc-project/types@0.97.0': {} + '@oxfmt/darwin-arm64@0.24.0': + optional: true + + '@oxfmt/darwin-x64@0.24.0': + optional: true + + '@oxfmt/linux-arm64-gnu@0.24.0': + optional: true + + '@oxfmt/linux-arm64-musl@0.24.0': + optional: true + + '@oxfmt/linux-x64-gnu@0.24.0': + optional: true + + '@oxfmt/linux-x64-musl@0.24.0': + optional: true + + '@oxfmt/win32-arm64@0.24.0': + optional: true + + '@oxfmt/win32-x64@0.24.0': + optional: true + + '@oxlint/darwin-arm64@1.39.0': + optional: true + + '@oxlint/darwin-x64@1.39.0': + optional: true + + '@oxlint/linux-arm64-gnu@1.39.0': + optional: true + + '@oxlint/linux-arm64-musl@1.39.0': + optional: true + + '@oxlint/linux-x64-gnu@1.39.0': + optional: true + + '@oxlint/linux-x64-musl@1.39.0': + optional: true + + '@oxlint/win32-arm64@1.39.0': + optional: true + + '@oxlint/win32-x64@1.39.0': + optional: true + '@rolldown/binding-android-arm64@1.0.0-beta.50': optional: true @@ -1028,6 +1181,30 @@ snapshots: obug@2.1.1: {} + oxfmt@0.24.0: + dependencies: + tinypool: 2.0.0 + optionalDependencies: + '@oxfmt/darwin-arm64': 0.24.0 + '@oxfmt/darwin-x64': 0.24.0 + '@oxfmt/linux-arm64-gnu': 0.24.0 + '@oxfmt/linux-arm64-musl': 0.24.0 + '@oxfmt/linux-x64-gnu': 0.24.0 + '@oxfmt/linux-x64-musl': 0.24.0 + '@oxfmt/win32-arm64': 0.24.0 + '@oxfmt/win32-x64': 0.24.0 + + oxlint@1.39.0: + optionalDependencies: + '@oxlint/darwin-arm64': 1.39.0 + '@oxlint/darwin-x64': 1.39.0 + '@oxlint/linux-arm64-gnu': 1.39.0 + '@oxlint/linux-arm64-musl': 1.39.0 + '@oxlint/linux-x64-gnu': 1.39.0 + '@oxlint/linux-x64-musl': 1.39.0 + '@oxlint/win32-arm64': 1.39.0 + '@oxlint/win32-x64': 1.39.0 + picocolors@1.1.1: {} picomatch@4.0.3: {} @@ -1125,6 +1302,8 @@ snapshots: fdir: 6.5.0(picomatch@4.0.3) picomatch: 4.0.3 + tinypool@2.0.0: {} + tslib@2.8.1: optional: true |