-
-
Notifications
You must be signed in to change notification settings - Fork 180
Description
Discussed in #679
Originally posted by p0fi September 11, 2023
Currently in script based rules a match must be a map with the keys begin and end set to integer indexes into the scope. When displaying the error message vale uses the message field of the rule definition.
Script based rules could be made more powerful and versatile if the returned match could also have an optional custom message set per match.
A match could be added to the matches array like this
matches = append(matches, {begin: start, end: end, message: "custom error message"})
Any match with a custom message set would be displayed using this message, matches without this property set would display the default message of the rule like it is handled today.
This way a single script could be ran across the file and check for a a class or errors in the file and report a meaningful case by case error message. Currently the script based rule would have to be copied multiple times and slightly altered in each version to detect the concrete error case. This would also make vale run the almost identical script over any given input files multiple times.