From cb4634ce9345fcd72b947a42e3f3e13c45325e6f Mon Sep 17 00:00:00 2001 From: Aris Ripandi Date: Wed, 4 Sep 2024 21:03:47 +0700 Subject: [PATCH] feat: add lefthook --- .gitignore | 2 ++ .husky/_/pre-push | 60 ----------------------------------------------- lefthook.yml | 17 +++++++------- 3 files changed, 10 insertions(+), 69 deletions(-) delete mode 100755 .husky/_/pre-push diff --git a/.gitignore b/.gitignore index 78dc167..6f283fd 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ /.pnp /.cache /.output +/.husky .pnp.js .DS_Store .DS_Store? @@ -16,6 +17,7 @@ $RECYCLE.BIN/ !.vscode/extensions.json !.vscode/settings.json !.vscode/launch.json + *.bak # SQLite diff --git a/.husky/_/pre-push b/.husky/_/pre-push deleted file mode 100755 index cf59fe1..0000000 --- a/.husky/_/pre-push +++ /dev/null @@ -1,60 +0,0 @@ -#!/bin/sh - -if [ "$LEFTHOOK_VERBOSE" = "1" -o "$LEFTHOOK_VERBOSE" = "true" ]; then - set -x -fi - -if [ "$LEFTHOOK" = "0" ]; then - exit 0 -fi - -call_lefthook() -{ - if test -n "$LEFTHOOK_BIN" - then - "$LEFTHOOK_BIN" "$@" - elif lefthook -h >/dev/null 2>&1 - then - lefthook "$@" - else - dir="$(git rev-parse --show-toplevel)" - osArch=$(uname | tr '[:upper:]' '[:lower:]') - cpuArch=$(uname -m | sed 's/aarch64/arm64/;s/x86_64/x64/') - if test -f "$dir/node_modules/lefthook-${osArch}-${cpuArch}/bin/lefthook" - then - "$dir/node_modules/lefthook-${osArch}-${cpuArch}/bin/lefthook" "$@" - elif test -f "$dir/node_modules/@evilmartians/lefthook/bin/lefthook-${osArch}-${cpuArch}/lefthook" - then - "$dir/node_modules/@evilmartians/lefthook/bin/lefthook-${osArch}-${cpuArch}/lefthook" "$@" - elif test -f "$dir/node_modules/@evilmartians/lefthook-installer/bin/lefthook" - then - "$dir/node_modules/@evilmartians/lefthook-installer/bin/lefthook" "$@" - elif test -f "$dir/node_modules/lefthook/bin/index.js" - then - "$dir/node_modules/lefthook/bin/index.js" "$@" - - elif bundle exec lefthook -h >/dev/null 2>&1 - then - bundle exec lefthook "$@" - elif yarn lefthook -h >/dev/null 2>&1 - then - yarn lefthook "$@" - elif pnpm lefthook -h >/dev/null 2>&1 - then - pnpm lefthook "$@" - elif swift package plugin lefthook >/dev/null 2>&1 - then - swift package --disable-sandbox plugin lefthook "$@" - elif command -v mint >/dev/null 2>&1 - then - mint run csjones/lefthook-plugin "$@" - elif command -v npx >/dev/null 2>&1 - then - npx lefthook "$@" - else - echo "Can't find lefthook in PATH" - fi - fi -} - -call_lefthook run "pre-push" "$@" diff --git a/lefthook.yml b/lefthook.yml index ea20515..bda1379 100644 --- a/lefthook.yml +++ b/lefthook.yml @@ -1,11 +1,11 @@ # Refer for explanation to following link: # https://github.com/evilmartians/lefthook/blob/master/docs/configuration.md -pre-push: - commands: - npm-audit: - tags: frontend security - run: pnpm audit +# pre-push: +# commands: +# npm-audit: +# tags: frontend security +# run: pnpm audit pre-commit: parallel: true @@ -13,12 +13,11 @@ pre-commit: check: glob: "*.{js,ts,jsx,tsx}" exclude: '(^|/)(tests|stories)\.(ts|tsx)$' - run: pnpm check {staged_files} + run: pnpm exec biome check {staged_files} --write lint: glob: "*.{js,ts,jsx,tsx}" - run: pnpm lint {staged_files} + exclude: '(^|/)(tests|stories)\.(ts|tsx)$' + run: pnpm exec biome lint {staged_files} --write # scripts: # "hello.js": # runner: node - # "any.go": - # runner: go run