-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathlefthook.yml
More file actions
69 lines (64 loc) · 2.31 KB
/
lefthook.yml
File metadata and controls
69 lines (64 loc) · 2.31 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
# Lefthook configuration — replaces overcommit
# https://github.com/evilmartians/lefthook
#
# Lefthook does NOT use git stash, avoiding the index.lock race condition
# that plagued overcommit in worktree setups.
pre-commit:
parallel: true
commands:
rubocop:
glob: "*.{rb,rake}"
run: bundle exec rubocop --autocorrect --display-cop-names --force-exclusion {staged_files}
stage_fixed: true
eslint:
# Match CI's lint:ci scope exactly — only files under app/javascript.
# VitePress docs/ files are handled separately and would trip
# --max-warnings 0 as "file ignored" warnings if linted here.
glob: "app/javascript/**/*.{js,vue}"
# No --fix on purpose: matches the CI lint:ci behavior so prettier
# and lint errors fail the commit instead of being silently fixed.
# Run `yarn lint` manually to apply autofixes.
run: yarn eslint --max-warnings 0 {staged_files}
# Trailing whitespace handled by RuboCop (Ruby) and ESLint (JS/Vue)
# No separate fix-whitespace needed
yaml-syntax:
glob: "*.{yml,yaml}"
run: 'ruby -e "require ''yaml''; ARGV.each { |f| YAML.load_file(f, aliases: true) }" {staged_files}'
json-syntax:
glob: "*.json"
run: ruby -e "require 'json'; ARGV.each { |f| JSON.parse(File.read(f)) }" {staged_files}
merge-conflicts:
run: git diff --staged --check
commit-msg:
commands:
capitalized-subject:
# Allow conventional commits (feat:, fix:, chore:, etc.) or capitalized subjects
run: head -1 {1} | grep -qE '^([a-z]+(\(.+\))?:|[A-Z])'
empty-message:
run: test -s {1}
trailing-period:
run: "! head -1 {1} | grep -q '\\.$'"
text-width:
run: "! head -1 {1} | grep -qE '.{73,}'"
pre-push:
parallel: true
commands:
rubocop:
run: bundle exec rubocop --display-cop-names --force-exclusion
eslint:
glob: "*.{js,vue}"
run: yarn lint:ci
brakeman:
run: bundle exec brakeman --quiet --no-pager
post-checkout:
commands:
bundle-install:
run: bundle check || bundle install
yarn-install:
run: yarn install --frozen-lockfile 2>/dev/null || yarn install
post-merge:
commands:
bundle-install:
run: bundle check || bundle install
yarn-install:
run: yarn install --frozen-lockfile 2>/dev/null || yarn install