-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathlefthook.yml
56 lines (52 loc) · 2.2 KB
/
lefthook.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
pre-commit:
piped: true
# Always prints the output of each command.
# This allows the error log to be checked even if the command becomes busy.
follow: true
commands:
0_test-readme:
# If "{REPO_ROOT}/README.md" is staged, test it
# Note: README.md files in subdirectories are not included
files: git diff --name-only --cached | grep -Fx README.md || true
run: pnpm exec task test-readme
1_format:
# Call the "lefthook run ..." command within lefthook to perform parallel execution in the middle of a serial execution
# see https://github.com/evilmartians/lefthook/issues/66#issuecomment-1313279972
env:
LEFTHOOK_QUIET: meta,summary,success
run: pnpm exec lefthook run _pre-commit__format
2_build-readme:
# If any file other than "{REPO_ROOT}/README.md" is staged, build README.md
# Note: README.md files in subdirectories are included
files: git diff --name-only --cached | grep -Fvx README.md || true
run: >-
pnpm exec task build-readme
&& git add ./README.md
3_git-add:
run: git add {staged_files}
_pre-commit__format:
parallel: true
commands:
format/config:
env:
LEFTHOOK_QUIET: meta,summary,success
run: lefthook run _pre-commit__format__config
format/eslint:
# Note: ".js" and ".ts" files are formatted by ESLint's "eslint-plugin-prettier" plugin.
# So there is no need to use Prettier for these files.
glob: "*.{ts,js,cjs,mjs}"
run: pnpm exec eslint --fix {staged_files}
_pre-commit__format__config:
piped: true
commands:
format/config/0_prettier:
glob: "*.{json,json5,yaml,yml}"
run: pnpm exec prettier --write {staged_files}
format/config/1_format-package-json:
# Note: If "package.json" is specified, only the root package.json file will be included.
# If "**/package.json" is specified, only package.json files in subdirectories will be included.
# To include both, it appears that the "{,**/}package.json" pattern should be used.
glob: "{,**/}package.json"
run: >-
pnpm exec prettier-package-json --write {staged_files}
&& pnpm exec sort-package-json {staged_files}