2020-06-04 17:41:04 +00:00
|
|
|
# use with https://github.com/casey/just
|
|
|
|
|
2020-06-11 02:52:11 +00:00
|
|
|
# fix auto-fixable lint issues in staged files
|
2020-06-04 17:41:04 +00:00
|
|
|
fix:
|
2020-06-11 02:52:11 +00:00
|
|
|
FORMAT= pre-commit run go-returns # fixes all Go lint issues
|
|
|
|
pre-commit run prettier # fixes all Markdown (& other) lint issues
|
2020-06-04 17:41:04 +00:00
|
|
|
|
2020-06-04 19:30:56 +00:00
|
|
|
# lint most common issues in - or due - to staged files
|
2020-06-04 17:41:04 +00:00
|
|
|
lint:
|
2020-06-04 19:47:11 +00:00
|
|
|
pre-commit run go-vet-mod || true # runs go vet
|
|
|
|
pre-commit run go-lint || true # runs golint
|
2020-06-04 17:41:04 +00:00
|
|
|
|
2020-06-04 19:30:56 +00:00
|
|
|
# lint all issues in - or due - to staged files
|
2020-06-04 17:41:04 +00:00
|
|
|
lint-all:
|
2020-06-04 19:47:11 +00:00
|
|
|
pre-commit run golangci-lint-mod || true # runs golangci-lint
|
2020-06-04 19:30:56 +00:00
|
|
|
|
|
|
|
# run tests in - or due - to staged files
|
|
|
|
test:
|
2020-06-04 19:47:11 +00:00
|
|
|
pre-commit run go-test-mod || true # runs go test
|
2020-06-04 17:41:04 +00:00
|
|
|
|
|
|
|
# commit skipping pre-commit hooks
|
|
|
|
commit m:
|
|
|
|
git commit --no-verify -m "{{m}}"
|
|
|
|
|
|
|
|
# amend skipping pre-commit hooks
|
|
|
|
amend:
|
|
|
|
git commit --amend --no-verify
|
|
|
|
|
2020-06-04 19:30:56 +00:00
|
|
|
# install/update code automation (prettier, pre-commit, goreturns, lintpack, gocritic, golangci-lint)
|
|
|
|
install:
|
2020-06-04 17:41:04 +00:00
|
|
|
npm i -g prettier
|
|
|
|
curl https://pre-commit.com/install-local.py | python3 -
|
|
|
|
go get github.com/sqs/goreturns
|
2020-06-04 19:30:56 +00:00
|
|
|
go get github.com/go-lintpack/lintpack/...
|
|
|
|
go get github.com/go-critic/go-critic/...
|
2020-06-04 19:47:11 +00:00
|
|
|
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $(go env GOPATH)/bin v1.27.0
|
2020-06-04 19:30:56 +00:00
|
|
|
|
2020-06-04 19:47:11 +00:00
|
|
|
# setup/update pre-commit hooks (optional)
|
2020-06-04 19:30:56 +00:00
|
|
|
setup:
|
2020-06-04 19:47:11 +00:00
|
|
|
pre-commit install --install-hooks # uninstall: `pre-commit uninstall`
|