diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..14ad2a8 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,24 @@ +name: Lint + +on: + pull_request: + branches: [main] + push: + branches: [main] + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: pnpm/action-setup@v4 + - uses: actions/setup-node@v4 + with: + node-version: 22 + cache: pnpm + + - run: pnpm install --frozen-lockfile + + - name: Biome CI + run: pnpm exec biome ci diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100644 index 0000000..d551451 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1 @@ +pnpm exec biome check --staged --write --no-errors-on-unmatched diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4d1ffb8..8ffb930 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -136,15 +136,25 @@ pnpm lint:fix # auto-fix Rust code follows standard `rustfmt` conventions. +### Pre-commit Hook + +A [Husky](https://typicode.github.io/husky/) pre-commit hook runs automatically on every commit. It checks and auto-fixes staged files via `biome check --staged --write`, so lint issues are caught before they reach the repository. + +The hook is set up automatically when you run `pnpm install`. + +### CI + +A GitHub Actions workflow runs `biome ci` on every pull request and push to `main`. PRs that fail lint checks cannot be merged. + ## Pull Request Process 1. Fork the repository 2. Create a feature branch (`git checkout -b feat/my-feature`) 3. Make your changes 4. Run tests: `pnpm test` (frontend) and `cargo test` (Rust) -5. Run `pnpm lint` to ensure code quality -6. Commit with a descriptive message -7. Push to your fork and open a PR +5. Commit — the pre-commit hook will auto-fix lint issues on staged files +6. Push to your fork and open a PR +7. CI will verify lint and tests pass ### Commit Convention diff --git a/package.json b/package.json index b7111d4..39f8b71 100644 --- a/package.json +++ b/package.json @@ -17,10 +17,12 @@ "build:desktop": "pnpm --filter=@claude-prism/desktop tauri build", "lint": "pnpm exec biome check", "lint:fix": "pnpm exec biome check --fix", - "release": "echo 'To release: git tag v && git push origin v'" + "release": "echo 'To release: git tag v && git push origin v'", + "prepare": "husky" }, "devDependencies": { "@biomejs/biome": "^2.3.13", + "husky": "^9.1.7", "turbo": "^2.7.6" }, "packageManager": "pnpm@10.28.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0b76b91..3ed126a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -18,6 +18,9 @@ importers: '@biomejs/biome': specifier: ^2.3.13 version: 2.3.13 + husky: + specifier: ^9.1.7 + version: 9.1.7 turbo: specifier: ^2.7.6 version: 2.7.6 @@ -4538,6 +4541,11 @@ packages: humanize-ms@1.2.1: resolution: {integrity: sha512-Fl70vYtsAFb/C06PTS9dZBo7ihau+Tu/DNCk/OyHhea07S+aeMWpFFkUaXRa8fI+ScZbEI8dfSxwY7gxZ9SAVQ==} + husky@9.1.7: + resolution: {integrity: sha512-5gs5ytaNjBrh5Ow3zrvdUUY+0VxIuWVL4i9irt6friV+BqdCfmV11CQTWMiBYWHbXhco+J1kHfTOUkePhCDvMA==} + engines: {node: '>=18'} + hasBin: true + iconv-lite@0.6.3: resolution: {integrity: sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==} engines: {node: '>=0.10.0'} @@ -11524,6 +11532,8 @@ snapshots: dependencies: ms: 2.1.3 + husky@9.1.7: {} + iconv-lite@0.6.3: dependencies: safer-buffer: 2.1.2