Repository navigation
M3 G6: eslint-plugin-webtops (W-23, W-36, W-37) - #62
Merged
Merged
Conversation
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>
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>
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
M3 G6 adds
packages/eslint-plugin-webtops, with three rules for laws that no existing ESLint rule covers. The presets enable them aterror.G6a and G6b: the plugin and its rule tests
Each rule has valid and invalid
RuleTestercases.complete-tailwind-classes`bg-${c}-500`,`${a}${b}`) or by concatenation ("bg-" + c,"bg-".concat(c),[...].join()), inclassName,classandclsx/cn/twMerge/cva-style helpersno-unsanitized-htmlset:html,dangerouslySetInnerHTML,innerHTML/outerHTML,insertAdjacentHTMLanddocument.write. A literal or a sanitizer result is allowedpublic-env-onlyprocess.envorimport.meta.envname, computed or destructured reads, the whole env object, andastro:env/serverThe tests that kill surviving mutants found one bug, now fixed: a
-expression such as"bg-" - csent W-23 into endless recursion.G6c: the presets enable the rules
Delivery: the plugin ships inside the
web-topspackage, with its build infiles, and theweb-tops/eslintpreset imports it: from source in a checkout, from the build when installed. An adopter has one dependency and no separate pin. Apreparescript builds the plugin on install.W-37 scope: client code only,
**/*.{jsx,tsx}. Astro frontmatter is server code..astroclient 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 thebase,reactandastrovariants:ui-componentsweb-appastro-sitets-library,node-servicesrc/presets/class-rules.test.tschecks, for each of the five launch classes, that the plugin rules its preset sets toerrorequal 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
WEB_TOPS.mdpackages/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 readersrc/cli/layout.test.tspackages/eslint-plugin-webtops/comes off the "not yet" listpackage.jsonfilesand thepreparebuildlaws/W-37.yamlsrc/init/*and thefixtures/init/*goldensGate on this head
layers: 5 in range, 5 ran, 0 failed, 0 not-evaluated.🤖 Generated with Claude Code