Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Extend Script Based Rules To Include Individual Message per Match #680

@jdkato

Description

@jdkato

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions