@@ -68,7 +68,9 @@ setup_pre_commit_config() {
6868 if [[ ! -f " $file " ]]; then
6969 cat > " $file " << 'EOF '
7070repos:
71- ########## ✅ Precommit Hooks #########
71+ # ==========================================
72+ # Pre-commit default hooks
73+ # ==========================================
7274 - repo: https://github.com/pre-commit/pre-commit-hooks
7375 rev: v4.4.0
7476 hooks:
@@ -81,55 +83,48 @@ repos:
8183 - id: destroyed-symlinks
8284 - id: pretty-format-json
8385
84- ########## ✅ golang fmt and go tidey #########
86+ # ==========================================
87+ # Golang hooks
88+ # ==========================================
8589 - repo: https://github.com/TekWizely/pre-commit-golang
8690 rev: v1.0.0-rc.1
8791 hooks:
8892 - id: go-fmt
8993 args: [-w]
90- - id: go-mod-tidy # Ensure go.mod & go.sum are tidy
94+ - id: go-mod-tidy
9195
96+ # ==========================================
97+ # Python formatting & linting
98+ # ==========================================
9299 - repo: https://github.com/psf/black
93100 rev: 23.9.1
94101 hooks:
95102 - id: black
96103 args: [--line-length=88]
97- # ✅ Import sorter (runs before Black)
104+
98105 - repo: https://github.com/PyCQA/isort
99106 rev: 5.12.0
100107 hooks:
101108 - id: isort
102109 args: ["--profile=black"]
103110
104- # ✅ Linter (flake8 for code quality)
105111 - repo: https://github.com/pycqa/flake8
106112 rev: 6.1.0
107113 hooks:
108114 - id: flake8
109115 args:
110116 - --max-line-length=88
111117 - --extend-ignore=E203,W503
112- additional_dependencies:
113- - flake8-bugbear
114- - flake8-comprehensions
115- - flake8-docstrings
116- # ✅ Static code analysis for Python (pylint optional)
117- - repo: https://github.com/pycqa/pylint
118- rev: v3.2.6
119- hooks:
120- - id: pylint
121- args: ["--disable=C0114,C0115,C0116"]
122- additional_dependencies:
123- - pylint-django
124- - pylint-flask
125- # ✅ Terraform docs
118+
119+ # ==========================================
120+ # Terraform hooks
121+ # ==========================================
126122 - repo: https://github.com/terraform-docs/terraform-docs
127123 rev: "v0.16.0"
128124 hooks:
129125 - id: terraform-docs-go
130- args: ["markdown", "table", "--output-file", "README.md", "./"]
126+ args: ["markdown", "table", "--output-file", "README.md", "./"]
131127
132- # ✅ Terraform precommit
133128 - repo: https://github.com/antonbabenko/pre-commit-terraform
134129 rev: "v1.74.1"
135130 hooks:
@@ -138,34 +133,36 @@ repos:
138133 - id: terraform_tflint
139134 - id: terraform_tfsec
140135
141- # ✅ Stylelint
142- - repo: https://github.com/thibaudcolas/pre-commit-stylelint
143- rev: v14.4.0
144- hooks:
145- # - id: stylelint
146- # files: \.(css|scss)$
147- # exclude: "node_modules/"
148- # additional_dependencies:
149- # - stylelint
150- # - stylelint-config-standard
151- # args: ['--config', '.stylelintrc.json', '--fix']
152- - id: stylelint
153- args: [--fix]
154-
155- # ✅ Codespell
136+ # ==========================================
137+ # Codespell
138+ # ==========================================
156139 - repo: https://github.com/codespell-project/codespell
157140 rev: v2.2.5
158141 hooks:
159142 - id: codespell
160143 files: ^.*\.(py|c|h|md|rst|yml|go|sh|sql|tf|yaml)$
161144 args: ["--ignore-words-list", "hist,nd"]
162- # ✅ Gitleaks
145+
146+ # ==========================================
147+ # Gitleaks
148+ # ==========================================
163149 - repo: https://github.com/gitleaks/gitleaks
164150 rev: v8.21.0
165151 hooks:
166- - id: gitleaks
152+ - id: gitleaks
167153 args: ["detect", "--verbose"]
168- verbose: true
154+
155+ # ==========================================
156+ # FIXED STYLELINT HOOK (No nodeenv)
157+ # ==========================================
158+ - repo: local
159+ hooks:
160+ - id: stylelint
161+ name: stylelint
162+ entry: npx stylelint --fix
163+ language: system
164+ types: [css, scss]
165+ exclude: "node_modules/|dist/|build/"
169166EOF
170167
171168 log " INFO" " Pre-commit config created."
0 commit comments