This release adds vale test, a test runner for your rules. A rule that matches nothing still loads, runs, and reports success. You only find out it's broken when it misses something. Now each rule can carry its own test cases: a short document, and the alerts linting it should produce.
extends: existence
message: "Consider removing '%s'."
tokens:
- perhaps
tests:
- name: flags a hedge
input: Perhaps we should ship.
want: |
1:1:House.Hedging:Consider removing 'Perhaps'.
Running vale test lints each case and shows a diff when the output doesn't match. A case can pin the exact output (want), check for part of it (contains), or check that something is left alone (absent). It can run one rule on its own or go through your project's configuration, and it can read its input as another format or through a View. script rules are tested the same way. --coverage fails any rule that no case makes fire, and the exit codes are built for CI.
See Testing and the announcement post.
Changelog
- 2ee7817 fix: A rule whose
testsdon't parse failsvale testinstead of vanishing - 77da0b0 refactor: Typed errors, pattern errors at the token, and readable contexts
- 634b321 fix: Errors show the real exit code, honor --no-color, and point at the config
- db39c40 feat:
BasedOnStyles = NONE, the spelled-out empty value - bc8b91d perf: Don't parse a file no rule can run on
- c283a4d feat: Conditional sections,
[glob if expr] - 08923bd feat:
vale test, and install a package's own dependencies for it - 424f6e6 fix: Keep a fenced block skipped when both
preandcodeare in SkippedScopes - 84deb6c fix: Keep non-breaking and narrow spaces beside inline markup
- 8cbda87 feat(code): parse C# comments with the C# grammar (#1196)
- 24f277b test: add
vale testcases