Skip to content

Commit

Permalink
Pre commit formatting (#3)
Browse files Browse the repository at this point in the history
- [x] Runs formatting on staged files during commit (formatting result
will be included in the commit)

I'm still not 100% about running lint-staged long term. My main issue is
that the hook is terminated if the process running git is killed. The
result is that as a dev you're forced to whatever interface for git
you're using open during lint-staged or the commit will be arborted.
(e.g. if you commit from a pane in your terminal and close it too early
the commit won't go through)

I'm in favor of merging anyways and reverting if it becomes an issue.
  • Loading branch information
GNRSN authored Jul 9, 2024
2 parents 57552a4 + b86ed54 commit bf85879
Show file tree
Hide file tree
Showing 4 changed files with 246 additions and 6 deletions.
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged
11 changes: 11 additions & 0 deletions TOOLING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Tooling

## Git hooks

Packages:

- Husky: Easier git hook configuration

- Lint-staged: Run e.g. formatting on staged filed and include result in the commit

Opt out through the `-n/--no-verify` flag available for most git commands
10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,20 @@
"lint:ws": "pnpm dlx sherif@latest",
"postinstall": "pnpm lint:ws",
"typecheck": "turbo run typecheck",
"ui-add": "turbo run ui-add"
"ui-add": "turbo run ui-add",
"prepare": "husky"
},
"devDependencies": {
"@acme/prettier-config": "workspace:*",
"@turbo/gen": "^2.0.3",
"husky": "^9.0.11",
"lint-staged": "^15.2.7",
"prettier": "^3.3.1",
"turbo": "^2.0.3",
"typescript": "^5.4.5"
},
"prettier": "@acme/prettier-config"
"prettier": "@acme/prettier-config",
"lint-staged": {
"*": "prettier --ignore-unknown --write"
}
}
Loading

0 comments on commit bf85879

Please sign in to comment.