Skip to content

Openverse is a search engine for openly-licensed media. This monorepo includes all application code.

Switch to locally available prettier for pre-commit hook (#4749)

sarayourfriende1282a6b316b
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index f5a7a94d6..7bc53b883 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -53,18 +53,6 @@ repos:
- --fix
- id: ruff-format # replaces Black
- # Use the `.prettierignore` and `.prettier.config.js` files to configure project-specific requirements.
- - repo: https://github.com/pre-commit/mirrors-prettier
- rev: v3.1.0
- hooks:
- - id: prettier
- # Must include any plugins defined in prettier.config.js, along with TypeScript and Prettier themselves
- # Versions must be manually kept in sync with those in the pnpm-lock.yaml file to prevent drift.
- additional_dependencies:
-
- repo: https://github.com/koalaman/shellcheck-precommit
rev: v0.10.0
hooks:
@@ -123,6 +111,15 @@ repos:
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|json)$
diff --git a/justfile b/justfile
index 8c8ead47d..b93edf8ab 100644
--- a/justfile
+++ b/justfile
@@ -77,6 +77,8 @@ install:
# Install `ov`-based git hooks
@install-hooks:
bash -c "cp ./docker/dev_env/hooks/* ./.git/hooks"
+ # Run pnpm install to ensure eslint and prettier are available
+ pnpm install
# Create an `.ov_profile.json` as a starting point for development environment customisation. Does not make changes if the file already exists.
init-ov-profile: