Selective prose linting with Vale’s glob switch
I ran into one challenge though where I didn’t want to enable Vale for everything: a large internal documentation repo. This is the catch-all of things we should share with one another and like most internal company documentation sites, there is a lot going on. I assembled a very minimal set of Vale rules and still the first pass netted me over 10k errors. Luckily, Vale has a --glob
option, but it took me a while to find how to exclude multiple files and directories using it, so here’s the example for future-me, and anyone else who needs to see it!
Most of Vale’s configuration uses a .vale.ini
file, but you specify the files and directories to check at the time you run the command, with something like:
vale docs/
In my case, I needed to exclude a mix of folders (there’s little value in checking/fixing a meeting notes collection of a past project, and we can’t make changes to our legal docs. Also there’s a page of good restaurants near the office that is full of proper nouns!). To include just one section or another, I could run Vale multiple times to check each section, but to run everything except some problem areas, I used --glob
. I ended up with a command like this:
vale --glob='!{office/where-to-eat.md,legal/*,projects/codename/meetings/*}
Some of the skipped directories we will probably work on improving and then dropping the exception for – but this approach is useful when retrofitting a tool like Vale to an existing repository which can’t be made to align all at once. We’re also using a pretty reduced ruleset and may incrementally add to this over time.
Glob in GitHub Actions
Probably all the CI integrations have something similar but Vale has a GitHub Action and I could add the whole --glob
expression to a vale_flags
entry in the with
step.
Ideally we’d be running identical commands and configuration both locally and in CI, but since the configuration for this doesn’t seem to be able to go in the Vale config file, I compromised on adding it as an npm script as well as a GitHub action. It’ll be annoying to maintain but I didn’t come up with any better ideas!
Hopefully this post will help me next time I’m wondering how to combine glob expressions for Vale, since I didn’t find many other examples. If it helps you do, then that’s even better! Share your tips in the comments :)
Also published on Medium.