Here, the action is a to replaceJavascript with JavaScript. In such
cases, we know what we want to suggest to the user ahead of time and Vale can
easily generate the appropriate output message.
However, there are cases in which we don’t know the appropriate suggestion
ahead of time. For example, consider the following rule:
yaml
Copy
extends: existencemessage: "'%s' should be '%s'."level: erroraction: name: edit params: - regex - '(w+)_(w+)' - '$1-$2'tokens: - 'w+_w+'
This rule is designed to catch instances of snake_case and suggest that the
user convert to kebab-case. In this case, the exact suggestion is dependent
on a string transformation that needs to be computed at runtime.
Using the edit action allows us to define a rule that can dynamically
generate suggestions based on the matched text in CLI output:
As you can see, the CLI output is dynamically computing the suggestion based on
the matched text.
In both static and dynamic cases, any application that uses the Vale Language Server will be able to provide the user with a list of
“Quick Fixes” that can be applied to the document.