-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Expand file tree
/
Copy pathlefthook.yml
More file actions
83 lines (81 loc) · 2.64 KB
/
Copy pathlefthook.yml
File metadata and controls
83 lines (81 loc) · 2.64 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# Lefthook configuration
#
# Install lefthook with any preferred method (see https://github.com/evilmartians/lefthook?tab=readme-ov-file#install).
# example: `gem install lefthook`
#
# Add commit hooks with `lefthook install`.
#
# To override any config, create a `lefthook-local.yml` file - e.g., for changing the run command
# to be executed in a docker container context.
#
# Refer for explanation to the following link:
# https://github.com/evilmartians/lefthook/blob/master/docs/usage.md
pre-commit:
parallel: true
commands:
eslint:
root: "frontend/"
files: git diff --name-only --staged
glob: "*.{js,ts,jsx,tsx}"
run: npx eslint {staged_files}
rubocop:
files: git diff --name-only --staged
glob: "*.rb"
run: bin/dirty-rubocop --uncommitted --force-exclusion {files}
erb_lint:
files: git diff --name-only --staged
glob: "*.erb"
run: erb_lint {files}
primer-view-components-version-is-the-same-everyhwere:
files: git diff --name-only --staged
glob: "{Gemfile.lock,frontend/package.json}"
run: script/check_same_primer_view_components_version_everywhere
yamllint:
files: git diff --name-only --staged
glob:
- ".yamllint.yml"
- "config/locales/en.yml"
- "config/locales/js-en.yml"
- "modules/*/config/locales/en.yml"
- "modules/*/config/locales/js-en.yml"
run: |
if command -v yamllint > /dev/null 2>&1; then
yamllint {files}
else
echo "warning: yamllint is not installed, skipping" >&2
fi
# Autofix counterpart of the pre-commit checks. Run explicitly:
#
# # fix staged files
# lefthook run fix
#
# # fix files changed since origin/dev (excluding deleted ones)
# lefthook run fix --files-from-stdin < <(git diff --name-only --diff-filter=d origin/dev)
#
# # fix all files in the repository
# lefthook run fix --all-files
fix:
parallel: true
commands:
eslint:
root: "frontend/"
files: git diff --name-only --staged
glob: "*.{js,ts,jsx,tsx}"
run: npx eslint --fix {files}
rubocop:
files: git diff --name-only --staged
glob: "*.rb"
run: bin/dirty-rubocop --uncommitted --force-exclusion -a {files}
erb_lint:
files: git diff --name-only --staged
glob: "*.erb"
run: erb_lint --autocorrect {files}
order_yaml:
files: git diff --name-only --staged
glob:
- ".yamllint.yml"
- "config/locales/en.yml"
- "config/locales/js-en.yml"
- "modules/*/config/locales/en.yml"
- "modules/*/config/locales/js-en.yml"
run: script/order_yaml -i {files}