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

Different rules for different file types? #832

Closed tbazant closed 1 month ago

tbazant commented 1 month ago

Check for existing issues

Describe the feature

I'm facing the following problem: our company is using XML DocBook and AsciiDoc as source languages. As of now, we share the same set of style rules. Although 95% of rules apply to both languages, some are correct in one language and not applicable in the other one. For example, Replace " with <quote/> does not apply to AsciiDoc, same goes for Use &nbsp; to join number and unit in 10 GB. Is there any solution how to pick rules that differ based on the file source language except for creating a whole new set of rules?

jdkato commented 1 month ago

You can do this in your .vale.ini file:


[*.adoc]
# AsciiDoc rules ...

[*.xml]
# DockBook rules ...

Or at the rule-level by using a format-specific scope:

scope: text.adoc
tbazant commented 1 month ago

You can do this in your .vale.ini file:

[*.adoc]
# AsciiDoc rules ...

[*.xml]
# DockBook rules ...

how about having 2 subdirs, adoc, xml, common and use

[*.adoc]
BasedOnStyles=adoc/
[*.xml]
BasedOnStyles=xml/
[*.adoc, *.xml]
BasedOnStyles=common/

is that possible? Or at the rule-level by using a format-specific scope:

scope: text.adoc

can there be more scopes combined? such as

scope: text.adoc, raw.adoc
jdkato commented 1 month ago

Yes:

[*.adoc]
BasedOnStyles = Common, AsciiDoc

[*.xml]
BasedOnStyles = Common, XML

where Common, AsciiDoc and XML are custom styles on your StylesPath.

can there be more scopes combined?

Yes, see Multi-scope rules. However, raw shouldn't be combined with any other scope.