feat: pr auto format (#50)

This commit is contained in:
仓鼠
2024-12-13 23:16:09 +08:00
committed by GitHub
parent 1c09c7d6e9
commit b04ef1bb72
4 changed files with 70 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
name: Auto Format
on:
pull_request_target:
types: [opened, synchronize]
jobs:
auto-fix:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.head_ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
- name: Set up Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: "latest"
- name: Install dependencies
run: bun install
- name: Run formatter
run: bun run format
- name: Check for changes
id: check_changes
run: |
git diff --exit-code || echo "has_changes=true" >> $GITHUB_ENV
- name: Commit and push changes
if: steps.check_changes.outputs.has_changes == 'true' || env.has_changes == 'true'
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "chore: auto-fix linting and formatting issues"
commit_options: "--no-verify"
file_pattern: "."
- name: Add PR comment
if: steps.check_changes.outputs.has_changes == 'true' || env.has_changes == 'true'
uses: actions/github-script@v7
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'Linting and formatting issues were automatically fixed. Please review the changes.'
});

12
.prettierrc.json Normal file
View File

@@ -0,0 +1,12 @@
{
"semi": false,
"singleQuote": false,
"printWidth": 100,
"tabWidth": 4,
"trailingComma": "all",
"importOrder": ["^@core/(.*)$", "^@server/(.*)$", "^@ui/(.*)$", "^[./]"],
"importOrderSeparation": true,
"importOrderSortSpecifiers": true,
"endOfLine": "auto",
"plugins": ["prettier-plugin-tailwindcss", "@trivago/prettier-plugin-sort-imports"]
}

BIN
bun.lockb Executable file

Binary file not shown.

View File

@@ -8,6 +8,8 @@
"build": "tsc -b && vite build",
"build-ignore-error": "vite build",
"lint": "eslint .",
"lint:fix": "eslint --fix .",
"format": "prettier --write .",
"preview": "vite preview"
},
"dependencies": {
@@ -26,6 +28,8 @@
"@radix-ui/react-slot": "^1.1.0",
"@radix-ui/react-tabs": "^1.1.1",
"@tanstack/react-table": "^8.20.5",
"@trivago/prettier-plugin-sort-imports": "^5.2.0",
"@types/luxon": "^3.4.2",
"@xterm/addon-attach": "^0.11.0",
"@xterm/addon-fit": "^0.10.0",
"@xterm/xterm": "^5.5.0",
@@ -38,6 +42,7 @@
"jotai-zustand": "^0.6.0",
"lucide-react": "^0.454.0",
"next-themes": "^0.3.0",
"prettier-plugin-tailwindcss": "^0.6.9",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-hook-form": "^7.53.1",