Skip to content

Commit ec1b3c7

Browse files
committed
chore: lefthook
1 parent 90f2bda commit ec1b3c7

6 files changed

Lines changed: 772 additions & 13 deletions

File tree

commitlint.config.mjs

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
export default {
2+
parserPreset: 'conventional-changelog-conventionalcommits',
3+
prompt: {
4+
questions: {
5+
body: {
6+
description: 'Provide a longer description of the change'
7+
},
8+
breaking: {
9+
description: 'Describe the breaking changes'
10+
},
11+
breakingBody: {
12+
description:
13+
'A BREAKING CHANGE commit requires a body. Please enter a longer description of the commit itself'
14+
},
15+
isBreaking: {
16+
description: 'Are there any breaking changes?'
17+
},
18+
isIssueAffected: {
19+
description: 'Does this change affect any open issues?'
20+
},
21+
issues: {
22+
description: 'Add issue references (e.g. "fix #123", "re #123".)'
23+
},
24+
issuesBody: {
25+
description:
26+
'If issues are closed, the commit requires a body. Please enter a longer description of the commit itself'
27+
},
28+
scope: {
29+
description: 'What is the scope of this change (e.g. component or file name)'
30+
},
31+
subject: {
32+
description: 'Write a short, imperative tense description of the change'
33+
},
34+
type: {
35+
description: "Select the type of change that you're committing",
36+
enum: {
37+
build: {
38+
description:
39+
'Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)',
40+
emoji: '🛠',
41+
title: 'Builds'
42+
},
43+
chore: {
44+
description: "Other changes that don't modify src or test files",
45+
emoji: '♻️',
46+
title: 'Chores'
47+
},
48+
ci: {
49+
description:
50+
'Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)',
51+
emoji: '⚙️',
52+
title: 'Continuous Integrations'
53+
},
54+
docs: {
55+
description: 'Documentation only changes',
56+
emoji: '📚',
57+
title: 'Documentation'
58+
},
59+
feat: {
60+
description: 'A new feature',
61+
emoji: '✨',
62+
title: 'Features'
63+
},
64+
fix: {
65+
description: 'A bug fix',
66+
emoji: '�',
67+
title: 'Bug Fixes'
68+
},
69+
perf: {
70+
description: 'A code change that improves performance',
71+
emoji: '🚀',
72+
title: 'Performance Improvements'
73+
},
74+
refactor: {
75+
description: 'A code change that neither fixes a bug nor adds a feature',
76+
emoji: '📦',
77+
title: 'Code Refactoring'
78+
},
79+
revert: {
80+
description: 'Reverts a previous commit',
81+
emoji: '🗑',
82+
title: 'Reverts'
83+
},
84+
style: {
85+
description:
86+
'Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)',
87+
emoji: '💎',
88+
title: 'Styles'
89+
},
90+
test: {
91+
description: 'Adding missing tests or correcting existing tests',
92+
emoji: '🚨',
93+
title: 'Tests'
94+
},
95+
wip: {
96+
description: 'Work in progress',
97+
emoji: '🚧',
98+
title: 'Work In Progress'
99+
}
100+
}
101+
}
102+
}
103+
},
104+
rules: {
105+
'body-leading-blank': [1, 'always'],
106+
'body-max-line-length': [2, 'always', 300],
107+
'footer-leading-blank': [1, 'always'],
108+
'footer-max-line-length': [2, 'always', 100],
109+
'header-max-length': [2, 'always', 100],
110+
'subject-case': [2, 'never', ['sentence-case', 'start-case', 'pascal-case', 'upper-case']],
111+
'subject-empty': [2, 'never'],
112+
'subject-full-stop': [2, 'never', '.'],
113+
'type-case': [2, 'always', 'lower-case'],
114+
'type-empty': [2, 'never'],
115+
'type-enum': [
116+
2,
117+
'always',
118+
[
119+
'build',
120+
'chore',
121+
'ci',
122+
'docs',
123+
'feat',
124+
'fix',
125+
'perf',
126+
'refactor',
127+
'revert',
128+
'style',
129+
'test',
130+
'wip'
131+
]
132+
]
133+
}
134+
}

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"scripts": {
1111
"lint": "./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php",
1212
"unused:variable": "phpcs -p --standard=VariableAnalysis backend",
13-
"compat": "./vendor/bin/phpcs -p ./backend --standard=PHPCompatibilityWP --runtime-set testVersion 5.6-"
13+
"compat": "./vendor/bin/phpcs -p ./backend --standard=PHPCompatibilityWP --runtime-set testVersion 7.4-"
1414
},
1515
"require-dev": {
1616
"friendsofphp/php-cs-fixer": "^3.10",

lefthook.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
pre-push:
2+
parallel: true
3+
commands:
4+
style-lint:
5+
glob: '*.{css,scss}'
6+
run: pnpm stylelint {staged_files} --aei --fix --quiet
7+
8+
php-lint:
9+
glob: '*.php'
10+
run: composer lint
11+
php-test:
12+
glob: '*php'
13+
run: composer test {staged_files}
14+
php-compatibility-check:
15+
glob: 'backend/**/*.php'
16+
run: composer compat {staged_files}
17+
18+
lint:
19+
glob: '*.{js,ts,jsx,tsx}'
20+
run: pnpm eslint frontend
21+
pretty:
22+
glob: '*.{js,ts,jsx,tsx}'
23+
run: pnpm pretty:fix
24+
ts-check:
25+
glob: '*.{ts,tsx}'
26+
run: pnpm ts-check
27+
28+
commit-msg:
29+
commands:
30+
commit-lint:
31+
run: pnpm commitlint --edit {1}
32+
33+
github-actions:
34+
parallel: true
35+
commands:
36+
lint:
37+
run: pnpm eslint frontend
38+
lint-css:
39+
run: pnpm lint:css
40+
lint-php:
41+
run: composer lint
42+
php-compatibility-check:
43+
run: composer compat
44+
prettier:
45+
run: pnpm pretty:fix
46+
test-js:
47+
run: pnpm test
48+
ts-check:
49+
run: pnpm ts-check
50+
# require db conn
51+
# test-php:
52+
# run: composer test:unit

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
"react-router-dom": "^6.26.2"
4242
},
4343
"devDependencies": {
44+
"@commitlint/cli": "^20.1.0",
45+
"@commitlint/config-conventional": "^20.0.0",
4446
"@emotion/babel-plugin": "^11.12.0",
4547
"@rollup/plugin-commonjs": "^25.0.8",
4648
"@storybook/react": "^7.6.20",
@@ -80,6 +82,7 @@
8082
"eslint-utils": "^3.0.0",
8183
"eslint-visitor-keys": "^3.4.3",
8284
"gettext-parser": "^8.0.0",
85+
"lefthook": "^2.0.2",
8386
"lodash": "^4.17.21",
8487
"onchange": "^7.1.0",
8588
"postcss-csso": "^6.0.1",

0 commit comments

Comments
 (0)