Skip to content

Commit

Permalink
feat: use lefthook for precommit hook
Browse files Browse the repository at this point in the history
Add a precommit that helps keep code in check as we work

PR: #2
  • Loading branch information
jbergstroem authored Jul 17, 2024
1 parent a41298e commit d53b9d1
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 6 deletions.
16 changes: 16 additions & 0 deletions .lefthook.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
skip_output = ['meta', 'execution', 'empty_summary']

[pre-commit]
parallel = true

[pre-commit.commands.biome]
glob = "*.{json,ts}"
run = "node_modules/.bin/biome check --no-errors-on-unmatched --files-ignore-unknown=true {staged_files}"

[pre-commit.commands.test]
glob = "*.ts"
run = "bun test"

[pre-commit.commands.typos]
glob = "*.{md,mdoc,mdx}"
run = "typos {staged_files}"
4 changes: 3 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ are more sensitive, emailed to <[email protected]>.

To install Topsort.js as a contributor, you need to have Bun installed on your machine. Follow the instructions on the [Bun website](https://bun.sh/) to install it.

You will also need [typos][https://github.com/crate-ci/typos] for validating documentation. Install it through your package manager (on MacOS: `brew install typos-cli`)

Clone the repository and install the dependencies:

```sh
Expand Down Expand Up @@ -120,4 +122,4 @@ The SDK uses following configuration files:
`tsup.config.ts`: Configuration for the TSUP bundler.

## License
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for more details.
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for more details.
3 changes: 1 addition & 2 deletions biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
"enabled": true
},
"files": {
"ignoreUnknown": true,
"ignore": ["dist/**"]
"ignoreUnknown": true
},
"json": {
"formatter": {
Expand Down
Binary file modified bun.lockb
Binary file not shown.
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@
"README.md"
],
"scripts": {
"build": "rm -rf dist && bun run tsup",
"test": "bun test",
"build": "tsup",
"format": "biome check",
"format:fix": "biome check --write"
"format:fix": "biome check --write",
"prepare": "lefthook install"
},
"devDependencies": {
"@biomejs/biome": "1.8.3",
"@types/bun": "1.1.6",
"lefthook": "1.7.2",
"msw": "2.3.1",
"tsup": "8.1.0",
"typescript": "5.5.3"
Expand Down

0 comments on commit d53b9d1

Please sign in to comment.