Repository navigation
feat: create_analyzer().add() for many inputs (stacked on #647) - #652
Draft
bartveneman wants to merge 25 commits into
Draft
bartveneman wants to merge 25 commits into
bartveneman wants to merge 25 commits into
Conversation
Adds the new engine next to the legacy analyze(), exposed as the temporary `./next` subpath until the old code is removed: - adapter/css-parser: the only module that talks to the parser - define_collector, create_analyzer, analyze and merge - one count shape (create_counter, merge_counts, summarize) with opt-in locations - declarative dispatch table: parse options follow subscriptions, one shared value walk, lazy memoized declaration facts - incremental add() with per-file `source` on locations - oxlint overrides (prefer-const, function declarations, adapter-only parser imports) for the new code, plus a pkg.pr.new preview workflow Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Reworks the public utils on the /selectors, /values and /atrules subpaths to one contract: input is `string | node`, output is plain data. No callbacks, no parser nodes in results. - get_specificity, compare_specificity, get_complexity (number[]), get_vendor_prefixes, get_accessibility_selectors, get_combinators - analyze_animation, destructure_font_shorthand, is_value_reset, get_prefixed_values, get_value_browserhacks - get_supports_browserhacks, get_media_browserhacks - colour keyword sets renamed to snake_case - remove deprecated is_ie9_hack The legacy analyze() is adapted to the new utils and its output is unchanged. Adds contract tests (text vs node parity) for each util. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Ports the nine collectors css-design-tokens reads onto the new engine: colors (+ formats, per-property counts), font_sizes, font_families, line_heights, gradients, box_shadows, border_radiuses, durations and timing_functions, exposed on the new ./collectors subpath. The ./presets subpath adds analyze_design_tokens and design_tokens_collectors. Engine additions the collectors needed: - value handlers receive the node kind - lazy, shared ctx facts: clean_value_text and font_shorthand - context counters track contexts only with `contexts: true` Output matches the 9.x analyzer on a fixture covering all nine (parity test). Deliberate differences: contexts are keyed by the normalized property, and values are lowercased consistently. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Covers the stylelint use cases next to colors: max-unique-z-indexes, max-unique-colors and max-average-selector-specificity. - z_indexes counts z-index values - specificity counts every selector as "a,b,c"; summarize_specificity derives min, max, sum, mean and mode and matches the 9.x analyzer - summarize_numbers/summarize_frequencies derive min, max, range, sum, mean, mode and median from counted values, so averages stay mergeable across files and runs - the engine no longer descends into selectors nested in :is()/:not(), so each selector is dispatched once Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Adds the collectors for every other group of the 9.x report, so the full report can now be built from collectors: - stylesheet (size, lines, comments, embedded content) - atrules (all at-rules incl. font-face, import, media, supports, keyframes, container, layer, property, function, scope) - rules, selectors, declarations, properties - text_shadows, displays, units, keywords, resets, value_prefixes, value_browserhacks, value_complexity, animation_names Names that are defined and used (keyframes, containers, layers, custom properties, anchor names) are tracked per collector and merge across files. Numeric series are stored as counted values so min, max, mean, mode and median stay derivable and mergeable. Every group has a parity test against the 9.x analyzer on one fixture. The engine now skips @supports conditions, so they are no longer mistaken for declarations. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
- analyze_all: every collector in one call, flat snake_case result (one key per collector), mergeable with merge() - analyze_compat: the 9.x report (nested, camelCase, same numbers), built from the collectors; `useLocations` and `__meta__` are gone - opt-in `sequence: true` on the counting collectors keeps numeric series in source order (9.x `items`, used for charts); compat turns it on - context collectors take `property: 'as_written'` for 9.x-style per-property keys; compat uses it - `pnpm test:compat` runs the existing 9.x topic tests against analyze_compat (tests about useLocations are skipped); CI runs it - shared fixtures, preset tests and a knip config that treats every test file as an entry Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…alyzer The new API now lives at `.`: analyze, create_analyzer, merge, define_collector, the counters and summaries. The 9.x analyze() is gone; `analyze_compat` from `/presets` returns the same report. - delete the monolithic analyze(), useLocations, Collection, ContextCollection and AggregateCollection, plus deprecated exports (hasVendorPrefix, isIe9Hack) - freeze the 9.9.6 output as golden JSON; analyze_compat must match it - run the 9.x topic tests against analyze_compat; port the useLocations tests to collectors - apply prefer-const and function declarations to all of src, rename the remaining camelCase helpers - drop the temporary `./next` subpath and the compat test config - rewrite the readme for pnpm and the collector API; add MIGRATION.md BREAKING CHANGE: see MIGRATION.md Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… selectors); rename remaining camelCase locals to snake_case Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The 9.x topic tests ran the whole analyzer for every case. They are now unit tests that live next to the code they test: - one test file per collector in src/collectors, each running only that collector (src/test-utils.ts has plain() and series() to compare results) - direct tests for the utilities (specificity, complexity, font shorthand, browserhacks, prefixes, resets, property helpers) and for the adapter, using test.each tables - the only integration test left is the compat preset against the golden 9.x output - add CONTRIBUTING.md with the style and test conventions Also rename all remaining camelCase locals, parameters and helpers to snake_case, and fix walk_value reporting the value node itself. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
pkg.pr.new publishes previews to its own registry, not npm, so the trusted publishing audit does not apply. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Remove our own preview workflow; main now has pkg-pr-new.yml. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The adapter layer was 435 lines of mostly thin wrappers for a parser swap that is not planned. Simplicity wins over flexibility: - the engine parses and walks with css-parser directly; collector handlers get typed nodes (Declaration, Rule, Atrule, Selector) - helpers that only one collector needs now live in that collector; the small shared ones are in collectors/shared.ts - text-or-node input handling for the utilities moves to src/input.ts - remove the lint rule that restricted parser imports No behaviour change: the full suite, golden 9.x output included, still passes. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The 9.x compatibility layer (analyze_compat, compat_collectors, the golden 9.x output and the tests that use them) moves to its own pull request so the package stays smaller and it can be revisited later. The core keeps what compat needed from the collectors: `sequence`, `property: 'as_written'`, and the collectors themselves. The tests that ran through analyze_compat now run the collectors directly. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Review feedback: - the lint rules (prefer-const, no-var, func-style) are global settings now instead of an override for src - enforce `curly` and add braces to the 100+ single-line ifs - tsdown builds the main entry and src/*/index.ts with a glob (the engine index stays internal) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…perty Review feedback: - every `.text`, `.name`, `.block`, `.prelude` read hits the parser's arena: read them once and reuse (at-rules, rules, selectors, properties, keywords, animations, browserhacks, the shared context) - replace the `...(cond ? { x } : {})` pattern with explicit `undefined` (location `source`, locations of font faces and embedded content, sequences) - track `@property` registrations as defined and `var()` as used, like keyframes, containers and layers (atrules `properties`) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Merging results of separate runs (`merge()`, `merge_counts`, `merge_context_counts`, `merge_defined_used` and the `merge` function every collector had to provide) moves to its own pull request, to keep this one smaller to review and the package smaller to ship. `create_analyzer().add()` stays: it covers many inputs in one analyzer. `define_collector(init)` now takes just the init function. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…r out of this PR Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
commit: |
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
bartveneman
force-pushed
the
claude/incremental-analyzer
branch
from
November 7, 2026 19:15
229c7c0 to
26bf8d5
Compare
…, test.each for browserhack tests Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
bartveneman
force-pushed
the
claude/incremental-analyzer
branch
from
November 7, 2026 19:25
26bf8d5 to
c9f49a4
Compare
bartveneman
force-pushed
the
claude/sleepy-tesla-tu72wq
branch
from
November 8, 2026 21:54
b9224e1 to
4157128
Compare
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.
Stacked on #647. Re-adds the incremental multi-input API that was split off to keep #647 small:
create_analyzer(collectors).add(css, { source }).result()andanalyzer.parse_options. In #647,analyze(input, collectors, options?)is the only entry point.The branch is #647 plus a revert of the removal commit, so merging it later is a clean re-add.
Generated by Claude Code