diff --git a/.eslintrc.yml b/.eslintrc.yml index 271427fe3..7a5c6a7db 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -11,8 +11,8 @@ extends: - prettier globals: - OC: - t: + OC: readonly + t: readonly rules: no-plusplus: diff --git a/.gitignore b/.gitignore index 461ea6db9..ba61fd728 100755 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ cookbook.tar.gz .idea/ /.php-cs-fixer.cache +/.eslintcache # Built js package js/* diff --git a/.hooks/pre-commit b/.hooks/pre-commit index 7707579bf..703e05ae3 100755 --- a/.hooks/pre-commit +++ b/.hooks/pre-commit @@ -14,20 +14,6 @@ cleanup() { trap cleanup EXIT -if [ -e 'vendor/bin/php-cs-fixer' ]; then - - composer cs:check || { echo "The PHP code is not validly formatted."; exit 1; } - -fi - if [ -e 'node_modules/.bin/eslint' ]; then - npm run eslint || { echo 'The javascript code seems to be not satifying the eslint linter.'; exit 2; } -fi - -if [ -e 'node_modules/.bin/prettier' ]; then - npm run prettier || { echo 'The javascript code seems to be not satifying the prettier code styler.'; exit 3; } -fi - -if [ -e 'node_modules/.bin/stylelint' ]; then - npm run stylelint || { echo 'The CSS code seems to be not satifying the stylelint linter.'; exit 4; } + npm run --silent eslint || { echo 'The javascript code seems to be not satifying the eslint linter.'; exit 1; } fi diff --git a/.hooks/pre-push b/.hooks/pre-push new file mode 100755 index 000000000..7707579bf --- /dev/null +++ b/.hooks/pre-push @@ -0,0 +1,33 @@ +#!/bin/sh + +# set -x + +lines_before=`git stash list | wc -l` +git stash push --keep-index -q +lines_after=`git stash list | wc -l` + +cleanup() { + if [ $lines_before -lt $lines_after ]; then + git stash pop -q + fi +} + +trap cleanup EXIT + +if [ -e 'vendor/bin/php-cs-fixer' ]; then + + composer cs:check || { echo "The PHP code is not validly formatted."; exit 1; } + +fi + +if [ -e 'node_modules/.bin/eslint' ]; then + npm run eslint || { echo 'The javascript code seems to be not satifying the eslint linter.'; exit 2; } +fi + +if [ -e 'node_modules/.bin/prettier' ]; then + npm run prettier || { echo 'The javascript code seems to be not satifying the prettier code styler.'; exit 3; } +fi + +if [ -e 'node_modules/.bin/stylelint' ]; then + npm run stylelint || { echo 'The CSS code seems to be not satifying the stylelint linter.'; exit 4; } +fi diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e1980daf..8e4fd7a35 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,8 @@ [#848](https://github.com/nextcloud/cookbook/pull/848) @christianlupus - Update PHP CS-Fixer [#849](https://github.com/nextcloud/cookbook/pull/849) @christianlupus +- Update git hooks to not delay commits too much + [#851](https://github.com/nextcloud/cookbook/pull/851) @christianlupus ## 0.9.6 - 2021-10-18 diff --git a/package.json b/package.json index b8f477ae8..503a2284f 100644 --- a/package.json +++ b/package.json @@ -12,8 +12,8 @@ "prettier-fix": "npx prettier --write src", "stylelint": "npx stylelint src", "stylelint-fix": "npx stylelint --fix src", - "eslint": "npx eslint src/**/*.{vue,js}", - "eslint-fix": "npx eslint --fix src/**/*.{vue,js}" + "eslint": "npx eslint --cache --cache-strategy content src/**/*.{vue,js}", + "eslint-fix": "npx eslint --cache --cache-strategy content --fix src/**/*.{vue,js}" }, "repository": { "type": "git",