Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Husky and lint-staged for better codestyle checks on commit #136

Merged
merged 4 commits into from
Jul 25, 2019
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
13 changes: 1 addition & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,10 @@ outro:
# Main commands
# ===========================

init: intro do-pre-init do-install-git-hooks do-run-updates do-show-commands outro
init: intro do-pre-init do-run-updates do-show-commands outro
update-project: intro do-run-updates outro
update: intro do-switch-branch do-run-updates outro
github: intro do-checkout-pr do-run-updates outro
git-hooks: intro do-install-git-hooks outro
eXistenZNL marked this conversation as resolved.
Show resolved Hide resolved

build-docs: intro do-build-docs outro
preview-docs: intro do-preview-docs outro
Expand All @@ -47,7 +46,6 @@ run-container-slave: intro do-run-container-slave outro
inspect-container: intro do-inspect-container outro
inspect-container-slave: intro do-inspect-container-slave outro

pre-commit: intro do-test-eslint-prettier do-commit-intro
fix: intro do-fix-eslint-prettier outro

test: intro do-test-eslint-prettier do-test-jest outro
Expand All @@ -65,7 +63,6 @@ do-show-commands:
@echo " make update-project Install all dependencies and generate required files."
@echo " make update BRANCH=<branch> Switch to a branch and run update-project."
@echo " make github PR=<number> Check out a PR from github and update the project."
@echo " make git-hooks Install the available git hooks."
@echo " make fix Fix most of the codestyle errors."
@echo "\nLocal installation:"
@echo " make build-production Build all the files required for production."
Expand Down Expand Up @@ -149,14 +146,6 @@ do-fix-eslint-prettier:
@(node_modules/.bin/eslint --fix --ext .js,.vue,.json . && echo "Code style is cleaned ❤️") ||\
echo "\nNot everything could be fixed automatically, please check the errors above."

do-commit-intro:
@echo "\n=== Committing ===\n"

do-install-git-hooks:
@echo "\n=== Installing git hooks ===\n"
cp dev/git-hooks/* .git/hooks
chmod +x .git/hooks/*

do-cypress-open:
@echo "\n=== Opening Cypress dashboard ===\n"
./node_modules/.bin/cypress open
Expand Down
3 changes: 0 additions & 3 deletions dev/git-hooks/pre-commit

This file was deleted.

15 changes: 14 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
"eslint-plugin-json": "^1.2.1",
"eslint-plugin-prettier": "^3.0.0",
"eslint-plugin-vue": "^4.7.1",
"jest": "^24.7.1"
"husky": "^3.0.0",
"jest": "^24.7.1",
"lint-staged": ">=8"
},
"scripts": {
"dev": "NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
Expand All @@ -59,5 +61,16 @@
"vue-socket.io-extended": "^3.1.0",
"vuex": "^3.0.1",
"vuex-persistedstate": "^2.5.4"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"*.js": [
"eslint --fix --ext .js,.vue,.json",
"git add"
]
}
}
Loading