Skip to content

Commit

Permalink
Update README and lefthook
Browse files Browse the repository at this point in the history
  • Loading branch information
khleomix committed May 3, 2024
1 parent a40759b commit 89049ec
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 33 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,10 @@ From the command line, type any of the following to perform an action:
| ------- | ------ |
| `npm run a11y` | Triggers Pa11y CI for accessibility checks |
| `npm run build` | Builds production-ready assets for a deployment |
| `npm run format` | Fix all CSS, JS, MD, and PHP formatting errors automatically |
| `npm run lint` | Check all CSS, JS, MD, and PHP files for errors |
| `npm run format` | Fix all CSS, JS, and MD formatting errors automatically |
| `npm run format-php` | Fix all PHP formatting errors automatically |
| `npm run lint` | Check all CSS, JS, and MD files for errors |
| `npm run lint-php` | Check all PHP files for errors |
| `npm run report` | Gives detailed information on coding standards violations in PHP code |
| `npm run start` | Builds assets and starts Live Reload server |

Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
"wp-coding-standards/wpcs": "^3.1.0"
},
"scripts": {
"format-php": "./vendor/bin/phpcbf --report=summary,source --standard=WordPress --extensions=php --ignore=*/build/*,*/vendor/*,*/node_modules/* .",
"lint-php": "./vendor/bin/phpcs --standard=WordPress --extensions=php --report=summary,source --ignore=*/build/*,*/vendor/*,*/node_modules/* .",
"report": "./vendor/bin/phpcs --report=full --report-file=phpcs-report.txt --standard=WordPress --extensions=php --ignore=*/build/*,*/vendor/*,*/node_modules/* ."
"format-php": "./vendor/bin/phpcbf --report=summary,source",
"lint-php": "./vendor/bin/phpcs --report=summary,source",
"report": "./vendor/bin/phpcs --report=full --report-file=phpcs-report.txt"
}
}
30 changes: 2 additions & 28 deletions lefthook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ pre-commit:
commands:
formatphp:
glob: '*.php'
run: composer run format {staged_files}
run: composer run-script format-php {staged_files}
lintphp:
glob: '*.php'
run: composer run lint {staged_files}
run: composer run-script lint-php {staged_files}
formatstyles:
glob: '*.{css,scss}'
run: npx prettier {staged_files} --write
Expand Down Expand Up @@ -38,29 +38,3 @@ pre-commit:
templates-exclude:
glob: 'templates/**' # Match all files and subdirectories within templates folder
run: echo "Skipping templates folder"

pre-push:
parallel: true
commands:
a11y:
run: |
if [ "$LEFTHOOK_EVENT" = "push" ]; then
git diff --staged --name-only | grep -E '\.(html|htm)$' | xargs npm run a11y
fi
lintstyles:
run: |
if [ "$LEFTHOOK_EVENT" = "push" ]; then
git diff --staged --name-only | grep -E '\.(css|scss)$' | xargs npx stylelint --fix
fi
lintjavascript:
run: |
if [ "$LEFTHOOK_EVENT" = "push" ]; then
git diff --staged --name-only | grep -E '\.(js|ts|tsx)$' | xargs npx eslint --fix
fi
lintphp:
run: |
if [ "$LEFTHOOK_EVENT" = "push" ]; then
git diff --staged --name-only | grep -E '\.php$' | xargs composer run lint
fi
exit-status:
run: echo "All pre-push checks passed"

0 comments on commit 89049ec

Please sign in to comment.