Skip to content

Commit 623c707

Browse files
brunoborgesCopilotCopilot
authored
chore: enforce pre-PR validation (aggregate scripts, git hooks, PR checklist) (#1061)
* chore: enforce pre-PR validation with aggregate scripts, git hooks, and PR checklist Add tooling to help contributors run the same checks as CI before submitting a pull request, reducing avoidable format/lint/build failures. - Add aggregate npm scripts: - `npm run check` runs format-check + lint + build + test (mirrors CI) - `npm run fix` runs format + lint:fix + build - Add husky + lint-staged git hooks (installed via `npm install`): - pre-commit formats and lints staged files - pre-push rebuilds dist/ and runs the test suite - Add a checklist item to the PR template prompting contributors to run `npm run check` locally - Document the aggregate scripts and hooks in docs/contributors.md dist/ is intentionally not auto-committed by CI to avoid pwn-request security risks; the existing `Check dist/` workflow continues to verify it. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent 1bcf9fb commit 623c707

6 files changed

Lines changed: 599 additions & 0 deletions

File tree

.github/pull_request_template.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ Describe your changes.
55
Add link to the related issue.
66

77
**Check list:**
8+
- [ ] Ran `npm run check` locally (format, lint, build, test) and all checks pass.
89
- [ ] Mark if documentation changes are required.
910
- [ ] Mark if tests were added or updated to cover the changes.

.husky/pre-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
npx lint-staged

.husky/pre-push

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
npm run build && npm test

docs/contributors.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,17 @@ Pull requests are the easiest way to contribute changes to git repos at GitHub.
6363
- To lint the code, **you need to run the `lint:fix` script**
6464
- To transpile source code to `javascript` we use [NCC](https://github.com/vercel/ncc). **It is very important to run the `build` script after making changes**, otherwise your changes will not get into the final `javascript` build
6565

66+
> [!TIP]
67+
> Instead of running each script individually, you can run the aggregate scripts:
68+
>
69+
> - `npm run fix` — formats, lints (with autofix) and rebuilds the `dist/` bundle.
70+
> - `npm run check` — runs the same validation as CI: `format-check`, `lint`, `build` and `test`. **Run this before pushing a pull request** to make sure it will pass the required checks.
71+
>
72+
> Git hooks are installed automatically when you run `npm install` (via [husky](https://typicode.github.io/husky/)):
73+
>
74+
> - a **pre-commit** hook formats and lints staged files with [lint-staged](https://github.com/lint-staged/lint-staged);
75+
> - a **pre-push** hook rebuilds `dist/` and runs the test suite.
76+
6677
**Learn more about how to implement tests:**
6778

6879
Adding or changing tests is an integral part of making a change to the code.

0 commit comments

Comments
 (0)