Docs
Checks
existence

existence

Learn about the existence extension point.

NameTypeDescription
appendboolAdds raw to the end of tokens, assuming both are defined.
ignorecaseboolMakes all matches case-insensitive.
nonwordboolRemoves the default word boundaries (\b).
actionarrayOptions for correcting matches, see the actions section.
rawarrayA list of tokens to be concatenated into a pattern.
tokensarrayA list of tokens to be transformed into a non-capturing group.
exceptionsarrayAn array of strings to be ignored.
vocabboolIf false, disables all active vocabularies for this rule (default: true).

The most general extension point is existence. As its name implies, it looks for the “existence” of particular tokens.

yaml
extends: existence message: Consider removing '%s' level: warning ignorecase: true tokens: - appears to be - arguably

These tokens can be anything from simple phrases (as in the above example) to regular expressions—e.g., the number of spaces between sentences or the position of punctuation after quotes.

tokens

The most common entry point for this extension point is the tokens key, which is a list of strings or regular expressions to be transformed into a word-bounded, non-capturing group:

yaml
tokens: - appears to be - arguably

Which, after compilation, becomes:

regex
(?i)(?m)\b(?:appears to be|arguably)\b

This is a convenience feature to avoid having to write the same boilerplate for every token in a rule.

raw

When you want more control over the regular expression, you can use the raw key instead:

yaml
extends: existence message: "Incorrect use of symbols in '%s'." ignorecase: true raw: - $[d]* ?(?:dollars|usd|us dollars)

This allows you to write more complex patterns without having to worry about any post-processing. Each entry in raw is concatenated with the previous entry, allowing for improve commenting and readability of complex patterns.

message

The message key is a string that will be used to generate the final message when a match is found. The (optional) %s placeholder will be replaced with the matched text.