Add Git Hooks to run lint (#1788)
* + Add package @arkweid/lefthook * Add git hook pre-commit for linting changed files only * Update lefthook.yml about `glob` Co-authored-by: absidue <48293849+absidue@users.noreply.github.com> * Update lefthook.yml to use `yarn run` instead of `npx` Co-authored-by: absidue <48293849+absidue@users.noreply.github.com> Co-authored-by: absidue <48293849+absidue@users.noreply.github.com>
This commit is contained in:
parent
180a89d7c6
commit
ba0bcee2fe
|
@ -0,0 +1,46 @@
|
||||||
|
|
||||||
|
# Refer for explanation to following link:
|
||||||
|
# https://github.com/evilmartians/lefthook/blob/master/docs/full_guide.md
|
||||||
|
pre-commit:
|
||||||
|
parallel: true
|
||||||
|
commands:
|
||||||
|
lint:
|
||||||
|
# Only runs when any file with filename
|
||||||
|
# matching the glob is being committed
|
||||||
|
glob: "*.{js,vue}"
|
||||||
|
run: yarn run eslint --no-color {staged_files}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# EXAMPLE USAGE
|
||||||
|
#
|
||||||
|
# pre-push:
|
||||||
|
# commands:
|
||||||
|
# packages-audit:
|
||||||
|
# tags: frontend security
|
||||||
|
# run: yarn audit
|
||||||
|
# gems-audit:
|
||||||
|
# tags: backend security
|
||||||
|
# run: bundle audit
|
||||||
|
#
|
||||||
|
# pre-commit:
|
||||||
|
# parallel: true
|
||||||
|
# commands:
|
||||||
|
# eslint:
|
||||||
|
# glob: "*.{js,ts}"
|
||||||
|
# run: yarn eslint {staged_files}
|
||||||
|
# rubocop:
|
||||||
|
# tags: backend style
|
||||||
|
# glob: "*.rb"
|
||||||
|
# exclude: "application.rb|routes.rb"
|
||||||
|
# run: bundle exec rubocop --force-exclusion {all_files}
|
||||||
|
# govet:
|
||||||
|
# tags: backend style
|
||||||
|
# files: git ls-files -m
|
||||||
|
# glob: "*.go"
|
||||||
|
# run: go vet {files}
|
||||||
|
# scripts:
|
||||||
|
# "hello.js":
|
||||||
|
# runner: node
|
||||||
|
# "any.go":
|
||||||
|
# runner: go run
|
|
@ -84,6 +84,7 @@
|
||||||
"ytsr": "^3.8.0"
|
"ytsr": "^3.8.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@arkweid/lefthook": "^0.7.7",
|
||||||
"@babel/core": "^7.17.10",
|
"@babel/core": "^7.17.10",
|
||||||
"@babel/plugin-proposal-class-properties": "^7.16.7",
|
"@babel/plugin-proposal-class-properties": "^7.16.7",
|
||||||
"@babel/preset-env": "^7.17.10",
|
"@babel/preset-env": "^7.17.10",
|
||||||
|
|
|
@ -15,6 +15,11 @@
|
||||||
"@jridgewell/gen-mapping" "^0.1.0"
|
"@jridgewell/gen-mapping" "^0.1.0"
|
||||||
"@jridgewell/trace-mapping" "^0.3.9"
|
"@jridgewell/trace-mapping" "^0.3.9"
|
||||||
|
|
||||||
|
"@arkweid/lefthook@^0.7.7":
|
||||||
|
version "0.7.7"
|
||||||
|
resolved "https://registry.yarnpkg.com/@arkweid/lefthook/-/lefthook-0.7.7.tgz#12951b09b955d8054885ffe929aa07a49f39027c"
|
||||||
|
integrity sha512-Eq30OXKmjxIAIsTtbX2fcF3SNZIXS8yry1u8yty7PQFYRctx04rVlhOJCEB2UmfTh8T2vrOMC9IHHUvvo5zbaQ==
|
||||||
|
|
||||||
"@babel/code-frame@7.12.11":
|
"@babel/code-frame@7.12.11":
|
||||||
version "7.12.11"
|
version "7.12.11"
|
||||||
resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.12.11.tgz#f4ad435aa263db935b8f10f2c552d23fb716a63f"
|
resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.12.11.tgz#f4ad435aa263db935b8f10f2c552d23fb716a63f"
|
||||||
|
|
Loading…
Reference in New Issue