diff --git a/CLAUDE.md b/CLAUDE.md index b0f9d16..8eaa7b2 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -2,13 +2,17 @@ ## Project Overview -A collection of reusable git hook scripts for automating code quality checks. Main focus: PHP/Laravel (PHPStan, Pint), shell script validation (ShellCheck), Docker linting, and commit message enhancement. +A collection of reusable git hook scripts for automating code quality checks. Covers JavaScript/TypeScript, Python, PHP/Laravel, CSS, HTML, Markdown, YAML, Docker, and shell scripts. ## Directory Structure ``` +css/ # CSS/SCSS/Less hooks +├── check_stylelint.sh # Stylelint for staged files +└── check_stylelint_all.sh # Stylelint for entire project + docker/ # Docker-related hooks -├── check_hadolint.sh # Dockerfile linter +└── check_hadolint.sh # Dockerfile linter git/ # Git workflow hooks ├── check_branch_name.sh # Branch naming convention validator @@ -16,6 +20,26 @@ git/ # Git workflow hooks ├── add_task_id_in_commit.sh └── prepare-commit-description.sh +html/ # HTML hooks +├── check_htmlhint.sh # HTMLHint for staged files +└── check_htmlhint_all.sh # HTMLHint for entire project + +javascript/ # JavaScript/TypeScript hooks +├── check_eslint_all.sh # ESLint across the project +├── check_prettier.sh # Prettier on staged files +├── check_prettier_all.sh # Prettier on all TS files +├── check_tsc_all.sh # TypeScript type checking +├── check_vitest.sh # Vitest runner +├── check_vitest_all.sh # Full Vitest suite +├── check_tests.sh # Vitest for changed files +├── check_tests_all.sh # Full Vitest suite (wrapper) +├── check_test_coverage.sh # Vitest with coverage +└── check_tests_exist.sh # Test file existence validator + +markdown/ # Markdown hooks +├── check_markdownlint.sh # markdownlint for staged files +└── check_markdownlint_all.sh # markdownlint for entire project + php/ # PHP/Laravel hooks ├── check_phpstan.sh # PHPStan with progressive error reduction ├── find_test.sh # Unit test coverage validator @@ -23,6 +47,15 @@ php/ # PHP/Laravel hooks └── laravel/ └── check_pint.sh # Laravel Pint code style fixer +python/ # Python hooks +├── check_flake8.sh # Flake8 linting (local) +├── check_flake8_in_docker.sh # Flake8 (Docker) +├── check_mypy.sh # Mypy type checking (local) +├── check_mypy_in_docker.sh # Mypy (Docker) +├── check_pytest.sh # Pytest (local) +├── check_pytest_in_docker.sh # Pytest (Docker) +└── find_test.sh # Service test existence validator + shell/ # Shell script validation └── check_shellcheck.sh # ShellCheck via Docker @@ -30,10 +63,20 @@ scripts/ # Local utility scripts ├── check_shellcheck.sh # ShellCheck (local execution) └── pre-commit-check.sh # Pre-commit orchestrator +yml/ # YAML hooks +├── check_yamllint.sh # yamllint for staged files +└── check_yamllint_all.sh # yamllint for entire project + tests/ # Test framework ├── run_all.sh # Run all test suites ├── lib/test_helper.bash # Test utilities and assertions -└── php/phpstan/ # PHPStan hook tests +├── css/ # CSS hook tests +├── html/ # HTML hook tests +├── javascript/ # JavaScript hook tests +├── markdown/ # Markdown hook tests +├── php/ # PHP hook tests +├── python/ # Python hook tests +└── yml/ # YAML hook tests ``` ## Script Conventions @@ -67,7 +110,13 @@ Every script must start with a description block after the shebang: ## Dependencies - Bash 4.0+, Git, jq +- Node.js with npx (for JavaScript/TypeScript, CSS, HTML hooks) +- Python 3, Flake8, Mypy, Pytest (for Python hooks) - PHP 8.1+, Composer (for PHPStan/Pint) +- Stylelint via npx (for CSS hooks) +- HTMLHint via npx (for HTML hooks) +- markdownlint-cli (for Markdown hooks) +- yamllint (for YAML hooks) - Docker (optional, for containerized checks) - ShellCheck (for shell validation) diff --git a/README.md b/README.md index c72e616..7098442 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,10 @@ A collection of reusable git hook scripts for automating code quality checks and - **JavaScript/TypeScript**: ESLint, Prettier, TypeScript type checking, Vitest test runner, test existence validation - **Python**: Flake8 linting, Mypy static analysis, Pytest runner, service test validation (local and Docker modes) - **PHP/Laravel**: PHPStan analysis with progressive error reduction, Pint code style fixing, test coverage validation +- **CSS/SCSS/Less**: Stylelint code style validation +- **HTML**: HTMLHint linting +- **Markdown**: markdownlint style validation +- **YAML**: yamllint style validation - **Docker**: Dockerfile linting with Hadolint - **Shell**: Script validation with ShellCheck - **Git**: Branch naming conventions, automatic task ID injection in commits @@ -55,6 +59,34 @@ A collection of reusable git hook scripts for automating code quality checks and | `php/find_test.sh` | Validates that modified PHP classes have corresponding unit tests. | | `php/start_test_in_docker.sh` | Runs PHPUnit tests inside Docker for modified files. | +### CSS / SCSS / Less + +| Script | Description | +|--------|-------------| +| `css/check_stylelint.sh` | Runs Stylelint on staged CSS/SCSS/Less files passed as arguments. | +| `css/check_stylelint_all.sh` | Runs Stylelint on all CSS/SCSS/Less files in the project. Used in pre-push hooks. | + +### HTML + +| Script | Description | +|--------|-------------| +| `html/check_htmlhint.sh` | Runs HTMLHint on staged HTML files passed as arguments. | +| `html/check_htmlhint_all.sh` | Runs HTMLHint on all HTML files in the project. Used in pre-push hooks. | + +### Markdown + +| Script | Description | +|--------|-------------| +| `markdown/check_markdownlint.sh` | Runs markdownlint on staged `.md` files passed as arguments. | +| `markdown/check_markdownlint_all.sh` | Runs markdownlint on all `.md` files in the project. Used in pre-push hooks. | + +### YAML + +| Script | Description | +|--------|-------------| +| `yml/check_yamllint.sh` | Runs yamllint on staged `.yml`/`.yaml` files passed as arguments. | +| `yml/check_yamllint_all.sh` | Runs yamllint on all `.yml`/`.yaml` files in the project. Used in pre-push hooks. | + ### Git Workflow | Script | Description | @@ -138,6 +170,46 @@ A collection of reusable git hook scripts for automating code quality checks and ./php/check_phpstan.sh strict src/Service.php ``` +### CSS / SCSS / Less + +```bash +# Check staged files +./css/check_stylelint.sh styles/main.css components/button.scss + +# Check all files in the project +./css/check_stylelint_all.sh +``` + +### HTML + +```bash +# Check staged files +./html/check_htmlhint.sh templates/index.html templates/layout.html + +# Check all files in the project +./html/check_htmlhint_all.sh +``` + +### Markdown + +```bash +# Check staged files +./markdown/check_markdownlint.sh README.md docs/guide.md + +# Check all files in the project +./markdown/check_markdownlint_all.sh +``` + +### YAML + +```bash +# Check staged files +./yml/check_yamllint.sh .github/workflows/ci.yml docker-compose.yml + +# Check all files in the project +./yml/check_yamllint_all.sh +``` + ### Branch Name Validation ```bash @@ -188,6 +260,18 @@ bash python/find_test.sh $FILES PHP_FILES=$(echo "$FILES" | grep '\.php$' || true) [[ -n "$PHP_FILES" ]] && bash php/check_phpstan.sh default $PHP_FILES +# CSS/SCSS/Less +bash css/check_stylelint.sh $FILES + +# HTML +bash html/check_htmlhint.sh $FILES + +# Markdown +bash markdown/check_markdownlint.sh $FILES + +# YAML +bash yml/check_yamllint.sh $FILES + # Shell SH_FILES=$(echo "$FILES" | grep '\.sh$' || true) [[ -n "$SH_FILES" ]] && bash scripts/check_shellcheck.sh $SH_FILES @@ -207,6 +291,14 @@ SH_FILES=$(echo "$FILES" | grep '\.sh$' || true) ./tests/python/flake8/run.sh ./tests/python/mypy/run.sh ./tests/python/find_test/run.sh +./tests/css/stylelint/run.sh +./tests/css/stylelint_all/run.sh +./tests/html/htmlhint/run.sh +./tests/html/htmlhint_all/run.sh +./tests/markdown/markdownlint/run.sh +./tests/markdown/markdownlint_all/run.sh +./tests/yml/yamllint/run.sh +./tests/yml/yamllint_all/run.sh ``` ## Requirements @@ -214,9 +306,13 @@ SH_FILES=$(echo "$FILES" | grep '\.sh$' || true) - Bash 4.0+ - Git - jq -- Node.js with npx (for JavaScript/TypeScript hooks) +- Node.js with npx (for JavaScript/TypeScript, CSS, HTML hooks) - Python 3, Flake8, Mypy, Pytest (for Python hooks) - PHP 8.1+ with Composer (for PHP hooks) +- Stylelint (`npm install -g stylelint`) or via `npx` +- HTMLHint (`npm install -g htmlhint`) or via `npx` +- markdownlint-cli (`npm install -g markdownlint-cli`) +- yamllint (`pip install yamllint` or system package) - Docker (optional, for Docker-based hooks) - ShellCheck (for shell validation)