forked from WordPress/openverse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.pre-commit-config.yaml
168 lines (152 loc) · 5.42 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
exclude: Pipfile\.lock|migrations|\.idea|node_modules|\.snap
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
# Replace ```console code block with ```bash in our documentation
- id: fix-console-code-block
name: Ensure "bash" code block is used over "console"
files: ^documentation/.*\.md$
# -i: edit in place (no argument means no backup)
# -p: loop over all files provided, print error message if file cannot be opened
# -e: use the code provided inline
entry: python3 -c 'import fileinput; [print(line.replace("```console", "```bash"), end="") for line in fileinput.input(inplace=True)]'
language: system
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.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|frontend/.*snapshots.*)
- id: check-symlinks
- id: mixed-line-ending
- id: fix-encoding-pragma
args:
- --remove
- id: check-docstring-first
- id: requirements-txt-fixer
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.3
hooks:
- id: ruff # replaces Flake8, isort, pydocstyle, pyupgrade
args:
- --fix
- id: ruff-format # replaces Black
- repo: https://github.com/koalaman/shellcheck-precommit
rev: v0.10.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.7.1
hooks:
- id: actionlint-docker
- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
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/**",
"-S",
"catalog/tests/s3-data/**",
# 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/js)/.*$
entry: bash -c 'pnpm run prepare:nuxt && pnpm run -r types'
language: system
pass_filenames: false
- id: prettier
name: prettier
"types": [text]
language: system
pass_filenames: true
# Set log-level to error to prevent prettier printing every single file it checks
# when running pre-commit with --all-files
entry: pnpm exec prettier --write --ignore-unknown --log-level error
- id: eslint
name: eslint
files: (frontend|automations|packages/js).*?\.(js|ts|mjs|vue|json5?)$
"types": [file] # ESLint only accepts [javascript] by default.
language: system
pass_filenames: false
entry: just eslint
- id: test:unit
name: test:unit
files: ^(frontend|packages/js)/.*$
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
- id: vale
name: vale
language: system
entry: bash -c 'just .vale/run'
pass_filenames: false
files: (.vale/.*|.mdx?)$
- repo: https://github.com/renovatebot/pre-commit-hooks
rev: 37.440.7
hooks:
- id: renovate-config-validator
args:
- --strict
- .github/global-renovate.json5
- .github/renovate.json5
- repo: https://github.com/hadolint/hadolint
rev: v2.12.0
hooks:
- id: hadolint-docker