Skip to content

Add support for analyzing @function at-rules#540

Merged
bartveneman merged 3 commits intomainfrom
claude/add-atrules-collection-mo0jY
Mar 16, 2026
Merged

Add support for analyzing @function at-rules#540
bartveneman merged 3 commits intomainfrom
claude/add-atrules-collection-mo0jY

Conversation

@bartveneman
Copy link
Copy Markdown
Member

Summary

This PR adds support for analyzing CSS @function at-rules (from the CSS Mixins specification) to the CSS analyzer. The implementation tracks function definitions, counts their occurrences, and calculates uniqueness metrics similar to existing at-rule analysis.

Key Changes

  • Added registeredFunctions collection to track @function at-rules during CSS parsing
  • Implemented parsing logic to extract function names from @function prelude text, handling the function signature syntax (e.g., --my-color(--base))
  • Added function property to the atrules analysis output with metrics for total count, unique count, and uniqueness ratio
  • Updated test fixtures to verify correct analysis of @function at-rules, including edge cases like:
    • Duplicate function definitions
    • Case-insensitive at-rule names (@FUNCTION)
    • Invalid at-rules with no prelude
  • Updated empty input test case to include the new function field in expected output

Implementation Details

  • Function names are extracted by parsing the prelude text up to the opening parenthesis, handling cases where the prelude may contain parameter lists
  • The implementation follows the same pattern as existing at-rule analysis (e.g., @property)
  • Uniqueness ratio is calculated as the ratio of unique function names to total function definitions

https://claude.ai/code/session_01NZGg1kjwKsnugxGXx3vtLF

Track CSS @function at-rules (CSS Functions and Mixins Module) in a
new `atrules.function` collection. Extracts function names from
preludes and counts total/unique occurrences.

https://claude.ai/code/session_01NZGg1kjwKsnugxGXx3vtLF
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 15, 2026

Bundle Report

Changes will increase total bundle size by 253 bytes (0.28%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
analyzeCss-esm 90.67kB 253 bytes (0.28%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: analyzeCss-esm

Assets Changed:

Asset Name Size Change Total Size Change (%)
css-*.js 253 bytes 90.67kB 0.28%

Files in css-*.js:

  • ./src/index.ts → Total Size: 30.55kB

claude and others added 2 commits March 15, 2026 12:58
Rename registeredFunctions -> functions (matches scopes, layers, etc.)
and use prelude/name instead of prelText/funcName abbreviations.

https://claude.ai/code/session_01NZGg1kjwKsnugxGXx3vtLF
@bartveneman bartveneman marked this pull request as ready for review March 16, 2026 15:49
@bartveneman bartveneman merged commit 40a1e8d into main Mar 16, 2026
5 checks passed
@bartveneman bartveneman deleted the claude/add-atrules-collection-mo0jY branch March 16, 2026 15:49
@bartveneman bartveneman mentioned this pull request Mar 18, 2026
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.

3 participants