Skip to content

M3 G7: Astro rules in eslint-plugin-webtops (W-28, W-30, W-31) - #69

Merged
VirtualMachinist merged 7 commits into
mainfrom
m3/g7-plugin-astro
Nov 20, 2026
Merged

VirtualMachinist merged 7 commits into
mainfrom
m3/g7-plugin-astro

Conversation

@VirtualMachinist

@VirtualMachinist VirtualMachinist commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

M3 G7 adds three Astro rules to eslint-plugin-webtops, running on the Astro parser.

G7a and G7b: the rules

Each rule has valid and invalid cases.

Rule Law What it catches
astro-client-load-ack W-28 A client:load directive without an ack. Until the ack ledger lands, the ack is an <!-- webtops-ack W-28: reason --> comment directly before the element
astro-assets-image W-30 An image that doesn't go through astro:assets (<Image>, <Picture>) with dimensions
astro-frontmatter-size W-31 Frontmatter of more than 10 statements, which should move to a module. It is tested at 10 statements (passes) and 11 (fails)
  • Shared ack reading: src/rules/ack.ts. Its ackReason is the one place the ack ledger (G8) will widen.
  • Registration: src/index.ts registers the three rules, and index.test.ts covers that.
  • Preset: src/presets/eslint.js enables the rules for the Astro class and sets up the Astro file parser. The parser setup is also what makes the astro variant lint .astro files at all, and it applies W-37 to client <script> blocks.
  • Tests: src/presets/presets.test.ts checks the rules per class, and runs a live test on a scratch Astro project.
  • .astro outside the Astro class: when a class maps an .astro-scoped rule and the project depends on astro, the preset adds the Astro parser config, whatever its variant. A web-app project's .astro files therefore parse. init lists eslint-plugin-astro among web-app's conditional tools, and a test checks that each class's preset can parse every file kind its rules match.
  • Golden: fixtures/init/astro-site/eslint.preset.json.golden is updated, because the astro-site preset output changed.

G7c, reading W-28's ack from the ledger, completes when G8 lands. The comment ack is the named stub until then.

Gate on this head

  • layers: 5 in range, 5 ran, 0 failed, 0 not-evaluated. The gate took 6m51s on a 10-CPU machine.
  • Mutation: 469 killed, 0 unexplained survivors. The 3 explained were already in the ledger.
  • The highest CRAP score is 4.00.

🤖 Generated with Claude Code

VirtualMachinist and others added 7 commits November 19, 2026 18:36
… <script> blocks (G7)

Three rules on the Astro parser, read by node shape like the others:

- astro-client-load-ack (W-28): a client:load directive needs a comment right
  before the element, <!-- webtops-ack W-28: reason -->. The comment is the
  only acknowledgement read here (ack.ts is the one place to widen when the
  ledger form lands).
- astro-assets-image (W-30): no <img>; an Image or Picture imported from
  astro:assets needs width and height, inferSize, or a spread.
- astro-frontmatter-size (W-31): more than 10 statements in the frontmatter,
  nested ones counted, imports, type declarations and the template not.

The preset enables W-28 for web-app and astro-site, W-30 and W-31 for
astro-site, all on .astro files, and public-env-only also on the <script>
blocks of a page (the files eslint-plugin-astro names page.astro/0.ts).

Linting an .astro file through the preset did not work: the Astro parser does
not take projectService, and the script blocks have no project. The astro
variant now gives .astro files `project`, and script blocks no types.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…same lazy data

The G7 rules take their module data as functions and their metadata as
getters, the plugin and the preset decide the Astro rules by class (W-28 for
astro-site and web-app, W-30 and W-31 for astro-site), and the astro variant
keeps the parser options that make .astro files and their script blocks lint.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…el (G7)

The Astro rules read their constants, regex and metadata where they are used,
as the first three rules do, and tests now pin what the first G7 gate left
alive: a spread beside other attributes, a named Image from another module, a
member element, an empty comment between an acknowledgement and its element,
and an acknowledgement written as plain text.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…the files its rules match (G7)

A class that maps an .astro-scoped rule now gets the Astro parser config when the
project depends on astro, whatever its variant. Before, web-app (react variant) had
W-28 enabled on **/*.astro with no parser, so a page failed to parse.

init lists eslint-plugin-astro among web-app's conditional tools (a new optional
astro_tools list in the profile), installed and locked only where the project
depends on astro.

Tests: a live web-app run with an .astro file, the preset's parser choice, the init
tool list, and class-rules.test.ts lints a module, a React module and a page for
every class and fails on any parse error.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The helper cleans up through onTestFinished instead of a module-level list, so
there is no state to leave unobserved, and its prefix, cleanup and tsconfig text
are pinned by tests.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@VirtualMachinist
VirtualMachinist merged commit bb4c335 into main Nov 20, 2026
2 checks passed
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