From 07d0c69ba3ef695d46fc70c28765f04e9b1af049 Mon Sep 17 00:00:00 2001 From: Jade Turner Date: Mon, 7 Sep 2026 00:58:17 +0800 Subject: [PATCH] Remove precommit hooks --- .husky/post-checkout | 3 --- .husky/pre-commit | 1 - .husky/pre-push | 5 ----- lint-staged.config.mjs | 42 ------------------------------------ package.json | 5 +---- pnpm-lock.yaml | 32 --------------------------- scripts/post-checkout.mjs | 34 ----------------------------- scripts/postinstall.ts | 22 ------------------- scripts/stamp.mjs | 27 ----------------------- scripts/syncLockfile.lint.ts | 13 ----------- 10 files changed, 1 insertion(+), 183 deletions(-) delete mode 100755 .husky/post-checkout delete mode 100644 .husky/pre-commit delete mode 100755 .husky/pre-push delete mode 100644 lint-staged.config.mjs delete mode 100644 scripts/post-checkout.mjs delete mode 100644 scripts/postinstall.ts delete mode 100644 scripts/stamp.mjs delete mode 100644 scripts/syncLockfile.lint.ts diff --git a/.husky/post-checkout b/.husky/post-checkout deleted file mode 100755 index 788cd335..00000000 --- a/.husky/post-checkout +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -node scripts/post-checkout.mjs "$1" "$2" "$3" diff --git a/.husky/pre-commit b/.husky/pre-commit deleted file mode 100644 index 5ee7abd8..00000000 --- a/.husky/pre-commit +++ /dev/null @@ -1 +0,0 @@ -pnpm exec lint-staged diff --git a/.husky/pre-push b/.husky/pre-push deleted file mode 100755 index 7c6f4a91..00000000 --- a/.husky/pre-push +++ /dev/null @@ -1,5 +0,0 @@ -if git diff --name-only @{u}..HEAD | grep -q '\.astro$'; then - astro check --minimumFailingSeverity warning -else - tsc --noEmit -fi \ No newline at end of file diff --git a/lint-staged.config.mjs b/lint-staged.config.mjs deleted file mode 100644 index 3202ba0c..00000000 --- a/lint-staged.config.mjs +++ /dev/null @@ -1,42 +0,0 @@ -import { platform } from 'node:process'; -import { resolve } from 'node:path'; - -const gradlew = resolve( - 'examples', - platform === 'win32' ? 'gradlew.bat' : 'gradlew', -); - -const runPrettierOn = - '**/*.{' + - [ - 'js', - 'mjs', - 'ts', - 'json', - 'json5', - 'jsonc', - 'css', - 'md', - 'mdx', - 'yaml', - 'yml', - 'astro', - ].join(',') + - '}'; - -/** @type {import('lint-staged').Configuration} */ -export default { - [runPrettierOn]: (files) => - `prettier --write --ignore-unknown ${files.join(' ')}`, - '{src,public}/**/*.{png,jpg,jpeg,webp}': (images) => - `node scripts/images.lint.js ${images.join(' ')}`, - '**/*.{astro,ts,mjs,js}': (files) => `eslint --fix ${files.join(' ')}`, - 'src/content/**/*.{md,mdx}': (files) => [ - `pnpm remark ${files.join(' ')} --ext mdx --frail --no-stdout --quiet`, - ], - 'examples/**/*.{java,gradle}': () => [ - `${gradlew} -p examples spotlessApply`, - ], - // Yes, I know this should be a FunctionTask but those are kinda bad until https://github.com/lint-staged/lint-staged/issues/1826 is resolved - 'package.json': () => 'pnpm tsx scripts/syncLockfile.lint.ts', -}; diff --git a/package.json b/package.json index fd40b90a..1d0ca260 100644 --- a/package.json +++ b/package.json @@ -32,8 +32,7 @@ "vale:setup": "tsx scripts/setup-vale.ts", "format": "prettier --write .", "format:check": "prettier --check .", - "typecheck": "astro check --minimumFailingSeverity warning", - "prepare": "husky" + "typecheck": "astro check --minimumFailingSeverity warning" }, "dependencies": { "@astrojs/markdown-remark": "^7.3.0", @@ -58,8 +57,6 @@ "eslint-plugin-astro": "^3.1.0", "fast-glob": "^3.3.3", "globals": "^17.12.0", - "husky": "^9.1.7", - "lint-staged": "^17.4.1", "mdast-util-mdx": "^3.0.0", "mdast-util-mdx-jsx": "^3.2.0", "mdx2vast": "^0.5.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e4f472f1..99c549de 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -170,12 +170,6 @@ importers: globals: specifier: ^17.12.0 version: 17.12.0 - husky: - specifier: ^9.1.7 - version: 9.1.7 - lint-staged: - specifier: ^17.4.1 - version: 17.4.1 mdast-util-mdx: specifier: ^3.0.0 version: 3.0.0(supports-color@10.2.2) @@ -2147,11 +2141,6 @@ packages: resolution: {integrity: sha512-V5nVw1PAOgfI3Lmeaj2Exmeg7fenjhRUgz1lPSezy1CuhPYbgQtbQj4jZfEAEMlaL+vupsvhjqCyjzob0yxsmQ==} engines: {node: '>=10.19.0'} - husky@9.1.7: - resolution: {integrity: sha512-5gs5ytaNjBrh5Ow3zrvdUUY+0VxIuWVL4i9irt6friV+BqdCfmV11CQTWMiBYWHbXhco+J1kHfTOUkePhCDvMA==} - engines: {node: '>=18'} - hasBin: true - i18next@26.4.1: resolution: {integrity: sha512-9YbX5E6gd1H+yaOSX3izCsPj5iWXyH7X4oC+iuHHJJw8AeHglzOK5SJf+1CHxaYKYigcea+8jvzSxqYx46YvyA==} peerDependencies: @@ -2424,11 +2413,6 @@ packages: resolution: {integrity: sha512-wM1+Z03eypVAVUCE7QdSqpVIvelbOakn1M0bPDoA4SGWPx3sNDVUiMo3L6To6WWGClB7VyXnhQ4Sn7gxiJbE6A==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} - lint-staged@17.4.1: - resolution: {integrity: sha512-FmJeudcalbSfg1du+JCfvi5vS6Qt08KgbfLWiHinbef+2JJwUZwAWVoaO1AcJVUTWPfk0t30PMQNwPAeCzYQ+Q==} - engines: {node: '>=22.22.1'} - hasBin: true - load-plugin@6.0.3: resolution: {integrity: sha512-kc0X2FEUZr145odl68frm+lMJuQ23+rTXYmR6TImqPtbpmXC4vVXbWKDQ9IzndA0HfyQamWfKLhzsqGSTxE63w==} @@ -3404,10 +3388,6 @@ packages: '@astrojs/starlight': '>=0.42.0' astro: ^7.2.10 - string-argv@0.3.2: - resolution: {integrity: sha512-aqD2Q0144Z+/RqG52NeHEkZauTAUWJO8c6yTftGJKO3Tja5tUgIfmIl6kExvhtxSDP7fXB6DvzkfMpCd/F3G+Q==} - engines: {node: '>=0.6.19'} - string-width@4.2.3: resolution: {integrity: sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==} engines: {node: '>=8'} @@ -6206,8 +6186,6 @@ snapshots: quick-lru: 5.1.1 resolve-alpn: 1.2.1 - husky@9.1.7: {} - i18next@26.4.1(typescript@6.0.3): optionalDependencies: typescript: 6.0.3 @@ -6401,14 +6379,6 @@ snapshots: lines-and-columns@2.0.4: {} - lint-staged@17.4.1: - dependencies: - picomatch: 4.0.7 - string-argv: 0.3.2 - tinyexec: 1.3.0 - optionalDependencies: - yaml: 2.9.0 - load-plugin@6.0.3(bluebird@3.7.2): dependencies: '@npmcli/config': 8.3.4(bluebird@3.7.2) @@ -8168,8 +8138,6 @@ snapshots: astro: 7.3.1(@astrojs/markdown-remark@7.3.0(supports-color@10.2.2))(@emnapi/core@1.11.1)(@emnapi/runtime@1.11.3)(@types/node@26.4.1)(tsx@4.23.13)(yaml@2.9.0) picomatch: 4.0.7 - string-argv@0.3.2: {} - string-width@4.2.3: dependencies: emoji-regex: 8.0.0 diff --git a/scripts/post-checkout.mjs b/scripts/post-checkout.mjs deleted file mode 100644 index fb6558b3..00000000 --- a/scripts/post-checkout.mjs +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env node - -import { execSync } from 'node:child_process'; -import { hashLockfile, readStamp } from './stamp.mjs'; - -function main() { - const [, , , , isBranchCheckoutArg] = process.argv; - - if (isBranchCheckoutArg !== '1') { - process.exit(0); - } - - const currentHash = hashLockfile(); - if (!currentHash) { - process.exit(0); - } - - if (currentHash === readStamp()) { - process.exit(0); - } - - console.log('lockfile changed since last checkout, running `pnpm install`'); - - try { - execSync('pnpm install', { stdio: 'inherit' }); - } catch { - console.error('pnpm install failed. retry manually.'); - process.exit(1); - } -} - -if (!process.env.CI) { - main(); -} diff --git a/scripts/postinstall.ts b/scripts/postinstall.ts deleted file mode 100644 index a7e27e4f..00000000 --- a/scripts/postinstall.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { hashLockfile, STAMP, writeStamp } from './stamp.mjs'; -import { existsSync, unlinkSync } from 'node:fs'; - -function updateHash(): void { - const hash = hashLockfile(); - if (!hash) { - // no lockfile for some reason, remove stale stamp if it exists - if (existsSync(STAMP)) { - unlinkSync(STAMP); - } - process.exit(0); - } - writeStamp(hash); -} -// main function. put other functions in here to run on postinstall. do not put loose code in main, make your own method -function main(): void { - updateHash(); -} - -if (!process.env.CI) { - main(); -} diff --git a/scripts/stamp.mjs b/scripts/stamp.mjs deleted file mode 100644 index efc69968..00000000 --- a/scripts/stamp.mjs +++ /dev/null @@ -1,27 +0,0 @@ -import { createHash } from 'node:crypto'; -import { existsSync, readFileSync, writeFileSync } from 'node:fs'; -import { resolve } from 'node:path'; - -export const LOCKFILE = resolve(process.cwd(), 'pnpm-lock.yaml'); -export const STAMP = resolve(process.cwd(), 'node_modules', '.checksum.sha1'); - -/** - * @returns {string | null} the hash or null if the lockfile doesn't exist - */ -export function hashLockfile() { - if (!existsSync(LOCKFILE)) return null; - const contents = readFileSync(LOCKFILE); - return createHash('sha1').update(contents).digest('hex'); -} -/** - * @returns {string} the hash from the stamp file, or an empty string if it doesn't exist - */ -export function readStamp() { - return existsSync(STAMP) ? readFileSync(STAMP, 'utf-8').trim() : ''; -} -/** - * @param {string} hash - */ -export function writeStamp(hash) { - writeFileSync(STAMP, hash, 'utf-8'); -} diff --git a/scripts/syncLockfile.lint.ts b/scripts/syncLockfile.lint.ts deleted file mode 100644 index e2f0e005..00000000 --- a/scripts/syncLockfile.lint.ts +++ /dev/null @@ -1,13 +0,0 @@ -// Script to check if pnpm-lock.yaml is in sync with package.json. -import { exec } from 'node:child_process'; -import { promisify } from 'node:util'; - -await promisify(exec)( - // check if lockfile is in sync, don't run scripts, don't modify node_modules or lockfile - 'pnpm install --frozen-lockfile --lockfile-only --ignore-scripts', -).catch(() => { - console.error( - 'pnpm-lock.yaml is out of sync with package.json. Run `pnpm install` to update the lockfile.', - ); - process.exit(1); -});