test: integrate Lefthook (#727)
Some checks failed
Build / Build Action (push) Has been cancelled
Test / Test Action (macos-14) (push) Has been cancelled
Test / Test Action (ubuntu-24.04) (push) Has been cancelled
Test / Test Action (windows-2022) (push) Has been cancelled
Test / Test Action With Specified Directories (push) Has been cancelled
Test / Test Action Without Run Build (push) Has been cancelled
Test / Test Action With Additional Options (push) Has been cancelled
Test / Test Action With Custom Generator (push) Has been cancelled

* style: ignore `dist` and `README.md` in `.prettierignore`

Signed-off-by: Alfi Maulana <alfi.maulana.f@gmail.com>

* test: integrate Lefthook

Signed-off-by: Alfi Maulana <alfi.maulana.f@gmail.com>

* build: remove `build`, `format`, and `lint` scripts

Signed-off-by: Alfi Maulana <alfi.maulana.f@gmail.com>

---------

Signed-off-by: Alfi Maulana <alfi.maulana.f@gmail.com>
This commit is contained in:
Alfi Maulana 2025-06-10 13:01:57 +07:00 committed by GitHub
parent e71bbfd78e
commit bef022bb70
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 149 additions and 6 deletions

View File

@ -19,13 +19,16 @@ jobs:
run: pnpm install
- name: Check Formatting
run: pnpm format && git diff --exit-code HEAD
run: pnpm prettier --check .
- name: Check Lint
run: pnpm lint
run: pnpm eslint
- name: Check Types
run: pnpm tsc --noEmit
- name: Test Action
run: pnpm test
- name: Build Action
run: pnpm build && git diff --exit-code HEAD
run: pnpm rollup -c && git diff --exit-code dist

View File

@ -1 +1,3 @@
dist
pnpm-lock.yaml
README.md

39
lefthook.yml Normal file
View File

@ -0,0 +1,39 @@
pre-commit:
piped: true
jobs:
- name: install dependencies
run: pnpm install
glob:
- package.json
- pnpm-lock.yaml
- pnpm-workspace.yaml
- name: fix formatting
run: pnpm prettier --write --ignore-unknown {staged_files}
- name: fix lint
run: pnpm eslint --no-warn-ignored --fix {staged_files}
- name: check types
run: pnpm tsc --noEmit
glob:
- src/*.ts
- .npmrc
- pnpm-lock.yaml
- tsconfig.json
exclude:
- src/*.test.ts
- name: build action
run: pnpm rollup -c
glob:
- dist/*
- src/*.ts
- .npmrc
- pnpm-lock.yaml
- tsconfig.json
exclude:
- src/*.test.ts
- name: check diff
run: git diff --exit-code dist {staged_files}

View File

@ -3,9 +3,6 @@
"private": true,
"type": "module",
"scripts": {
"build": "rollup -c",
"format": "prettier --write --cache . !dist !README.md",
"lint": "eslint",
"test": "vitest run"
},
"dependencies": {
@ -19,6 +16,7 @@
"@types/node": "^22.15.30",
"@vitest/coverage-v8": "^3.1.4",
"eslint": "^9.28.0",
"lefthook": "^1.11.13",
"prettier": "^3.5.3",
"rollup": "^4.41.1",
"tslib": "^2.8.1",

100
pnpm-lock.yaml generated
View File

@ -33,6 +33,9 @@ importers:
eslint:
specifier: ^9.28.0
version: 9.28.0
lefthook:
specifier: ^1.11.13
version: 1.11.13
prettier:
specifier: ^3.5.3
version: 3.5.3
@ -913,6 +916,60 @@ packages:
keyv@4.5.4:
resolution: {integrity: sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==}
lefthook-darwin-arm64@1.11.13:
resolution: {integrity: sha512-gHwHofXupCtzNLN+8esdWfFTnAEkmBxE/WKA0EwxPPJXdZYa1GUsiG5ipq/CdG/0j8ekYyM9Hzyrrk5BqJ42xw==}
cpu: [arm64]
os: [darwin]
lefthook-darwin-x64@1.11.13:
resolution: {integrity: sha512-zYxkWNUirmTidhskY9J9AwxvdMi3YKH+TqZ3AQ1EOqkOwPBWJQW5PbnzsXDrd3YnrtZScYm/tE/moXJpEPPIpQ==}
cpu: [x64]
os: [darwin]
lefthook-freebsd-arm64@1.11.13:
resolution: {integrity: sha512-gJzWnllcMcivusmPorEkXPpEciKotlBHn7QxWwYaSjss/U3YdZu+NTjDO30b3qeiVlyq4RAZ4BPKJODXxHHwUA==}
cpu: [arm64]
os: [freebsd]
lefthook-freebsd-x64@1.11.13:
resolution: {integrity: sha512-689XdchgtDvZQWFFx1szUvm/mqrq/v6laki0odq5FAfcSgUeLu3w+z6UicBS5l55eFJuQTDNKARFqrKJ04e+Vw==}
cpu: [x64]
os: [freebsd]
lefthook-linux-arm64@1.11.13:
resolution: {integrity: sha512-ujCLbaZg5S/Ao8KZAcNSb+Y3gl898ZEM0YKyiZmZo22dFFpm/5gcV46pF3xaqIw5IpH+3YYDTKDU+qTetmARyQ==}
cpu: [arm64]
os: [linux]
lefthook-linux-x64@1.11.13:
resolution: {integrity: sha512-O5WdodeBtFOXQlvPcckqp4W/yqVM9DbVQBkvOxwSJlmsxO4sGYK1TqdxH9ihLB85B2kPPssZj9ze36/oizzhVQ==}
cpu: [x64]
os: [linux]
lefthook-openbsd-arm64@1.11.13:
resolution: {integrity: sha512-SyBpciUfvY/lUDbZu7L6MtL/SVG2+yMTckBgb4PdJQhJlisY0IsyOYdlTw2icPPrY7JnwdsFv8UW0EJOB76W4g==}
cpu: [arm64]
os: [openbsd]
lefthook-openbsd-x64@1.11.13:
resolution: {integrity: sha512-6+/0j6O2dzo9cjTWUKfL2J6hRR7Krna/ssqnW8cWh8QHZKO9WJn34epto9qgjeHwSysou8byI7Mwv5zOGthLCQ==}
cpu: [x64]
os: [openbsd]
lefthook-windows-arm64@1.11.13:
resolution: {integrity: sha512-w5TwZ8bsZ17uOMtYGc5oEb4tCHjNTSeSXRy6H9Yic8E7IsPZtZLkaZGnIIwgXFuhhrcCdc6FuTvKt2tyV7EW2g==}
cpu: [arm64]
os: [win32]
lefthook-windows-x64@1.11.13:
resolution: {integrity: sha512-7lvwnIs8CNOXKU4y3i1Pbqna+QegIORkSD2VCuHBNpIJ8H84NpjoG3tKU91IM/aI1a2eUvCk+dw+1rfMRz7Ytg==}
cpu: [x64]
os: [win32]
lefthook@1.11.13:
resolution: {integrity: sha512-SDTk3D4nW1XRpR9u9fdYQ/qj1xeZVIwZmIFdJUnyq+w9ZLdCCvIrOmtD8SFiJowSevISjQDC+f9nqyFXUxc0SQ==}
hasBin: true
levn@0.4.1:
resolution: {integrity: sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==}
engines: {node: '>= 0.8.0'}
@ -2078,6 +2135,49 @@ snapshots:
dependencies:
json-buffer: 3.0.1
lefthook-darwin-arm64@1.11.13:
optional: true
lefthook-darwin-x64@1.11.13:
optional: true
lefthook-freebsd-arm64@1.11.13:
optional: true
lefthook-freebsd-x64@1.11.13:
optional: true
lefthook-linux-arm64@1.11.13:
optional: true
lefthook-linux-x64@1.11.13:
optional: true
lefthook-openbsd-arm64@1.11.13:
optional: true
lefthook-openbsd-x64@1.11.13:
optional: true
lefthook-windows-arm64@1.11.13:
optional: true
lefthook-windows-x64@1.11.13:
optional: true
lefthook@1.11.13:
optionalDependencies:
lefthook-darwin-arm64: 1.11.13
lefthook-darwin-x64: 1.11.13
lefthook-freebsd-arm64: 1.11.13
lefthook-freebsd-x64: 1.11.13
lefthook-linux-arm64: 1.11.13
lefthook-linux-x64: 1.11.13
lefthook-openbsd-arm64: 1.11.13
lefthook-openbsd-x64: 1.11.13
lefthook-windows-arm64: 1.11.13
lefthook-windows-x64: 1.11.13
levn@0.4.1:
dependencies:
prelude-ls: 1.2.1

View File

@ -1,2 +1,3 @@
onlyBuiltDependencies:
- esbuild
- lefthook