errata-ai / vale

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

Vale.Terms not taking precedence over Styles vocabs #888

Closed andrewvaughan closed 4 days ago

andrewvaughan commented 2 weeks ago

Check for existing issues

Environment

macOS

Describe the bug / provide steps to reproduce it

.vale.ini:

##
# The linter configuration root is the base for Vale styles.
#
StylesPath = .config/linters/vale/styles

##
# This project's hardened consistency requirement dictates the most verbose option.
#
# The default level is `warning` for projects that don't need stringent prose requirements.
#
MinAlertLevel = suggestion

##
# This project uses the Google Developer Documentation Style Guide as its base.
#
# @link https://developers.google.com/style/
# @see {@link .config/linters/vale/README.md}
#
Packages = Google

##
# Two vocab sets exist for ops and the project.
#
# This isn't used for spellcheck, as CSpell manages that. Instead, this informs vale what words to treat as proper nouns
# and various formatting standards.
#
# These Vocab configurations are available in the `.config/linters/vale/styles/config/vocabularies` folder.
#
# @link https://vale.sh/docs/topics/vocab/
#
Vocab = Ops, Project

## ---------------------------------------------------------------------------------------------------------------------
# Global rules.
#
[*]

##
# The Google style-guide is the default for this project.
#
BasedOnStyles = Vale, Google

##
# Users of these projects understand common acronyms.
#
Google.Acronyms = NO

##
# The project disables spelling as the project uses CSpell for spellcheck.
#
Vale.Spelling = NO

.config/linters/vale/styles/config/vocabularies/Ops/accept.txt:

All Rights Reserved
amd64
Andrew Vaughan
andrewvaughan
ANSI
Apache
Apple
application
ARM
Branch
Branches
Checkmake
Checkmarx
Checkov
Chiberia
CI/CD
Code of Conduct
Code Owner
Code Owners
Code Review
Code Reviewer
Community Leader
Community Leaders
Continuous Delivery
Continuous Integration
Contributing Guidelines
Contributor
Contributors
Coordinated Vulnerability Disclosure
Coordinated Vulnerability Disclosure Policy
CSpell
CVD
Definition of Done
Discussion
Discussions
Docker
EditorConfig
Fork
Forks
FreeBSD
GIF
GIFs
GitHub
GitHub Action
GitHub Actions
GNU
Google
Hot-Fix
Hot-Fixes
ID
In Progress
in progress
[Ii]ssue
[Ii]ssues
Keeping Infrastructure as Code Secure
KICS
LFS
License
Licensee
Licenses
Licensor
M&Ms
macOS
Makefile
Makefiles
Markdown
MegaLinter
Milestone
Milestones
MIT
Pending Initiation
Pending Staging
Project Licenses
Project Maintainer
Project Maintainers
Pull Request
Pull Requests
Primary Commit Message
[Rr]elease
Releases
Repository
Reviewer
Rubber Duck Debugging
[Rr]uleset
[Rr]ulesets
SASS
SCSS
SDLC
Security Issue
Security Policy
Semantic Versioning
SemVer
Software Development Lifecycle
Staged
Support Policy
Tag
URL
URLs
Vale
VSCode
Wontfix
X-Y Problem

It seems as if my vocabs have a lower priority than something buried in the Vale core, or is otherwise broken. I've confirmed that the vocabs are loading (by dictating how to format FooBar and seeing that the vale command properly complains about that), but it also complains about a lot of things that should be valid with the config, above:

$ vale README.md

 README.md
 23:4    error  Use 'release' instead of        Vale.Terms 
                'Release'.                                 
 24:4    error  Use 'license' instead of        Vale.Terms 
                'License'.                                 
 26:4    error  Use 'megalinter' instead of     Vale.Terms 
                'MegaLinter'.                              
 31:9    error  Use 'release' instead of        Vale.Terms 
                'Release'.                                 
 32:12   error  Use 'release' instead of        Vale.Terms 
                'Release'.                                 
 33:15   error  Use 'release' instead of        Vale.Terms 
                'Release'.                                 
 34:20   error  Use 'release' instead of        Vale.Terms 
                'Release'.                                 
 64:6    error  Use 'release' instead of        Vale.Terms 
                'Release'.                                 
 65:6    error  Use 'license' instead of        Vale.Terms 
                'License'.                                 
 118:22  error  Use 'issue' instead of          Vale.Terms 
                'Issue'.                                   
 137:10  error  Use 'issue' instead of          Vale.Terms 
                'Issue'.                                   
 159:1   error  Use 'GitHub Actions' instead    Vale.Terms 
                of 'GitHub actions'.                       
 160:4   error  Use 'docker' instead of         Vale.Terms 
                'Docker'.                                  
 198:4   error  Use 'release' instead of        Vale.Terms 
                'Release'.                                 
 200:1   error  Use 'releases' instead of       Vale.Terms 
                'Releases'.                                
 203:91  error  Use 'release' instead of        Vale.Terms 
                'Release'.                                 
 204:27  error  Use 'release' instead of        Vale.Terms 
                'Release'.                                 
 205:27  error  Use 'release' instead of        Vale.Terms 
                'Release'.                                 
 207:2   error  Use 'github' instead of         Vale.Terms 
                'GitHub'.                                  
 207:30  error  Use 'releases' instead of       Vale.Terms 
                'Releases'.                                
 207:56  error  Use 'release' instead of        Vale.Terms 
                'Release'.                                 
 211:4   error  Use 'license' instead of        Vale.Terms 
                'License'.                                 
 213:70  error  Use 'license' instead of        Vale.Terms 
                'License'.                                 
 217:15  error  Use 'license' instead of        Vale.Terms 
                'License'.    

No matter what I put in my vocabs, I can't override what Vale thinks vale or release or any of my other specified terms should be. This occurs in my MegaLinter configuration, as well.

andrewvaughan commented 2 weeks ago

Of note, when I removed Vale from BasedOnStyles I no longer get errors... although I also lose all of the Vale style guide value. My guess is that the Vale style guide is (I assume, inappropriately) taking precedence over the local vocab.

andrewvaughan commented 2 weeks ago

Okay, this is weird. I'll leave this open if I can help with any debugging, but I did the following and it fixed the issue:

  1. Removed Vale from BasedOnStyles
  2. Ran vale
  3. Added Vale back into BasedOnStyles

Vale version for all commands:

$ vale --version
vale version 3.7.1

Now it works as-expected. This was a project I was actively updating from Vale v2 to Vale v3, if that's helpful. Feel free to close this, if not of interest, or let me know if I can answer any further questions. Thanks.

Edit: Ignore all of this - this was user error. I accidentally added Vale to Packages not BasedOnStyles. When I add it back to BasedOnStyles, the bug reappears.

andrewvaughan commented 2 weeks ago

Looks like this is the offending line:

https://github.com/errata-ai/vale/blob/871dafd1e24500cee9d8ad82b25d42a136bb2103/internal/check/manager.go#L233

Loading the vocabularies in the loadDefaultRules() seems like a mistake, if the intent is to have local vocabs override styles. They're loaded in the wrong order, here:

https://github.com/errata-ai/vale/blob/871dafd1e24500cee9d8ad82b25d42a136bb2103/internal/check/manager.go#L39-L49

My presumption is that mgr.loadVocabRules() should come after mgr.loadStyles(). I'll submit a PR, but I'm not a go dev, so please review thoroughly.

jdkato commented 2 weeks ago

What is in your Project vocab?

andrewvaughan commented 2 weeks ago

What is in your Project vocab?

Empty file for this project. It's a template repository. Here's the accept.txt:

##
# Vale special words formatting dictionary. This isn't intended for spell-checking, but for formatting.
#
# This file defines acceptable words and phrases for this specific project. Add common operational phrases to the
# parallel `Ops` vocabulary folder, reserving this file for project-specific phrases.
#
# @link https://vale.sh/docs/topics/vocab/
#
# TEMPLATE TODO - Add the proper spelling of the project name, and any other known phrases with specific-formatting, to
# start this dictionary.
#
jdkato commented 2 weeks ago

I can't reproduce this issue.

Vale doesn't have any default vocabulary, so the suggestion to use "release," for example, is coming from an external source.

What is the output of vale ls-config?

andrewvaughan commented 4 days ago

Apologies for dropping off, I got ill. Here is my ls-config:

{
  "BlockIgnores": {},
  "Checks": [
    "Google.Acronyms",
    "Vale.Spelling"
  ],
  "Formats": {},
  "Asciidoctor": {},
  "FormatToLang": {},
  "GBaseStyles": [
    "Vale",
    "Google"
  ],
  "GChecks": {
    "Google.Acronyms": false,
    "Vale.Spelling": false
  },
  "IgnoredClasses": null,
  "IgnoredScopes": null,
  "MinAlertLevel": 0,
  "Vocab": [
    "Ops",
    "Project"
  ],
  "RuleToLevel": {},
  "SBaseStyles": {},
  "SChecks": {},
  "SkippedScopes": null,
  "Stylesheets": {},
  "TokenIgnores": {},
  "WordTemplate": "",
  "RootINI": "/Users/andrew/Repositories/Personal/template-core/.vale.ini",
  "Paths": [
    "/Users/andrew/Library/Application Support/vale/styles",
    "/Users/andrew/Repositories/Personal/template-core/.config/linters/vale/styles"
  ],
  "ConfigFiles": [
    "/Users/andrew/Repositories/Personal/template-core/.vale.ini"
  ],
  "NLPEndpoint": ""
}
andrewvaughan commented 4 days ago

@jdkato here is the exact branch/environment where this issue is occurring: https://github.com/andrewvaughan/template-core/tree/ops/0077/megalinter-8.0

You can run make test if you wish to run it in a Docker container via Megalinter, or it should show as above with vale README.md in the project root.

Edit: I understand what you're saying about Vale not having a vocab. I'm not sure what to add, as the only way I can rectify the issues is by removing Vale from BasedOnStyles which led me to believe it had to do with that style being loaded.

I want to confirm - is this file not being used by Vale? It has all of the words being flagged in it:

https://github.com/errata-ai/vale/blob/v3/internal/spell/data/en_US-web.dic

andrewvaughan commented 4 days ago

Closing this issue, there was trailing TODO blocks appended in my dictionary I somehow missed multiple times:

##
# TODO - Remove this group when this Issue resolves and URLs are no longer linted:
# https://github.com/errata-ai/vale/issues/711
#

branch
discussions
docker
editorconfig
fork
github
issue
issues
license
megalinter
milestones
mit
release
releases
sdlc
vale

Thanks for the engagement.