existence

Checks

existence

existence

Learn about the existence extension point.

Name
Type
Description

append

bool

Adds raw to the end of tokens, assuming both are defined.

ignorecase

bool

Makes all matches case-insensitive.

nonword

bool

Removes the default word boundaries (\b).

action

array

Options for correcting matches, see the actions section.

raw

array

A list of tokens to be concatenated into a pattern.

tokens

array

A list of tokens to be transformed into a non-capturing group.

exceptions

array

An array of strings to be ignored.

vocab

bool

If 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.

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 sentencesarrow-up-right or the position of punctuation after quotesarrow-up-right.

circle-info

Heads up!

See Vale Studioarrow-up-right for a live editor that can help you write and test your rules, including generating the compiled regular expression.

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:

Which, after compilation, becomes:

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

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

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 improved commenting and readability of complex patterns.

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.

Transform substitution