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

Custom YAML Style files only accept `.yml` file extension #891

Closed jonathonlacher closed 1 month ago

jonathonlacher commented 3 months ago

Check for existing issues

Environment

Mac Brew vale version 3.7.1

Describe the bug / provide steps to reproduce it

It seems that custom YAML Style files must have the extension *.yml.

This tripped me up for a while; my style file I had was a *.yaml.

Example

Given this config:

StylesPath = styles

[*.md]
BasedOnStyles = Hello

My vale ls-config:

$ vale ls-config
{
  "BlockIgnores": {},
  "Checks": null,
  "Formats": {},
  "Asciidoctor": {},
  "FormatToLang": {},
  "GBaseStyles": null,
  "GChecks": {},
  "IgnoredClasses": null,
  "IgnoredScopes": null,
  "MinAlertLevel": 1,
  "Vocab": null,
  "RuleToLevel": {},
  "SBaseStyles": {
    "*.md": [
      "Hello"
    ]
  },
  "SChecks": {
    "*.md": {}
  },
  "SkippedScopes": null,
  "Stylesheets": {},
  "TokenIgnores": {},
  "WordTemplate": "",
  "RootINI": "/Users/jlacher/workspace/test/.vale.ini",
  "Paths": [
    "/Users/jlacher/Library/Application Support/vale/styles",
    "/Users/jlacher/workspace/test/styles"
  ],
  "ConfigFiles": [
    "/Users/jlacher/workspace/test/.vale.ini"
  ],
  "NLPEndpoint": ""
}

My rule:

extends: substitution
message: Consider using '%s' instead of '%s'
level: warning
ignorecase: false
swap:
  hello: goodbye

With .yaml

With rule: styles/Hello/PreferedTerms.yaml

> vale test.md
✔ 0 errors, 0 warnings and 0 suggestions in 1 file.

With .yaml

With rule: styles/Hello/PreferedTerms.yml

> vale test.md

 test.md
 1:1  warning  Consider using 'goodbye'        Hello.PreferedTerms 
               instead of 'hello'                                  

✖ 0 errors, 1 warning and 0 suggestions in 1 file.

It couldn't find an existing issue for this, though surely someone else must have been in the same position as me.

It does seem like it would be useful to support both .yaml and .yml.

In RFC 9512 section 3.3 they do say:

The "yaml" filename extension is the preferred one; it is the most popular and widely used on the web. The "yml" filename extension is still used. The simultaneous usage of two filename extensions in the same context might cause interoperability issues (e.g., when both a "config.yaml" and a "config.yml" are present).

jonathonlacher commented 2 months ago

Ah, it is mentioned in the docs.

Make sure your rule files end in extension .yml. Do not end them in .yaml, as Vale will not detect them.

jonathonlacher commented 2 months ago

Is there an appetite to support .yaml extension? I haven't fully looked at the codebase, but is the current barrier that it's just hard coded to look for .yml?

Like here for example: https://github.com/errata-ai/vale/blob/871dafd1e24500cee9d8ad82b25d42a136bb2103/internal/check/action.go#L118