Skip to content

Commit

Permalink
H-3733: Experiment with lefthook as a husky/lint-staged replacement (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
indietyp authored Dec 3, 2024
1 parent ecce2fd commit a6a645b
Show file tree
Hide file tree
Showing 8 changed files with 163 additions and 222 deletions.
4 changes: 0 additions & 4 deletions .config/husky/pre-commit

This file was deleted.

2 changes: 1 addition & 1 deletion .github/actions/warm-up-repo/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ runs:
- name: Install yarn dependencies
uses: nick-fields/retry@7152eba30c6575329ac0576536151aca5a72780e # v3.0.0
env:
HUSKY: 0
LEFTHOOK: 0
with:
max_attempts: 3
timeout_minutes: 10
Expand Down
38 changes: 38 additions & 0 deletions .lefthook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
$schema: https://json.schemastore.org/lefthook.json

pre-commit:
parallel: true
skip:
- merge
- rebase
commands:
markdownlint:
tags: frontend style
glob: "*.md"
run: yarn run markdownlint --fix {staged_files} || true
stage_fixed: true
prettier:
tags: frontend style
glob: "*.{cjs,css,js,json,md,mdx,mjs,scss,ts,tsx,yml}"
run: yarn run prettier --write {staged_files} || true
stage_fixed: true
yarn:
tags: frontend style
glob: "{*/package.json, package.json}"
run: yarn fix:constraints && yarn fix:yarn-deduplicate
stage_fixed: true
sqlfluff:
tags: backend style
glob: "*.sql"
run: sqlfluff fix {staged_files} || true
stage_fixed: true
rust:
tags: backend style
glob: "*.rs"
run: cargo fmt -- {staged_files} || true
stage_fixed: true
toml:
tags: backend style
glob: "*.toml"
run: yarn run taplo format {staged_files} || true
stage_fixed: true
2 changes: 1 addition & 1 deletion apps/hash-frontend/vercel-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ for _ in {1..5}; do rustup show && break || sleep 5; done
# Install the pruned dependencies

echo "Installing yarn dependencies"
HUSKY=0 yarn install --immutable
LEFTHOOK=0 yarn install --immutable
2 changes: 1 addition & 1 deletion apps/hashdotdesign/vercel-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ source "$HOME/.cargo/env"
for _ in {1..5}; do rustup show && break || sleep 5; done

echo "Installing yarn dependencies"
HUSKY=0 yarn install --immutable
LEFTHOOK=0 yarn install --immutable
2 changes: 1 addition & 1 deletion apps/hashdotdev/vercel-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ source "$HOME/.cargo/env"
for _ in {1..5}; do rustup show && break || sleep 5; done

echo "Installing yarn dependencies"
HUSKY=0 yarn install --immutable
LEFTHOOK=0 yarn install --immutable
12 changes: 2 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"lint:taplo": "taplo fmt --check",
"lint:tsc": "turbo --continue lint:tsc --",
"lint:yarn-deduplicate": "yarn dedupe --strategy highest --check",
"postinstall": "turbo run postinstall; husky install .config/husky",
"postinstall": "turbo run postinstall",
"seed-data:opensearch": "yarn workspace @apps/hash-search-loader clear-opensearch",
"seed-data:redis": "yarn workspace @apps/hash-realtime clear-redis",
"seed-data": "concurrently \"yarn:seed-data:*\"",
Expand All @@ -66,13 +66,6 @@
"bench:integration": "turbo run bench:integration --env-mode=loose --",
"prune-node-modules": "find . -type d -name \"node_modules\" -exec rm -rf {} +"
},
"lint-staged": {
"**": [
"suppress-exit-code markdownlint --fix",
"suppress-exit-code prettier --write",
"suppress-exit-code yarn constraints --fix"
]
},
"prettier": {
"plugins": [
"prettier-plugin-packagejson",
Expand Down Expand Up @@ -124,8 +117,7 @@
"@taplo/cli": "0.7.0",
"@yarnpkg/types": "^4.0.0",
"concurrently": "7.6.0",
"husky": "8.0.3",
"lint-staged": "15.2.10",
"lefthook": "1.8.5",
"lockfile-lint": "4.14.0",
"markdownlint-cli": "0.43.0",
"npm-run-all2": "7.0.1",
Expand Down
Loading

0 comments on commit a6a645b

Please sign in to comment.