Skip to content

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

Fix Vale by passing files to process instead of a glob to ignore (#3871)

zackb09b8652b93e
diff --git a/.vale/Dockerfile b/.vale/Dockerfile
index 9bd1fd58e..1afd8b6e0 100644
--- a/.vale/Dockerfile
+++ b/.vale/Dockerfile
@@ -2,8 +2,9 @@ FROM jdkato/vale:v2.30.0
WORKDIR /vale
COPY .vale.ini .
-COPY styles styles
RUN vale sync
+COPY styles styles
+
ENTRYPOINT ["vale", "--config=/vale/.vale.ini"]
diff --git a/.vale/justfile b/.vale/justfile
index f19128650..3a6fcd8ce 100644
--- a/.vale/justfile
+++ b/.vale/justfile
@@ -1,64 +1,41 @@
COLOR := "\\033[0;34m"
NO_COLOR := "\\033[0m"
-
# Show all available recipes
@_default:
printf "\n{{ COLOR }}# Vale (path: \`.vale/\`)\n"
printf "===================={{ NO_COLOR }}\n"
just --list --unsorted
-
# Build a local version of `openverse-vale:local` for testing
build:
docker build . -t openverse-vale:local
-
-# The --glob setting excludes things that should not be linted, including
-# build artefacts, dependencies, and automatically generated files like
-# the changelogs (without excluding `changelogs/index.md`). Project proposals
-# are also excluded for want of a good way to ignore existing proposals and only
-# lint _new_ proposals. Project proposals aren't "living documents" in the way
-# the rest of our documentation is, so it doesn't seem right to retroactively
-# edit them for mere editorial purposes (rather than, for example, to correct
-# some grave inacurracy).
-# Leading `,` compensates for lack of trailing comma support
-# Note the lack of space before the trailing \ on each line, this is to prevent
-# the addition of a space between each pattern, which isn't supported by Vale's glob
-# If you change this and Vale takes a very long time to run (more than 30 seconds)
-# then chances are the change is breaking the glob pattern. Unfortunately the only
-# feedback you get when the glob pattern is not working as intended is a very long
-# run time for Vale as it checks everything that should have otherwise been ignored,
-# but wasn't due to some minor issue in the pattern syntax.
-# This is fiddly, but I can't find a good way around it.
-_IGNORE_PATTERNS := """
- _build\
- ,_static\
- ,venv\
- ,.venv\
- ,.nuxt\
- ,.pnpm-store\
- ,node_modules\
- ,test-results\
- ,storebook-static\
- ,.ruff-cache\
- ,projects/proposals\
- ,changelogs/api\
- ,changelogs/frontend\
- ,changelogs/catalog\
- ,changelogs/ingestion_server\
-"""
-
-VALE_GLOB := "--glob='!*{" + _IGNORE_PATTERNS + "}*'"
-
+IGNORE_FILES_PATTERN := ".pnpm|changelogs|projects/proposals|node_modules|.?venv"
+
+# This recipe generates a list of Markdown and MDX files to be processed, excluding those
+# matched by the IGNORE_FILES_PATTERN. Files are listed relative to the parent directory
+# of the current working directory. If a custom separator is specified, newlines are
+# replaced with this separator before outputting the file list.
+@files separator="\n":
+ #! /usr/bin/env sh
+ files=$(
+ find "$PWD/.." -type f \( -name "*.md" -o -name "*.mdx" \) \
+ | grep -vE "{{ IGNORE_FILES_PATTERN }}" \
+ | sed "s|$PWD/../||"
+ )
+ if [ '{{ separator }}' != '\n' ]; then
+ echo "$files" | tr '\n' '{{ separator }}'
+ exit 0
+ fi
+ echo "$files"
# Run Vale configured for Openverse in Docker.
# Using Docker avoids the need for contributors to install the Vale binary.
#Configuration defaults to what is used for CI.
-run +files=".": build
+run: build
docker run --rm \
-v $PWD/..:/src:rw,Z \
--workdir=/src \
openverse-vale:local \
- {{ files }} \
- {{ VALE_GLOB }}
+ {{ "`just files`" }}
diff --git a/.vale/styles/Openverse/TermCasing.yml b/.vale/styles/Openverse/TermCasing.yml
index 90ecadc2e..cf64c6d5f 100644
--- a/.vale/styles/Openverse/TermCasing.yml
+++ b/.vale/styles/Openverse/TermCasing.yml
@@ -5,7 +5,7 @@ message: "Incorrect casing. Use '%s' instead of '%s'."
level: error
ignorecase: false
scope:
- - paragraph
+ - text
swap:
# [^/\.] prevents matching things that look like URLs, file paths, or GitHub team mentions
# For example: @WordPress/openverse-maintainers