Skip to content

M3 G6: eslint-plugin-webtops (W-23, W-36, W-37) - #62

Merged
VirtualMachinist merged 10 commits into
mainfrom
m3/g6-plugin-tsx
Nov 20, 2026
Merged

VirtualMachinist merged 10 commits into
mainfrom
m3/g6-plugin-tsx

Conversation

@VirtualMachinist

@VirtualMachinist VirtualMachinist commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

M3 G6 adds packages/eslint-plugin-webtops, with three rules for laws that no existing ESLint rule covers. The presets enable them at error.

G6a and G6b: the plugin and its rule tests

Each rule has valid and invalid RuleTester cases.

Rule Law What it catches
complete-tailwind-classes W-23 Class strings built by interpolation (`bg-${c}-500`, `${a}${b}`) or by concatenation ("bg-" + c, "bg-".concat(c), [...].join()), in className, class and clsx/cn/twMerge/cva-style helpers
no-unsanitized-html W-36 set:html, dangerouslySetInnerHTML, innerHTML/outerHTML, insertAdjacentHTML and document.write. A literal or a sanitizer result is allowed
public-env-only W-37 A non-public process.env or import.meta.env name, computed or destructured reads, the whole env object, and astro:env/server

The tests that kill surviving mutants found one bug, now fixed: a - expression such as "bg-" - c sent W-23 into endless recursion.

G6c: the presets enable the rules

  • Delivery: the plugin ships inside the web-tops package, with its build in files, and the web-tops/eslint preset imports it: from source in a checkout, from the build when installed. An adopter has one dependency and no separate pin. A prepare script builds the plugin on install.

  • W-37 scope: client code only, **/*.{jsx,tsx}. Astro frontmatter is server code. .astro client script blocks follow with the Astro parser (G7). The scope is written in the preset and in W-37's law data.

  • Each class enables exactly the plugin rules of the laws it maps. The preset picks them per class (webtopsConfigs(class)) on the base, react and astro variants:

    Class Rules
    ui-components W-36, W-37
    web-app W-36, W-37, W-23
    astro-site all three
    ts-library, node-service W-36
  • src/presets/class-rules.test.ts checks, for each of the five launch classes, that the plugin rules its preset sets to error equal the plugin rules of the laws it maps. Any drift fails the test.

That the laws layer judges these rules as laws is checked once the laws readers land (G4).

Declared exceptions

File Change
WEB_TOPS.md §17: packages/ is in the tree and off the "not yet" line. §8.2 is regenerated for W-37's scope, and the §5 note no longer lists W-37 as a law without a reader
src/cli/layout.test.ts packages/eslint-plugin-webtops/ comes off the "not yet" list
package.json files and the prepare build
laws/W-37.yaml The rule's scope in the reader cell (R97)
src/init/* and the fixtures/init/* goldens The plugin rules each class enables

Gate on this head

  • layers: 5 in range, 5 ran, 0 failed, 0 not-evaluated.
  • Mutation: 430 killed, 0 survived. 180 were excluded as compile errors, and the run took 2m34s on a 10-CPU machine. Module-level data moved into functions, so a mutant there no longer reruns the whole suite, and the plugin build runs once, not once per mutant.
  • The highest CRAP score is 4.00.

🤖 Generated with Claude Code

VirtualMachinist and others added 8 commits November 19, 2026 10:17
packages/eslint-plugin-webtops holds three rules, each tested with
ESLint's RuleTester under Vitest, with valid and invalid cases:

- complete-tailwind-classes (W-23): a class token built by interpolation
  (`bg-${c}-500`, `${a}${b}`) or concatenation ("bg-" + c, "bg-".concat(c))
  in className, class and the arguments of clsx, cn, twMerge, cva and
  the like. Whole tokens chosen by a condition or a lookup stay valid.
- no-unsanitized-html (W-36): set:html, dangerouslySetInnerHTML,
  innerHTML, outerHTML, insertAdjacentHTML and document.write take a
  literal or the result of a sanitizer.
- public-env-only (W-37): process.env and import.meta.env reads of a
  name that is not public, computed reads, the whole object, and
  astro:env/server.

The rules read nodes by shape, because ESLint's typings leave out JSX.
The package builds with tsc and loads under Node. Enabling the rules in
the presets (G6c) waits for the presets to merge.

Declared exceptions: WEB_TOPS.md section 17 (packages/ is in the tree)
and src/cli/layout.test.ts.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Stryker instruments the sources in its sandbox, so a build that type
checks them fails there. The test builds with --noCheck; the types are
checked by the gate's own tsc run on the same files.

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

A binary expression with an operator other than + (`"bg-" - c`) sent
the W-23 rule into endless recursion; only plus chains are joined now.

Tests: direct tests of the node-reading helpers, each rule's meta stated
in full, and cases for each helper name, each side of a glued
interpolation, and the env object in unusual positions. Branches that no
input could tell apart are gone: the kind checks a member lookup already
makes, the computed-key test, and the placeholder payload of an empty
dangerouslySetInnerHTML.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The operands of a sum are found by node type, so only a binary
expression can split, and only on +. Two cases: a glue after the last
interpolation only, and a non-plus operand nested in a sum.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…side the package (G6c)

The web-tops/eslint preset imports eslint-plugin-webtops from its build, which
the package ships in files, so an adopter has one dependency and no separate
pin. The build runs on install (prepare), and before the tests through a
Vitest global setup.

- W-36 no-unsanitized-html is at error in every variant.
- W-23 complete-tailwind-classes is at error in the react and astro variants.
- W-37 public-env-only is at error in the react and astro variants, on
  **/*.jsx and **/*.tsx only: frontmatter is server code. W-37's reader cell in
  laws/W-37.yaml and section 8.2 carries the scope.

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

A preset enables exactly the plugin rules the laws of its class map. W-23
(complete-tailwind-classes) maps to astro-site and web-app only, so the react
variant, which ui-components used, loses it, and a new react-app variant, which
web-app now names, keeps it. W-36 and W-37 are unchanged.

A new test reads every launch class's variant, the rules its preset sets to
error and the rules of the laws the class maps in the catalog, and requires the
webtops/* sets to be equal. A law that names a plugin rule a later step builds
(the Astro rules) is left out until the plugin has it; the step that adds the
rule must then enable it.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@VirtualMachinist VirtualMachinist added the protocol-change Changes laws, schema, profiles, thresholds, budgets or normative spec text label Nov 19, 2026
The mutation legs ran past their budget. The causes, and what changes:

- Module-level data (tables, lists, rule metadata) became functions and
  getters, so a mutant in it no longer reruns the whole suite as a static
  mutant.
- The test run no longer builds the plugin: the preset reads the plugin's
  source in a checkout and its build once published. vitest.config.ts,
  vitest.global-setup.js and src/cli/m3-open.test.ts are back as they were.
- The web-app variant split is undone, so src/init (profile.ts, render.ts and
  their tests) and profiles/web-app.yaml are back as they were. The preset
  decides the plugin's rules by class instead: `class` is an option, and the
  project's web-tops.yaml says which when it is left out, so the importer init
  writes is unchanged. W-36 applies to every class, W-37 to the three with a
  UI and W-23 to astro-site and web-app.
- class-rules.test.ts reads the profile and law files itself and requires the
  enabled webtops/* rules to equal the rules of the laws each class maps.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@VirtualMachinist

Copy link
Copy Markdown
Member Author

Closed for now so that only one open PR edits WEB_TOPS.md at a time. The step-3 law probe goes first. This branch reopens after it merges, with main merged in and its CI mutation run brought within the time budget.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@VirtualMachinist
VirtualMachinist merged commit 57880fd 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

protocol-change Changes laws, schema, profiles, thresholds, budgets or normative spec text

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant