Skip to content

feat(update): move a Vale rule's tests: cases into fixtures on 3.24.0 - #551

Merged
theCodeDrift merged 1 commit into
vendor/vale/3-24-0-contractfrom
vendor/vale/tests-to-fixtures
Oct 21, 2026
Merged

theCodeDrift merged 1 commit into
vendor/vale/3-24-0-contractfrom
vendor/vale/tests-to-fixtures

Conversation

@theCodeDrift

@theCodeDrift theCodeDrift commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

Stack (root → tip):

#549 makes validate and verify refuse a Vale rule's tests: key. 0.12.0 had accepted it, so a rule written since then would stop validating on upgrade. This adds a rule migration on #548's mechanism, so update --rules moves those cases into fixtures instead of leaving the author a by-hand list. It merges down into vendor/vale/3-24-0-contract.

What it does

src/rules/rule-migrations/vale-3-24-0-tests-to-fixtures.ts, registered in RULE_MIGRATIONS, keyed on Vale 3.24.0. It runs when the recorded Vale engine is below 3.24.0.

A case is a document and whether the rule fires on it, which is exactly a fixture. An in-rule case loads only its own rule, so any alert it expects is that rule's:

the case becomes
want with any text .tests/fail/
want that is empty .tests/pass/
no want, but contains .tests/fail/
only absent .tests/pass/
  • The fixture: the case's input, byte for byte. It is named for the case (flags a hedge → flags-a-hedge.md), with format as the extension (md by default, as Vale reads it). What want pins beyond that (line, column, message) is not something verification needs, and it is not carried.
  • The rule file: the tests: block is removed by its byte range from the YAML parser. Nothing is re-serialized, so comments and every other line stay as written.
  • Safe to rerun: fixtures are written before the rule file. A fixture with identical bytes counts as done, and a different file with the same name gets -2. A rerun, or a run that died between the two steps, changes nothing it already did.
  • Left alone: a rule with a case that reads through a view (this layout defines none) or names another rule file in rule:. Moving half its cases would be harder to finish than none. validate keeps naming that rule.

Issued rules

Per the rule-migration contract, the rewrite only applies to shapes the service never issued. Nothing in the Cloud corpus carries tests: (confirmed 2026-10-20), so no signed rule is touched. Rules users wrote themselves are what this is for.

Guidance

  • update (topic v18): the 0.13.3 opener is back to "Nothing here needs work by hand." The tests: paragraph now reads like the Haskell one: update --rules moves them for you, so don't do it by hand. It names the view and rule: cases as the exception.
  • The changeset on chore(vale): upgrade to Vale 3.24.0 #546 gains one sentence.

Tests

  • rule-migrate.test.ts: block removal for an indented list, a list at the key's column, a blank line inside, and a block ending the file with no newline. The bucket for each kind of case, naming and extensions, the rules it leaves alone, idempotence, finishing an interrupted run, never overwriting, failing on an unreadable rules tree, and keying on 3.24.0. A migrated rule passes validateValeRule.
  • reconcile-marker.test.ts: update --rules through the built CLI moves the cases, reports the files, and stamps the engines.
  • Two existing Haskell migration tests now record the current Vale version. They recorded only sg, so the Vale migration also read as pending in them.

pnpm typecheck, pnpm lint and pnpm test (2526 passed) are green locally, built.

Refs #549

`validate` refuses a Vale rule's `tests:` key from 3.24.0 on, and 0.12.0
had accepted it. A rule migration keyed on Vale 3.24.0 now writes each
case's input as a fixture under .tests/fail when it expects an alert and
.tests/pass when it expects none, named for the case with its format as
the extension, then deletes the block by its byte range. It never
overwrites a fixture, reruns as a no-op, and leaves a rule whose cases
read through a view or name another rule file untouched. No issued rule
carries the key.
@theCodeDrift
theCodeDrift merged commit 243c24f into vendor/vale/3-24-0-contract Oct 21, 2026
8 checks passed
@theCodeDrift
theCodeDrift deleted the vendor/vale/tests-to-fixtures branch October 21, 2026 00:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant