errata-ai / vale

:pencil: A markup-aware linter for prose built with speed and extensibility in mind.
https://vale.sh
MIT License
4.3k stars 144 forks source link

The order of Vocab vs BasedOnStyles in a vale.ini affecting raw-scoped rules #805

Closed rohennes closed 2 months ago

rohennes commented 2 months ago

Check for existing issues

Environment

vale version 3.0.7 Fedora Workstation 39 Installed from the repo

Describe the bug / provide steps to reproduce it

I cannot get the Vocab accept/reject rules working at the same time as raw scoped rules from rule set.

See here for test case: https://github.com/rohennes/vale-test

The structure of our repo has a top level .vale.ini file, with some rules disabled, and a lower level modules folder featuring a .vale.ini with all the rules.

It looks like when I set this order, the raw-scoped rules work but the Vocab doesn't work:

BasedOnStyles = RedHat, AsciiDoc, OpenShiftAsciiDoc

Vocab = OpenShiftDocs

But when I set this order, the Vocab works and the raw-scoped rules stop working:

Vocab = OpenShiftDocs

BasedOnStyles = RedHat, AsciiDoc, OpenShiftAsciiDoc

Thanks for your help.

jdkato commented 2 months ago

The Vocab key should be defined globally (not per syntax):

Packages = RedHat, AsciiDoc, OpenShiftAsciiDoc

Vocab = OpenShiftDocs

# Ignore files in dirs starting with `.` to avoid raising errors for `.vale/fixtures/*/testinvalid.adoc` files
[[!.]*.adoc]
BasedOnStyles = RedHat, AsciiDoc, OpenShiftAsciiDoc
rohennes commented 2 months ago

Thanks Joseph. That's good to know.

If I have Vocab in the modules/.vale.ini in the same format as your comment, the OpenShiftAsciiDoc.NoXrefInModules rule does not alert. If I delete the Vocab line in the modules/.vale.ini the OpenShiftAsciiDoc.NoXrefInModules rule does alert.

Why would the presence of Vocab be affecting this rule?

jdkato commented 2 months ago

The answer in such a case is always going to be that one of your vocab entries is matching what you expect the rule to alert against. In this case, it's your first entry:

(.*/)+

In general, you can add vocab: false to a rule to avoid this. However, this pattern looks like it isn't doing what you expect -- so I'd either remove it entirely or make it more specific.