Skip to content

Commit d89c747

Browse files
committed
chore: add pre-commit hooks and commitlint configuration
- Add comprehensive pre-commit configuration with hooks for: - Code quality checks (black, isort, pylint, codespell) - Security scanning (gitleaks) - Line ending and whitespace fixes - Add commitlint configuration with conventional commit format - Configure signed-off-by trailer requirement for commits Signed-off-by: Yihuang Yu <[email protected]>
1 parent 8a2c5df commit d89c747

File tree

2 files changed

+85
-0
lines changed

2 files changed

+85
-0
lines changed

.pre-commit-config.yaml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
default_install_hook_types: [pre-commit, commit-msg]
2+
default_stages: [pre-commit]
3+
repos:
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
rev: v6.0.0
6+
hooks:
7+
- id: check-added-large-files
8+
args: ['--maxkb=5120']
9+
- id: check-ast
10+
- id: check-yaml
11+
exclude: .cirrus.yml
12+
- id: detect-private-key
13+
- id: end-of-file-fixer
14+
- id: mixed-line-ending
15+
args: ['--fix=lf']
16+
- id: no-commit-to-branch
17+
- id: trailing-whitespace
18+
- repo: https://github.com/gitleaks/gitleaks
19+
rev: v8.28.0
20+
hooks:
21+
- id: gitleaks
22+
- repo: https://github.com/pycqa/isort
23+
rev: 6.1.0
24+
hooks:
25+
- id: isort
26+
args: ['--profile=black']
27+
- repo: https://github.com/psf/black
28+
rev: 25.9.0
29+
hooks:
30+
- id: black
31+
- repo: local
32+
hooks:
33+
- id: pylint
34+
entry: static-checks/check-lint
35+
language: script
36+
additional_dependencies:
37+
- pylint==4.0.0
38+
pass_filenames: false
39+
- repo: https://github.com/codespell-project/codespell
40+
rev: v2.4.1
41+
hooks:
42+
- id: codespell
43+
args: ['-I=spell.ignore']
44+
- repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
45+
rev: v9.23.0
46+
hooks:
47+
- id: commitlint
48+
additional_dependencies: ['@commitlint/config-conventional']
49+
stages: [commit-msg]

commitlint.config.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import type { UserConfig } from '@commitlint/types'
2+
3+
const config: UserConfig = {
4+
extends: ['@commitlint/config-conventional'],
5+
rules: {
6+
// Body
7+
'body-leading-blank': [2, 'always'],
8+
'body-empty': [0, 'never'],
9+
'body-min-length': [0, 'always', 1],
10+
'body-case': [0, 'always', 'lower-case'],
11+
12+
// Footer
13+
'footer-leading-blank': [2, 'always'],
14+
'footer-empty': [0, 'never'],
15+
'footer-max-length': [0, 'always', 72],
16+
17+
// Header
18+
'header-case': [0, 'always', 'lower-case'],
19+
'header-full-stop': [2, 'never', '.'],
20+
'header-max-length': [2, 'always', 72],
21+
'header-min-length': [2, 'always', 1],
22+
23+
// Scope / Subject
24+
'scope-case': [0, 'always', 'lower-case'],
25+
'subject-case': [0, 'always', 'lower-case'],
26+
'subject-empty': [0, 'never'],
27+
'subject-full-stop': [2, 'never', '.'],
28+
29+
// Signed-off-by
30+
'signed-off-by': [2, 'always', 'Signed-off-by:'],
31+
},
32+
helpUrl:
33+
'https://avocado-framework.readthedocs.io/en/latest/guides/contributor/chapters/styleguides.html#commit-style-guide',
34+
}
35+
36+
export default config

0 commit comments

Comments
 (0)