sourcegraph/.pre-commit-config.yaml
Noah S-C bc97fdbe34
add shellcheck & shfmt to pre-commit's pre-push hook (#59485)
Closes https://github.com/sourcegraph/sourcegraph/issues/54829

Next steps: 
- what safeguards will we have in place for when we remove this from `sg lint`
- should we remove it from `sg lint`, its likely not contributing much overhead even in the uncommon case of shell files being touched

_How did some of these violations get in when theres shell lints :clueless:_

## Test plan

`pre-commit run --hook-stage=pre-push shellcheck shfmt`
2024-01-11 14:16:22 +00:00

44 lines
1.3 KiB
YAML

exclude: (^.*\.snap$)|(^internal/database/.*\.json)|(^internal/database/.*\.md)|(^migrations/[^/]+/squashed\.sql)
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/keith/pre-commit-buildifier
rev: 5.0.1
hooks:
- id: buildifier
- id: buildifier-lint
- repo: local
hooks:
- id: check-tokens
name: check-tokens
description: 'Check for common tokens being committed'
entry: ./dev/check-tokens.sh
language: script
'types': [text]
args: []
require_serial: false
- id: shellcheck
name: shellcheck
description: 'Run shellcheck'
entry: ./dev/check/shellcheck.sh
language: script
# TODO: adapt shellcheck.sh to only operate on passed-in files,
# and fallback to git ls-files when empty
pass_filenames: false
files: '.*\.(sh|bash)'
stages: [pre-push]
- id: shfmt
name: shfmt
description: 'Run shfmt'
entry: ./dev/check/shfmt.sh
language: script
# TODO: adapt shfmt.sh to only operate on passed-in files,
# and fallback to git ls-files when empty
pass_filenames: false
files: '.*\.(sh|bash)'
stages: [pre-push]