Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions .pre-commit-config.yaml
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
Comment on lines +15 to +18
Copy link

Copilot AI Mar 9, 2026

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: to trailing-whitespace and end-of-file-fixer. As written, check-added-large-files / check-merge-conflict / mixed-line-ending will still run (and potentially fail/modify) on lists/releases/, lists/external/, Filters/, and userscripts/dist/. Consider adding the same exclude: to the remaining relevant hooks, or add a top-level exclude: so the exclusion is applied consistently to all hooks.

Suggested change
- id: check-added-large-files
args: [--maxkb=1024]
- id: check-merge-conflict
- id: mixed-line-ending
- id: check-added-large-files
exclude: ^(lists/(releases|external)/|Filters/|userscripts/dist/)
args: [--maxkb=1024]
- id: check-merge-conflict
exclude: ^(lists/(releases|external)/|Filters/|userscripts/dist/)
- id: mixed-line-ending
exclude: ^(lists/(releases|external)/|Filters/|userscripts/dist/)

Copilot uses AI. Check for mistakes.
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]
12 changes: 11 additions & 1 deletion mise.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,17 @@ BINSTALL_DISABLE_TELEMETRY = "true"

[tasks.install]
description = "Install all dependencies"
run = "mise install && bun install"
run = "mise install && bun install && uv sync"

[tasks."precommit:install"]
description = "Install prek as git pre-commit hook"
run = "uv run prek install --overwrite"
depends = ["install"]

[tasks."precommit:run"]
description = "Run pre-commit hooks on all files"
run = "uv run prek run --all-files"
depends = ["install"]

[tasks.build]
description = "Build all lists"
Expand Down
14 changes: 10 additions & 4 deletions run_pre_commit.sh
100644 → 100755
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'
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wrapper no longer runs python3 Scripts/deduplicate.py (which the prior version executed as “Test actual script”). If running deduplicate.py is still intended as part of the pre-commit workflow, it should be added as a dedicated pre-commit hook (preferred) or included in the fallback path so behavior remains consistent when developers use this script.

Suggested change
python3 -m unittest discover -s Scripts/ -p 'test_*.py'
python3 -m unittest discover -s Scripts/ -p 'test_*.py'
python3 Scripts/deduplicate.py

Copilot uses AI. Check for mistakes.
fi
Loading