diff --git a/.githooks/pre-commit b/.githooks/pre-commit new file mode 100755 index 000000000..7e617c2c7 --- /dev/null +++ b/.githooks/pre-commit @@ -0,0 +1,3 @@ +#!/usr/bin/env sh + +npx --no-install lint-staged diff --git a/.husky/pre-commit b/.husky/pre-commit deleted file mode 100755 index 60599ae35..000000000 --- a/.husky/pre-commit +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -. "$(dirname "$0")/_/husky.sh" - -# Run lint-staged (will autofix and stage fixed files). -# Exit non-zero only if non-fixable problems remain. -npx --no-install lint-staged diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c52e4fba9..4949dde96 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -71,7 +71,7 @@ npm run watch ## Pre-commit hooks (automatic linting & autofix) 🔧 -We use Husky + lint-staged to run linters only on the files being committed. The hook will: +We use a native Git hook and lint-staged to run linters only on the files being committed. The hook will: - Run the appropriate autofix for the changed files (PHP, JS/TS, CSS/SCSS). - Automatically stage any files that were fixed so the fixes are included in the same commit. @@ -85,7 +85,7 @@ Files → actions (configured in this repository): Setup -1. Install node deps (this will also prepare Husky via the `prepare` script): +1. Install node deps. The `prepare` script configures Git to use this repository's hooks: ```shell npm install diff --git a/package-lock.json b/package-lock.json index 7f515745a..38d9f46b7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -62,7 +62,6 @@ "eslint-webpack-plugin": "^4.2.0", "glob": "^11.1.0", "globals": "^15.14.0", - "husky": "^8.0.0", "lint-staged": "^15.5.2", "mini-css-extract-plugin": "^2.9.2", "postcss": "^8.5.2", @@ -8626,22 +8625,6 @@ "node": ">=16.17.0" } }, - "node_modules/husky": { - "version": "8.0.3", - "resolved": "https://registry.npmjs.org/husky/-/husky-8.0.3.tgz", - "integrity": "sha512-+dQSyqPh4x1hlO1swXBiNb2HzTDN1I2IGLQx1GrBuiqFJfoMrnZWwVmatvSiO+Iz8fBUnf+lekwNo4c2LlXItg==", - "dev": true, - "license": "MIT", - "bin": { - "husky": "lib/bin.js" - }, - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/sponsors/typicode" - } - }, "node_modules/iconv-lite": { "version": "0.6.3", "license": "MIT", diff --git a/package.json b/package.json index 5de45643c..417d03066 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "test": "tests" }, "scripts": { - "prepare": "husky install", + "prepare": "git config core.hooksPath .githooks || true", "test:php": "WP_TESTS_DIR=./.wp-tests-lib src/vendor/bin/phpunit -c phpunit.xml", "test:php:watch": "npm run test:php -- --testdox", "test:playwright": "playwright test -c config/playwright/playwright.config.ts", @@ -105,7 +105,6 @@ "eslint-webpack-plugin": "^4.2.0", "glob": "^11.1.0", "globals": "^15.14.0", - "husky": "^8.0.0", "lint-staged": "^15.5.2", "mini-css-extract-plugin": "^2.9.2", "postcss": "^8.5.2",