forked from WordPress/openverse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.pre-commit-config.yaml
173 lines (160 loc) · 5.45 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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
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.(base\.)?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:
- 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: https://github.com/codespell-project/codespell
rev: v2.2.5
hooks:
- id: codespell
args: [
# Pass skip configuration as command line arguments rather than in the
# config file because neither cfg nor TOML support splitting this argument
# across multiple lines.
# Globs must match the Python `glob` module's format:
# https://docs.python.org/3/library/glob.html#module-glob
"-S",
"sample_data/**",
"-S",
"frontend/test/tapes/**",
"-S",
"frontend/test/playwright/e2e/resources/**",
"-S",
"frontend/test/unit/fixtures/**",
"-S",
"catalog/tests/dags/providers/provider_api_scripts/resources/**",
"-S",
"catalog/tests/dags/common/test_resources/**",
# Test locales are non-English and therefore should not be checked by codespell
"-S",
"frontend/test/locales/*.json",
"-S",
"pnpm-lock.yaml",
# Write changes in place
"-w",
]
additional_dependencies:
# Support pyproject.toml configuration
- tomli
- repo: local # More local hooks are defined at the top.
hooks:
- id: types
name: types
files: ^(frontend|packages)/.*$
entry: bash -c 'pnpm run -r types'
language: system
pass_filenames: false
- id: eslint
name: eslint
files: (frontend|automations|packages).*?\.(js|ts|vue|json5|json)$
"types": [file] # ESLint only accepts [javascript] by default.
language: system
pass_filenames: false
entry: bash -c 'pnpm run eslint --fix'
- id: test:unit
name: test:unit
files: ^(frontend|packages)/.*$
entry: bash -c 'pnpm run -r 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