diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index 1486e0599..699e8aadb 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -26,7 +26,7 @@ jobs: run: | npm cache clean -f npm install npm@latest -g - npm install --package-lock-only + npm install --package-lock-only --ignore-scripts npm ci && npm cache clean --force npm run build:all npm pack --workspaces diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 575752f48..7c409a8a7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,7 +20,7 @@ jobs: run: | npm cache clean -f npm install npm@latest -g - npm install --package-lock-only + npm install --package-lock-only --ignore-scripts npm ci && npm cache clean --force npm run build:all diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100755 index 000000000..abf1181ca --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,4 @@ +#!/usr/bin/env sh +. "$(dirname -- "$0")/_/husky.sh" + +npx lint-staged --allow-empty diff --git a/package.json b/package.json index 7085b4e18..1d3102274 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,19 @@ "test-only": "mocha 'test/**/*.[jt]s' 'dist/**/*.test.js'", "test": "npm run build && npm run test-only && npm run ci-lint", "heroku-postbuild": "npm run build:all", - "master-changed-files": "git diff --name-status $(git tag | tail -1)..master" + "master-changed-files": "git diff --name-status $(git tag | tail -1)..master", + "prepare": "husky install" + }, + "husky": { + "hooks": { + "pre-commit": "lint-staged" + } + }, + "lint-staged": { + "*.{js,jsx,ts,tsx,json,css,scss,md}": [ + "prettier --write", + "eslint --fix" + ] }, "bin": { "signalk-server": "./bin/signalk-server", @@ -161,7 +173,8 @@ "eslint-plugin-prefer-arrow": "^1.2.3", "eslint-plugin-react": "^7.37.5", "globals": "^16.0.0", - "lint-staged": "^10.0.3", + "husky": "^8.0.0", + "lint-staged": "^10.5.4", "mocha": "^10.2.0", "prettier": "^3.5.3", "rimraf": "^6.0.1",