Files
owncast/lefthook.yml
T
Gabe KangasandGitHub d80a7246e1 Split out tools from main go.mod into tools/ (#4734)
* Split out tools from main go.mod into tools/ and create Makefile to support running them manually

* chore(ci): linter error

* fix(ci): fix the pre-commit and pre-push hooks
2026-01-13 16:17:35 -08:00

81 lines
2.3 KiB
YAML

# This is the configuration file for pre-push and pre-commit hooks that can
# be optionally run to assist in Owncast development.
# This file should be placed in the root of the Owncast repository.
# It will perform code linting, formatting, run tests, and other checks.
#
# To enable, run:
# make install-hooks
#
# To learn more: https://lefthook.dev/usage/commands.html#lefthook-install
#
# To test the install run: ./bin/lefthook run test
# And you should see the Go and JS tests run.
pre-push:
parallel: true
commands:
web-build:
root: web/
run: npm run build
pre-commit:
parallel: true
commands:
js-linter:
glob: '*.{js,ts,jsx,tsx}'
root: web/
run: npx --yes eslint --fix --ext {staged_files}
stage_fixed: true
prettier:
glob: '*.{js,ts,jsx,tsx,css,scss}'
run: npx --yes prettier --write {staged_files}
staged_fixed: true
css-linter:
glob: '*.{css,scss}'
root: web/
run: npx --yes stylelint --fix {staged_files}
stage_fixed: true
js-unused:
glob: '*.{js,ts,jsx,tsx}'
root: web/
run: npx --yes knip --include dependencies,files,exports
go-fmt:
glob: '*.go'
run: GOBIN=$(pwd)/bin go install -C tools mvdan.cc/gofumpt && ./bin/gofumpt -l -w {staged_files}
stage_fixed: true
golangci-lint:
glob: '*.go'
run: GOBIN=$(pwd)/bin go install -C tools github.com/golangci/golangci-lint/v2/cmd/golangci-lint && ./bin/golangci-lint run ./...
go-test:
glob: '*.go'
run: go test ./... > /dev/null
js-test:
glob: '*.{js,ts,jsx}'
root: web/
run: npm test
test:
parallel: true
commands:
web:
root: web/
run: npm test
go:
run: go test ./... > /dev/null
lint:
parallel: true
commands:
golangci-lint:
glob: '*.go'
run: GOBIN=$(pwd)/bin go install -C tools github.com/golangci/golangci-lint/v2/cmd/golangci-lint && ./bin/golangci-lint run ./...
# Validate commit messages per https://www.conventionalcommits.org/en/v1.0.0/
# Install commitlint into your global npm path if you want to use it.
# npm install -g @commitlint/{config-conventional,cli}
commit-msg:
commands:
'lint commit message':
run: if command -v commitlint >/dev/null 2>&1; then commitlint --edit {1}; fi