diff --git a/frontend/.husky/pre-commit b/frontend/.husky/pre-commit new file mode 100755 index 000000000..e86b17393 --- /dev/null +++ b/frontend/.husky/pre-commit @@ -0,0 +1,6 @@ +# Git runs hooks from the repository root, and core.hooksPath is repo-wide. +# This is a Go + JS monorepo, so only run the frontend checks when the frontend +# dependencies are installed — this keeps backend-only commits from being blocked. +[ -d frontend/node_modules ] || exit 0 + +cd frontend && npx lint-staged diff --git a/frontend/package.json b/frontend/package.json index 9ede04107..6a4d5b838 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -128,16 +128,12 @@ "url": "git+https://github.com/mendersoftware/gui.git" }, "type": "module", - "husky": { - "hooks": { - "pre-commit": "lint-staged", - "post-commit": "sh ${MENDER_TESTING}/check_commits.sh" - } - }, "scripts": { + "prepare": "husky", "build": "rspack --mode production", "lint": "eslint .", "lint-fix": "eslint . --fix", + "format": "prettier --write \"src/js/**/*.{js,ts,jsx,tsx,less}\"", "format:check": "prettier --check \"src/js/**/*.{js,ts,jsx,tsx,less}\"", "serve": "rspack serve --mode development", "serve:mocked": "MOCKS=true rspack serve --mode development", @@ -154,6 +150,9 @@ }, "homepage": "https://mender.io/", "lint-staged": { - "*.js": "eslint --cache --fix" + "*.{js,ts,jsx,tsx}": [ + "eslint --cache --fix", + "prettier --write" + ] } }