forked from WordPress/openverse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.pre-commit-config.yaml
139 lines (127 loc) · 4.38 KB
/
.pre-commit-config.yaml
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
exclude: Pipfile\.lock|migrations|\.idea|node_modules|archive|retired
repos:
- repo: local # More local hooks are defined at the bottom.
hooks:
- id: i18n
name: i18n
files: ^frontend/.*$
# Check if the i18n files have been downloaded by checking if the Arabic translation exists
# Download the i18n files if they do not exist
entry: bash -c 'if [ ! -f "$(dirname "$dir")"/frontend/src/locales/ar.json ]; then just frontend/run i18n; fi'
language: system
pass_filenames: false
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]
- id: check-executables-have-shebangs
- id: check-json
exclude: tsconfig.json|.devcontainer/devcontainer.json # contains comments
- id: check-case-conflict
- id: check-toml
- id: check-merge-conflict
- id: check-xml
- id: check-yaml
- id: end-of-file-fixer
exclude: frontend/test/tapes/.+\.json5
- id: check-symlinks
- id: mixed-line-ending
- id: fix-encoding-pragma
args:
- --remove
- id: check-docstring-first
- id: requirements-txt-fixer
# Use the `.isort.cfg` file to configure additional project-specific requirements.
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
files: \.py$
exclude: ^build/.*$|^.tox/.*$|^venv/.*$
args:
- --profile=black
- --lines-after-imports=2
- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
hooks:
- id: pyupgrade
args:
- --py310-plus
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: "v0.0.261"
hooks:
- id: ruff
args:
- --fix
- repo: https://github.com/ambv/black
rev: 23.3.0
hooks:
- id: black
args:
- --safe
- repo: https://github.com/pycqa/pydocstyle
rev: 6.3.0
hooks:
- id: pydocstyle
args:
- --convention=pep257
# Additional ignore reasons:
# D1xx: we do not want to force contributors to write redundant or useless docstrings
# D202: additional whitespace helps with readability
# D205: we don't want to always require a single line summary
# D211: same as D202
# D400: first line doesn't need to end in a period
# See the following documentation for what each rule does:
# https://www.pydocstyle.org/en/6.2.3/error_codes.html#error-codes
- --add-ignore=D1,D202,D205,D211,D400
# Use the `.prettierignore` and `.prettier.config.js` files to configure project-specific requirements.
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.6.0
hooks:
- id: prettier
additional_dependencies:
- prettier@2.6.0
- prettier-plugin-tailwindcss@0.2.2
- typescript@4.9.3
- repo: https://github.com/koalaman/shellcheck-precommit
rev: v0.9.0
hooks:
- id: shellcheck
- repo: https://github.com/scop/pre-commit-shfmt
rev: v3.6.0-2
hooks:
- id: shfmt-docker
- repo: https://github.com/rhysd/actionlint
rev: v1.6.24
hooks:
- id: actionlint-docker
- repo: local # More local hooks are defined at the top.
hooks:
- id: types
name: types
files: ^frontend/.*$
entry: bash -c 'pnpm exec vue-tsc -p frontend --noEmit'
language: system
pass_filenames: false
- id: eslint
name: eslint
files: (frontend|automations).*?\.(js|ts|vue|json5|json)$
"types": [file] # ESLint only accepts [javascript] by default.
language: system
pass_filenames: false
entry: bash -c 'pnpm exec eslint --fix --ext .js,.ts,.vue,.json,.json5 --ignore-path .gitignore --ignore-path .eslintignore --max-warnings=0 frontend automations/js .pnpmfile.cjs .eslintrc.js prettier.config.js'
- id: test:unit
name: test:unit
files: ^frontend/.*$
entry: bash -c 'just frontend/run test:unit'
language: system
pass_filenames: false
stages:
- push
- id: render-release-drafter
name: render-release-drafter
files: ^templates/.*$
entry: bash -c 'just automations/js/render-release-drafter'
language: system
pass_filenames: false