-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add prek pre-commit setup and enhance mise integration #152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| # prek / pre-commit configuration | ||
| # Install: uv run prek install --overwrite | ||
| # Run: uv run prek run --all-files | ||
| # See https://github.com/jdx/prek and https://pre-commit.com | ||
|
|
||
| repos: | ||
| - repo: https://github.com/pre-commit/pre-commit-hooks | ||
| rev: v5.0.0 | ||
| hooks: | ||
| - id: trailing-whitespace | ||
| exclude: ^(lists/(releases|external)/|Filters/|userscripts/dist/) | ||
| - id: end-of-file-fixer | ||
| exclude: ^(lists/(releases|external)/|Filters/|userscripts/dist/) | ||
| - id: check-yaml | ||
| - id: check-added-large-files | ||
| args: [--maxkb=1024] | ||
| - id: check-merge-conflict | ||
| - id: mixed-line-ending | ||
| args: [--fix=lf] | ||
|
|
||
| - repo: local | ||
| hooks: | ||
| # Python: ruff linter (auto-fix) | ||
| - id: ruff-check | ||
| name: ruff check | ||
| entry: uv run ruff check --fix | ||
| language: system | ||
| types: [python] | ||
|
|
||
| # Python: ruff formatter | ||
| - id: ruff-format | ||
| name: ruff format | ||
| entry: uv run ruff format | ||
| language: system | ||
| types: [python] | ||
|
|
||
| # Python: unit tests (run when Scripts/*.py files change) | ||
| - id: python-tests | ||
| name: Python unit tests | ||
| entry: python3 -m unittest discover -s Scripts/ -p test_*.py | ||
| language: system | ||
| pass_filenames: false | ||
| files: ^Scripts/.*\.py$ | ||
|
|
||
| # JavaScript: ESLint | ||
| - id: eslint | ||
| name: ESLint | ||
| entry: bun run lint:eslint | ||
| language: system | ||
| types_or: [javascript, jsx, ts, tsx] | ||
| pass_filenames: false | ||
|
|
||
| # JavaScript/JSON: Biome formatter | ||
| - id: biome | ||
| name: Biome format | ||
| entry: bun run format | ||
| language: system | ||
| types_or: [javascript, jsx, ts, tsx, json] | ||
| pass_filenames: false | ||
|
|
||
| # Filter lists: AGLint | ||
| - id: aglint | ||
| name: AGLint | ||
| entry: bun run lint:aglint | ||
| language: system | ||
| files: ^lists/(sources|adblock|hostlist)/.*\.txt$ | ||
| pass_filenames: false | ||
|
|
||
| # Shell: shellcheck | ||
| - id: shellcheck | ||
| name: shellcheck | ||
| entry: shellcheck | ||
| language: system | ||
| types: [shell] | ||
| args: [--severity=warning] | ||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -1,5 +1,11 @@ | ||||||||
| # Run tests | ||||||||
| python3 -m unittest discover Scripts/ 'test_*.py' | ||||||||
| #!/usr/bin/env bash | ||||||||
| # Run pre-commit hooks via prek | ||||||||
| # Usage: ./run_pre_commit.sh [--all-files] | ||||||||
| set -Eeuo pipefail | ||||||||
|
|
||||||||
| # Test actual script | ||||||||
| python3 Scripts/deduplicate.py | ||||||||
| if command -v uv >/dev/null 2>&1; then | ||||||||
| uv run prek run "${@}" | ||||||||
| else | ||||||||
| # Fallback: run checks manually if uv/prek is unavailable | ||||||||
| python3 -m unittest discover -s Scripts/ -p 'test_*.py' | ||||||||
|
||||||||
| python3 -m unittest discover -s Scripts/ -p 'test_*.py' | |
| python3 -m unittest discover -s Scripts/ -p 'test_*.py' | |
| python3 Scripts/deduplicate.py |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR description says the generated dirs are excluded for these hooks, but the config only applies
exclude:totrailing-whitespaceandend-of-file-fixer. As written,check-added-large-files/check-merge-conflict/mixed-line-endingwill still run (and potentially fail/modify) onlists/releases/,lists/external/,Filters/, anduserscripts/dist/. Consider adding the sameexclude:to the remaining relevant hooks, or add a top-levelexclude:so the exclusion is applied consistently to all hooks.