@helderberto/lefthook-config 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +41 -2
- package/lefthook.yml +10 -0
- package/package.json +30 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Helder Berto
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,42 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @helderberto/lefthook-config
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@helderberto/lefthook-config)
|
|
4
|
+
|
|
5
|
+
Pre-commit hooks for npm and pnpm projects: Prettier formats staged files, and ESLint lints staged TypeScript. Nothing checks commit messages.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install -D @helderberto/lefthook-config lefthook
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Use
|
|
14
|
+
|
|
15
|
+
```yaml
|
|
16
|
+
# lefthook.yml
|
|
17
|
+
extends:
|
|
18
|
+
- node_modules/@helderberto/lefthook-config/lefthook.yml
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
The hooks call these scripts through `npm run`, which works whichever package manager installed them:
|
|
22
|
+
|
|
23
|
+
```json
|
|
24
|
+
// package.json
|
|
25
|
+
{
|
|
26
|
+
"scripts": {
|
|
27
|
+
"prepare": "lefthook install",
|
|
28
|
+
"format:staged": "prettier --write --ignore-unknown",
|
|
29
|
+
"lint:staged": "eslint --no-warn-ignored"
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Moving from husky
|
|
35
|
+
|
|
36
|
+
Husky sets `core.hooksPath` in each clone's git config, and `lefthook install` refuses to run while it's set, so `npm install` fails at `prepare`. Run this once in every existing clone:
|
|
37
|
+
|
|
38
|
+
```sh
|
|
39
|
+
git config --unset core.hooksPath
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Fresh clones and CI aren't affected.
|
package/lefthook.yml
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# npm ships with Node, so `npm run` reaches the project's scripts whichever manager installed them.
|
|
2
|
+
pre-commit:
|
|
3
|
+
parallel: true
|
|
4
|
+
jobs:
|
|
5
|
+
- name: format
|
|
6
|
+
run: npm run format:staged -- {staged_files}
|
|
7
|
+
stage_fixed: true
|
|
8
|
+
- name: lint
|
|
9
|
+
glob: '*.{ts,tsx}'
|
|
10
|
+
run: npm run lint:staged -- {staged_files}
|
package/package.json
CHANGED
|
@@ -1,6 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@helderberto/lefthook-config",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/helderberto/coding-standards.git",
|
|
9
|
+
"directory": "packages/lefthook-config"
|
|
10
|
+
},
|
|
11
|
+
"exports": {
|
|
12
|
+
"./lefthook.yml": "./lefthook.yml"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"lefthook.yml"
|
|
16
|
+
],
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": ">=22"
|
|
19
|
+
},
|
|
20
|
+
"peerDependencies": {
|
|
21
|
+
"lefthook": ">=2"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"lefthook": "2.2.4",
|
|
25
|
+
"vitest": "5.1.2"
|
|
26
|
+
},
|
|
27
|
+
"publishConfig": {
|
|
28
|
+
"access": "public"
|
|
29
|
+
},
|
|
30
|
+
"scripts": {
|
|
31
|
+
"test": "vitest run"
|
|
32
|
+
}
|
|
6
33
|
}
|