errata-ai / vale

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

Proposal: Capitalization support for spelling rule #871

Closed Ravlen closed 4 months ago

Ravlen commented 4 months ago

Check for existing issues

Describe the feature

It would be great if there was a way to flag words that were spelled correctly, but not capitalized correctly, with the current spelling style rule. I realize I could maintain two lists, one for spelling, and a separate one for capitalization, but that would be a maintenance burden when the correct spelling and capitalization is already in the spelling ignore list. Maintaining two lists would mean that every mis-capitalized word would be flagged as a problem twice.

Using OpenID as an example word that could be in the ignore.txt exceptions list, with a basic spelling rule:

extends: spelling
message: "Did you really mean '%s'?"
level: error
ignore:
  - ignore.txt

If you use Openid (correct letters, incorrect capitalization), the error would be Did you really mean 'Openid'?. But the spelling is technically correct, it's just the capitalization that' s wrong. Since the exceptions list does contain the correct capitalization, I wonder if Vale could make use of that somehow? Perhaps:

extends: spelling
message: "Is '%s' spelled correctly?"
capitalization_message: "'%s' is spelled correctly, but should be capitalized as '%s'."
level: error
ignore:
  - ignore.txt

That way, general spelling AND capitalization can all be handled by a single rule.

jdkato commented 4 months ago

This is the use case that vocabularies are designed for: entries in a vocabulary will only raise a Vale.Spelling error if they're misspelled, while the Vale.Terms rule enforces that they match exactly as they're listed (so "Openid" would be corrected to "OpenID").