Skip to content

Commit 8bbc874

Browse files
committed
task: add optional commit hook
1 parent b8cde27 commit 8bbc874

File tree

5 files changed

+817
-1
lines changed

5 files changed

+817
-1
lines changed

.husky/pre-commit

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

.lintstagedrc.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"**/*.{js,jsx,ts,tsx,json,md}": ["prettier --write"],
3+
"**/*.js": ["jest --findRelatedTests --passWithNoTests"],
4+
}

CONTRIBUTING.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Contributing to MongoDB OpenAPI Project
2+
3+
## Development Setup
4+
5+
### Prerequisites
6+
7+
- Node.js v20 or later
8+
- npm v8 or later
9+
- Git
10+
11+
### Installation
12+
13+
1. Clone the repository:
14+
```bash
15+
git clone https://github.com/your-username/mongodb-openapi.git
16+
cd mongodb-openapi
17+
```
18+
19+
2. Install dependencies:
20+
```bash
21+
npm install
22+
```
23+
24+
3. Set up Git hooks (optional):
25+
```bash
26+
npm run precommit
27+
```
28+
29+
This will install Husky, which manages Git hooks for the project. The hooks ensure code quality by automatically running various checks before commits.
30+
31+
## Development Workflow
32+
33+
### Git Hooks
34+
35+
This project uses the following Git hooks:
36+
37+
- **pre-commit**: Automatically formats your code using Prettier and runs tests for staged JavaScript files to ensure code quality before each commit.
38+
39+
### Available Scripts
40+
41+
- `npm run format` - Format all files with Prettier
42+
- `npm run format-check` - Check formatting without modifying files
43+
- `npm run lint-js` - Lint JavaScript files
44+
- `npm run test` - Run all tests
45+
46+
#### IPA specific targets
47+
48+
- `npm run gen-ipa-docs` - Generate IPA ruleset documentation (see `./tools` folder for more information)
49+
- `npm run ipa-validation` - Run OpenAPI validation with Spectral

0 commit comments

Comments
 (0)