Skip to content

Commit

Permalink
Add Git Hooks to run lint (FreeTubeApp#1788)
Browse files Browse the repository at this point in the history
* + Add package @arkweid/lefthook

* Add git hook pre-commit for linting changed files only

* Update lefthook.yml about `glob`

Co-authored-by: absidue <[email protected]>

* Update lefthook.yml to use `yarn run` instead of `npx`

Co-authored-by: absidue <[email protected]>

Co-authored-by: absidue <[email protected]>
  • Loading branch information
PikachuEXE and absidue authored Aug 12, 2022
1 parent 180a89d commit ba0bcee
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
46 changes: 46 additions & 0 deletions lefthook.yml
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
"ytsr": "^3.8.0"
},
"devDependencies": {
"@arkweid/lefthook": "^0.7.7",
"@babel/core": "^7.17.10",
"@babel/plugin-proposal-class-properties": "^7.16.7",
"@babel/preset-env": "^7.17.10",
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
"@jridgewell/gen-mapping" "^0.1.0"
"@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/[email protected]":
version "7.12.11"
resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.12.11.tgz#f4ad435aa263db935b8f10f2c552d23fb716a63f"
Expand Down

0 comments on commit ba0bcee

Please sign in to comment.