Skip to content

Commit

Permalink
feat: remove husky and lint-staged in favor of lefthook (#404)
Browse files Browse the repository at this point in the history
* feat: remove husky and lint-staged in favor of lefthook

* chore: unset git previous git hooks that added husky back

* chore: use correct script name
  • Loading branch information
tsyirvo authored Nov 18, 2024
1 parent 8a8ac1b commit 821027f
Show file tree
Hide file tree
Showing 8 changed files with 160 additions and 409 deletions.
1 change: 0 additions & 1 deletion .husky/.gitignore

This file was deleted.

1 change: 0 additions & 1 deletion .husky/commit-msg

This file was deleted.

18 changes: 0 additions & 18 deletions .husky/post-merge

This file was deleted.

1 change: 0 additions & 1 deletion .husky/pre-commit

This file was deleted.

18 changes: 18 additions & 0 deletions lefthook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
pre-commit:
parallel: true
commands:
eslint:
glob: '*.{js,ts,jsx,tsx}'
run: yarn lint {staged_files}
typescript:
run: yarn lint:ts
tests:
run: yarn test {staged_files} --findRelatedTests --passWithNoTests --coverage=false

commit-msg:
commands:
'lint commit message':
run: yarn run commitlint --edit {1}

post-checkout:
scripts: './scripts/post-checkout.sh'
18 changes: 3 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
"build:production:android": "cross-env APP_ENV=production eas build --profile production --platform android --local",
"//// TESTS ////": "",
"test": "jest --coverage=false",
"test:staged": "jest -o --passWithNoTests --runInBand --coverage=false",
"test:coverage": "jest",
"test:e2e": "maestro test ./src/e2e",
"//// QUALITY ////": "",
Expand All @@ -54,11 +53,9 @@
"version:bump": "standard-version --skip.commit --skip.changelog --skip.tag",
"version:tag": "standard-version",
"//// MISC ////": "",
"clean:watchman": "watchman watch-del-all",
"perf:bundle": "npx react-native-bundle-visualizer",
"prepare": "husky",
"postinstall": "husky && patch-package",
"prepack": "pinst --disable",
"postpack": "pinst --enable"
"postinstall": "patch-package"
},
"dependencies": {
"@amplitude/analytics-react-native": "1.4.10",
Expand Down Expand Up @@ -157,14 +154,13 @@
"eslint": "8.57.1",
"eslint-config-tsyirvo-react-native": "https://github.com/tsyirvo/eslint-config-tsyirvo-react-native.git#develop",
"fs-extra": "11.2.0",
"husky": "9.1.6",
"imagemin": "7.0.1",
"imagemin-mozjpeg": "9.0.0",
"imagemin-pngquant": "9.0.2",
"is-image": "4.0.0",
"jest": "29.7.0",
"jest-expo": "~51.0.4",
"lint-staged": "15.2.10",
"lefthook": "1.8.4",
"patch-package": "8.0.0",
"pinst": "3.0.0",
"postinstall-postinstall": "2.1.0",
Expand All @@ -185,14 +181,6 @@
]
}
},
"lint-staged": {
"*.{js,ts,tsx}": [
"bash -c tsc --noEmit",
"bash -c yarn lint",
"bash -c yarn prettify",
"bash -c yarn test"
]
},
"jest": {
"moduleFileExtensions": [
"ts",
Expand Down
22 changes: 22 additions & 0 deletions scripts/post-checkout.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash

# $1 - Previous HEAD ref
# $2 - New HEAD ref
# $3 - Flag indicating if checkout was branch/file

# Only run on branch checkout, not file checkout
if [ "$3" = "1" ]; then
echo 'Checking for changes in yarn.lock...'

# Compare yarn.lock between old and new refs
if git diff --name-only $1 $2 | grep -q "^yarn.lock$"; then
echo "📦 yarn.lock changed. Run yarn to bring your dependencies up to date."
yarn
fi

echo 'You are up to date :)'
fi

echo 'If necessary, you can generate again the native code.'

exit 0
Loading

0 comments on commit 821027f

Please sign in to comment.