diff --git a/.github/workflows/auto-format-commit.yml b/.github/workflows/auto-format-commit.yml new file mode 100644 index 0000000..84baf2d --- /dev/null +++ b/.github/workflows/auto-format-commit.yml @@ -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.' + }); diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 0000000..0d556dc --- /dev/null +++ b/.prettierrc.json @@ -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"] +} diff --git a/bun.lockb b/bun.lockb new file mode 100755 index 0000000..5de484c Binary files /dev/null and b/bun.lockb differ diff --git a/package.json b/package.json index d3a1059..5f5a02a 100644 --- a/package.json +++ b/package.json @@ -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",