Skip to content

refactor: strict types for the test suite#21147

Merged
alexander-akait merged 7 commits into
mainfrom
claude/pr-21145-lint-fixes-bnyqwc
Jun 9, 2026
Merged

refactor: strict types for the test suite#21147
alexander-akait merged 7 commits into
mainfrom
claude/pr-21145-lint-fixes-bnyqwc

Conversation

@alexander-akait

Copy link
Copy Markdown
Member

Summary

Enables strict type-checking for the test files (test/*.{unittest,basictest,test,longtest}.js and test/helpers/**) and annotates them so tsc -p tsconfig.types.test.json passes. Builds on #21145: completes the remaining type errors, makes the lint suite green, and addresses the GitHub code-quality review (misleading multi-line cast, dead errored locals, superfluous CustomError argument).

What kind of change does this PR introduce?

refactor

Did you add tests for your changes?

No — this only adds JSDoc types and lint/formatting fixes to existing test files; no behavior changes, so no new test cases. Existing suites still pass.

Does this PR introduce a breaking change?

No.

If relevant, what needs to be documented once your changes are merged or what have you already documented?

n/a

Use of AI

AI (Claude Code) was used to finish the test type annotations, resolve the remaining tsc errors, fix ESLint/Prettier issues, and address the code-quality review comments.


Generated by Claude Code

Include test/helpers/**/*.js in tsconfig.types.test.json and annotate the
helpers with JSDoc so they pass under strict checkJs.
… strict explicitly

Type the test helpers with concrete types (config, jest, CSS-rule, worker and
event shapes) instead of the EXPECTED_ANY escape hatch, and set strict: true
explicitly in tsconfig.types.test.json.
Checkpoint while typing the *.unittest/*.test/*.basictest/*.longtest suites.
Not yet green; remaining files still being annotated.
- Resolve remaining tsc errors in strict test type-check (unused
  @ts-expect-error directives, SuiteConfig minimize/snapshot, cleverMerge
  CasesMap, webpack-cli optional peer).
- Run ESLint and Prettier across the newly type-checked test files.
- Address GitHub code-quality review: drop misleading multi-line cast in
  TestCases.template, remove dead errored locals in Validation.test, and
  drop superfluous CustomError argument.
@changeset-bot

changeset-bot Bot commented Jun 9, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 155a60a

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

This PR is packaged and the instant preview is available (9bd0b91).

Install it locally:

  • npm
npm i -D webpack@https://pkg.pr.new/webpack@9bd0b91
  • yarn
yarn add -D webpack@https://pkg.pr.new/webpack@9bd0b91
  • pnpm
pnpm add -D webpack@https://pkg.pr.new/webpack@9bd0b91

Comment thread test/JavascriptParser.unittest.js
@codspeed-hq

codspeed-hq Bot commented Jun 9, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 24.97%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 2 improved benchmarks
❌ 2 regressed benchmarks
✅ 140 untouched benchmarks

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Memory benchmark "asset-modules-inline", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' 322.6 KB 1,290.9 KB -75.01%
Memory benchmark "devtool-eval", scenario '{"name":"mode-production","mode":"production"}' 5.4 MB 7.5 MB -27.92%
Memory benchmark "future-defaults", scenario '{"name":"mode-production","mode":"production"}' 10.1 MB 7.4 MB +35.52%
Memory benchmark "asset-modules-bytes", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' 319.3 KB 246 KB +29.83%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing claude/pr-21145-lint-fixes-bnyqwc (155a60a) with main (87394de)

Open in CodSpeed

@alexander-akait alexander-akait merged commit 9bd0b91 into main Jun 9, 2026
126 checks passed
@alexander-akait alexander-akait deleted the claude/pr-21145-lint-fixes-bnyqwc branch June 9, 2026 17:15
alexander-akait added a commit that referenced this pull request Jun 10, 2026
Annotate the visitor arrays and cast the `VisitorMap` / visitor params, matching
the strict test-suite typing introduced on main (#21147), so the two added
`as: "block-contents"` tests pass `tsc -p tsconfig.types.test.json`.

https://claude.ai/code/session_01RtuVwAXk4wSAPE85d8qadX
alexander-akait added a commit that referenced this pull request Jun 10, 2026
…option (#21157)

* feat: resolve url() inside HTML style attributes via CSS parser "as" option

Add a CSS parser `as` option (default `"stylesheet"`) that selects the
parse entry point. With `as: "declaration-list"` the source is parsed as a
block's contents (CSS Syntax §5.4.5) instead of a full stylesheet, which is
the correct model for an element's `style="..."` attribute.

HTML modules now route URL-bearing `style` attributes through the CSS
pipeline (via the new `html-style-attribute` dependency category, parsed
with `as: "declaration-list"`), so `url()` / `image-set()` references in
inline styles resolve relative to the HTML file.

https://claude.ai/code/session_01RtuVwAXk4wSAPE85d8qadX

* refactor(css): inject the top-level consumer into the CSS walk

Instead of switching on an `as` string inside `grammar`, `SourceProcessor`
now accepts a `consume` driver (a `TopLevelConsumer`) and defaults to the
stylesheet consumer. `consumeADeclarationList` is exported as a reusable
driver, and `CssParser` maps its `as` option to it — so the walk no longer
hardcodes how the source is parsed.

https://claude.ai/code/session_01RtuVwAXk4wSAPE85d8qadX

* refactor(css): drive the walk through the spec parse* entry points

The injectable top-level driver now routes through the §5.3 `parse*`
functions instead of the §5.4 `consume*` internals: the default uses
`parseAStylesheetsContents` and a `style` attribute uses the new
`parseADeclarationList` ("parse a block's contents", §5.3.6). Both receive
the already-built `TokenStream`, which `normalizeIntoTokenStream` returns
as-is, so there is no re-tokenization. `parseAStylesheetsContents` gains the
same optional streaming `onRule` sink `consumeAStylesheetsContents` already
had, so the default path keeps its rule-by-rule memory profile.

https://claude.ai/code/session_01RtuVwAXk4wSAPE85d8qadX

* refactor(css): use parseABlocksContents directly for style attributes

Drop the `parseADeclarationList` wrapper — its name reflects the old spec
term "parse a list of declarations", which CSS Syntax renamed to "parse a
block's contents". CssParser now builds the `style`-attribute top-level
parser straight from `parseABlocksContents` (§5.3.6), reusing the existing
token stream as before.

https://claude.ai/code/session_01RtuVwAXk4wSAPE85d8qadX

* refactor(css): pass parseAStylesheet / parseABlocksContents as the walk driver

Drop the "declaration-list" terminology and the grammar's internal default.
`SourceProcessor#process` now requires the caller to pass the top-level parse
entry point, and CssParser passes one of the spec §5.3 functions directly:
`parseAStylesheet` for a stylesheet, `parseABlocksContents` for a block's
contents (the `as: "block"` mode, e.g. an HTML `style` attribute). The walk
reuses the existing token stream and walks the returned nodes. Revert the
now-unused streaming `onRule` extension on `parseAStylesheetsContents`.

https://claude.ai/code/session_01RtuVwAXk4wSAPE85d8qadX

* refactor(css): align `as` value with CSS spec and drop dead onRule

Rename the `style` attribute parse mode from `as: "block"` to
`as: "block-contents"` so the option values match the CSS Syntax §5.3 entry
points ("parse a block's contents" / "parse a stylesheet"), leaving room for
future spec-named modes. Also remove the now-unused `onRule` streaming param
from `consumeAStylesheetsContents`.

https://claude.ai/code/session_01RtuVwAXk4wSAPE85d8qadX

* refactor(css): keep stylesheet streaming intact, make block-contents purely additive

Restore the original "consume a stylesheet's contents" streaming driver
(`consumeAStylesheetsContents(ts, onRule)`) for the default `as: "stylesheet"`
mode — the spec parse logic is unchanged. The `as: "block-contents"` mode is
now a small additive branch in the walk's grammar that parses a block's
contents instead. Drops the `TopLevelParser` indirection.

https://claude.ai/code/session_01RtuVwAXk4wSAPE85d8qadX

* refactor(css): drive the walk through a uniform top-level consumer table

Give `consumeABlocksContents` the same streaming `onNode` callback that
`consumeAStylesheetsContents` already exposes, so both share a `(ts, onNode)`
shape. The walk's `grammar` now dispatches `as` through a `TOP_LEVEL_CONSUMERS`
map instead of a branch — a future `as` mode is one map entry, no new walk
code, and every mode streams (no full AST retained).

https://claude.ai/code/session_01RtuVwAXk4wSAPE85d8qadX

* chore: rename changeset file to match block-contents terminology

https://claude.ai/code/session_01RtuVwAXk4wSAPE85d8qadX

* feat(html): add stylesheet-style-attribute source type, rename stylesheet-inline

Let developers route a custom HTML attribute's value through the CSS pipeline
as a block's contents (a declaration list, like a `style` attribute) via the
new `stylesheet-style-attribute` source type, alongside `stylesheet-style` for
a full inline stylesheet. Renames the experimental `stylesheet-inline` type to
`stylesheet-style` so the inline pair mirrors `<style>` / `style=`.

https://claude.ai/code/session_01RtuVwAXk4wSAPE85d8qadX

* test(css): strictly type the new block-contents walk tests

Annotate the visitor arrays and cast the `VisitorMap` / visitor params, matching
the strict test-suite typing introduced on main (#21147), so the two added
`as: "block-contents"` tests pass `tsc -p tsconfig.types.test.json`.

https://claude.ai/code/session_01RtuVwAXk4wSAPE85d8qadX
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