Skip to content

Commit a2eb4be

Browse files
authored
chore: add opt-in pre-commit lint --write hook (#2475)
1 parent 75649f4 commit a2eb4be

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

.githooks/pre-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
cd "$(git rev-parse --show-toplevel)" || exit 1
4+
npm run lint

.github/maintainers_guide.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,27 @@ Maintaining this project requires installing [Node.js](https://nodejs.org). All
88

99
## ✅ Tasks
1010

11+
### 🔧 Git hooks (optional)
12+
13+
#### Pre-commit lint hook
14+
We provide an opt-in Git hook that runs `npm run lint` from the repository root before a commit is created.
15+
16+
Enable it once per clone:
17+
18+
```sh
19+
git config core.hooksPath .githooks
20+
```
21+
22+
Disable it:
23+
24+
```sh
25+
git config --unset core.hooksPath
26+
```
27+
28+
Notes:
29+
- The hook runs `npm run lint` from the repository root.
30+
- You can skip it with `git commit --no-verify` if needed.
31+
1132
### ⚗️ Testing and Linting
1233

1334
The Node SDK is made up of multiple, individual packages, each with their own tests. As such, tests are run on a per-package basis. However, the top-level directory contains some development dependencies applicable to all packages. As a result, to run tests for any package, first run `npm install` from the top-level directory. Then run `npm test --workspace packages/<package-name>` to run that package's tests. To run linting across all packages, run `npm run lint` from the root directory.
@@ -21,6 +42,7 @@ npm test --workspace packages/web-api
2142

2243
This project has tests for individual packages as `*.test.ts` (or `*.test.js`) files inside of each package's `src` directory. Tests use `node:test` as the test runner and `node:assert/strict` for assertions. Also, for verifying the behavior with the real Slack server-side and developer experience with installed packages, you can run the tests and scripts under `prod-server-integration-tests`. Refer to the README file in the directory for details. These tests are supposed to be run in the project maintainers' manual execution. They are not part of CI builds for now.
2344

45+
2446
Upon opening a PR, tests are executed by GitHub Actions, our continuous integration system. GitHub Actions runs several, more granular builds in order to report on success and failure in a more targeted way.
2547

2648
- There is one build for each package on each supported version of Node, as well as one for the integration tests on each supported version of Node.

0 commit comments

Comments
 (0)