Openverse is a search engine for openly-licensed media. This monorepo includes all application code.
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 Spanish translation exists
# Download the i18n files if they do not exist
entry: bash -c 'if [ ! -f "$(dirname "$dir")"/frontend/i18n/locales/es.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: v6.0.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
# pnpm 11+ writes `pnpm-lock.yaml` as two YAML documents.
args:
- --allow-multiple-documents
- id: end-of-file-fixer
exclude: (frontend/test/tapes/.+\.json5|frontend/.*snapshots.*)
- id: check-symlinks
- id: mixed-line-ending
- id: check-docstring-first
- id: requirements-txt-fixer
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.17.5
hooks:
- id: ruff-check # replaces Flake8, isort, pydocstyle, pyupgrade
args:
- --fix
- id: ruff-format # replaces Black
- repo: https://github.com/koalaman/shellcheck-precommit
rev: v0.11.0
hooks:
- id: shellcheck
- repo: https://github.com/scop/pre-commit-shfmt
rev: v3.10.0-2
hooks:
- id: shfmt-docker
- repo: https://github.com/rhysd/actionlint
rev: v1.7.12
hooks:
- id: actionlint-docker
- repo: https://github.com/codespell-project/codespell
rev: v2.4.3
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: 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:
- pre-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: 44.244.1
hooks:
- id: renovate-config-validator
args:
- --strict
- .github/global-renovate.json5
- .github/renovate.json5
- repo: https://github.com/hadolint/hadolint
rev: v2.15.1
hooks:
- id: hadolint-docker
# The upstream hook leaves the image tag floating at `latest`,
# ignoring `rev`. Pin it so lint results are reproducible.
entry: ghcr.io/hadolint/hadolint:v2.12.0 hadolint