-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.pre-commit-config.yaml
More file actions
113 lines (99 loc) · 4.07 KB
/
.pre-commit-config.yaml
File metadata and controls
113 lines (99 loc) · 4.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# Pre-commit hooks for dotfiles quality assurance
# See https://pre-commit.com for more information
repos:
# Built-in hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
# Basic file checks
- id: trailing-whitespace
exclude: '\.md$'
- id: end-of-file-fixer
- id: check-yaml
args: ['--unsafe']
- id: check-json
- id: check-toml
- id: check-xml
- id: check-merge-conflict
- id: check-case-conflict
- id: check-symlinks
- id: destroyed-symlinks
# Script checks
- id: check-executables-have-shebangs
- id: check-shebang-scripts-are-executable
# Security
- id: detect-private-key
- id: check-added-large-files
args: ['--maxkb=500']
# Text formatting
- id: mixed-line-ending
args: ['--fix=lf']
# Shell script formatting and linting
- repo: https://github.com/scop/pre-commit-shfmt
rev: v3.7.0-4
hooks:
- id: shfmt
args: [-w, -s, -i, '4', -ci]
- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.9.0.6
hooks:
- id: shellcheck
args: [-e, SC1090, -e, SC1091]
exclude: '^config/zsh/alias-reminder$'
# Markdown
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.37.0
hooks:
- id: markdownlint
args: ['--fix']
exclude: '^(docs/CHANGELOG\.md|docs/TECHNICAL_BLOG\.md)$'
# Local hooks for custom checks
- repo: local
hooks:
# Validate dotfiles structure
- id: validate-structure
name: Validate dotfiles structure
entry: make validate
language: system
pass_filenames: false
files: '^(install/|config/|bin/|Makefile).*'
# Check for hardcoded paths
- id: check-hardcoded-paths
name: Check for hardcoded paths
entry: bash -c 'if grep -rn "/usr/local\|/opt/homebrew\|/home/" --include="*.sh" --include="*.zsh" --include="*.bash" --exclude-dir=.git --exclude-dir=tests . config/zsh/ config/cli-tools/ 2>/dev/null | grep -v "\.template:" | grep -v "\.local:"; then echo "Found hardcoded paths - consider making them configurable"; exit 1; fi'
language: system
pass_filenames: false
# Check for TODO/FIXME comments in non-documentation files
- id: check-todos
name: Check for TODO/FIXME comments
entry: bash -c 'if grep -r "TODO\|FIXME\|XXX" --include="*.sh" --include="*.zsh" --include="*.lua" --exclude-dir=.git --exclude-dir=docs .; then echo "Found TODO/FIXME comments - consider addressing them"; exit 0; fi'
language: system
pass_filenames: false
# Validate aliases don't conflict with system commands
- id: check-alias-conflicts
name: Check for alias conflicts with system commands
entry: ./bin/check-alias-conflicts
language: system
pass_filenames: false
files: '^config/zsh/.*aliases.*'
# Check shell function naming conventions
- id: check-function-naming
name: Check function naming conventions
entry: bash -c 'if grep -E "^[a-z][a-zA-Z0-9_]*\(\)" config/zsh/functions 2>/dev/null | grep -E "[A-Z]"; then echo "Function names should use snake_case"; exit 1; fi'
language: system
pass_filenames: false
files: '^config/zsh/.*functions.*'
# Validate Git configuration (skip if template)
- id: validate-git-config
name: Validate Git configuration
entry: bash -c 'if [[ -f "config/git/gitconfig" ]] && [[ ! "$(head -5 config/git/gitconfig)" =~ \{\{ ]]; then git config --file=config/git/gitconfig --list >/dev/null; else echo "Skipping validation - template file or not generated yet"; fi'
language: system
pass_filenames: false
files: '^config/git/gitconfig$'
# Check for proper shebang in scripts
- id: check-shebang-consistency
name: Check shebang consistency
entry: bash -c 'find . -name "*.sh" -exec head -1 {} \; | sort | uniq -c | sort -nr | head -3'
language: system
pass_filenames: false
files: '\.sh$'