Skip to content

Commit

Permalink
chore: implements code linting
Browse files Browse the repository at this point in the history
Configures ESLint, Stylelint and phpcbf
  • Loading branch information
Genyus committed Apr 26, 2023
1 parent 224b99a commit 0e6b0a3
Show file tree
Hide file tree
Showing 5 changed files with 1,254 additions and 40 deletions.
10 changes: 10 additions & 0 deletions .phpcbf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh

composer fix "$@"
status=$?

if [ $status -eq 1 ]; then
exit 0
else
exit "$status"
fi
8 changes: 5 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,11 @@
"post-update-cmd": [
"@configure-ssp"
],
"configure-ssp": "cd web/app/plugins/cbf-academy;composer install;cd ../../../..",
"lint": "phpcs --standard=phpcs.xml ./web/app/plugins/cbf-academy ./web/app/themes/cbf-academy ./web/app/themes/cbf-jobs",
"fix": "phpcbf --standard=phpcs.xml ./web/app/plugins/cbf-academy ./web/app/themes/cbf-academy ./web/app/themes/cbf-jobs",
"configure-ssp": "cd web/app/plugins/cbf-academy;@composer install;cd ../../../..",
"lint": "phpcs --standard=phpcs.xml",
"lint:all": "@lint ./web/app/plugins/cbf-academy ./web/app/themes/cbf-academy ./web/app/themes/cbf-jobs",
"fix": "phpcbf --standard=phpcs.xml",
"fix:all": "@fix ./web/app/plugins/cbf-academy ./web/app/themes/cbf-academy ./web/app/themes/cbf-jobs",
"test": [
"phpcs"
]
Expand Down
25 changes: 17 additions & 8 deletions lefthook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,21 @@ prepare-commit-msg:
commit-msg:
commands:
"lint commit message":
run: npm run commitlint --edit ${1}
run: npm run lint:commit --edit ${1}


# pre-commit:
# parallel: true
# commands:
# eslint:
# glob: "*.js"
# run: npm lint -- --fix {staged_files} && git add {staged_files}
# Use this to lint files before committing
pre-commit:
parallel: true
commands:
lintjs:
glob: "*.js"
run: npm run lint:js -- --fix {staged_files}
stage_fixed: true
lintcss:
glob: "*.{css,scss}"
run: npm run lint:css -- --fix {staged_files}
stage_fixed: true
lintphp:
glob: "*.php"
run: ./.phpcbf {staged_files}
stage_fixed: true
Loading

0 comments on commit 0e6b0a3

Please sign in to comment.