From 12a0ad075d80914747a5bd675528d1153c75a1ab Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 20 Mar 2026 19:02:54 +0000 Subject: [PATCH 1/3] Add metrics tables to README for all three categories Documents each metric's purpose and point deduction logic for Performance, Maintainability, and Complexity categories. https://claude.ai/code/session_011qjCuV5Cpr4xAr5H57tGcv --- readme.md | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/readme.md b/readme.md index ace2d80..a11b2c3 100644 --- a/readme.md +++ b/readme.md @@ -28,6 +28,43 @@ This package analyzes your CSS on a high level and comes up with a score, divide - **Complexity**: how difficult is it for someone to make a change and be confident that they can make that change without side effects? - **Performance**: How likely is the CSS to have a negative impact on performance, based on high-level metrics? (Not including using hardware accelerated transforms and the like, because other tools are more suited for that.) +## Metrics + +### Performance + +| Metric | What is tested | Points deducted | +|--------|---------------|-----------------| +| `Imports` | Number of `@import` rules | 10 per `@import` | +| `EmptyRules` | Number of empty rules | 1 per empty rule | +| `SelectorDuplications` | Ratio of duplicate selectors | Up to 10 (when uniqueness ratio < 66%) | +| `DeclarationDuplications` | Ratio of duplicate declarations | Up to 10 (when uniqueness ratio < 66%) | +| `CssSize` | Total CSS file size | 5 if size exceeds 200,000 bytes | +| `TooMuchComments` | Total size of comments | 1 per 250 bytes of comments, max 10 | +| `TooMuchEmbeddedContent` | Total size of embedded content (e.g. base64) | 1 per 250 bytes of embedded content, max 20 | + +### Maintainability + +| Metric | What is tested | Points deducted | +|--------|---------------|-----------------| +| `SourceLinesOfCode` | Total source lines of code | 1 per 1,000 lines over 10,000, max 15 | +| `AverageSelectorsPerRule` | Average number of selectors per rule | 5 per selector over 2 (average), max 15 | +| `AverageDeclarationsPerRule` | Average number of declarations per rule | 5 per declaration over 5 (average), max 15 | +| `MaxSelectorsPerRule` | Maximum number of selectors in a single rule | 0.5 per selector over 10, max 15 | +| `MaxDeclarationsPerRule` | Maximum number of declarations in a single rule | 0.5 per declaration over 10, max 15 | +| `MoreThanMostCommonSelectorsPerRule` | Rules that have more selectors than the most common count | 0.01 per rule, max 15 (when > 10% of rules exceed the mode) | +| `MoreThanMostCommonDeclarationsPerRule` | Rules that have more declarations than the most common count | 0.01 per rule, max 15 (when > 10% of rules exceed the mode) | + +### Complexity + +| Metric | What is tested | Points deducted | +|--------|---------------|-----------------| +| `MoreThanMostCommonSelectorComplexity` | Selectors more complex than the most common complexity | 0.01 per selector, max 10 (when > 10% of selectors exceed the mode) | +| `MoreThanMostCommonSelectorSpecificity` | Selectors with higher specificity than the most common specificity | 0.01 per selector, max 10 (when > 10% of selectors exceed the mode) | +| `MaxSelectorComplexity` | Maximum complexity of a single selector | 0.5 per complexity unit over 5, max 5 | +| `AverageSelectorComplexity` | Average selector complexity | 2 per complexity unit over 2 (average), max 10 | +| `IdSelectorRatio` | Ratio of ID selectors | Up to 5 (when ID selector ratio exceeds 1%) | +| `ImportantRatio` | Ratio of `!important` declarations | Up to 5 (when `!important` ratio exceeds 1%) | + ## Installation ```bash From 0132ee4ce7213542aff29a8475a84fe017e47974 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 20 Mar 2026 19:25:43 +0000 Subject: [PATCH 2/3] Fix markdown table formatting to pass oxfmt lint https://claude.ai/code/session_011qjCuV5Cpr4xAr5H57tGcv --- readme.md | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/readme.md b/readme.md index a11b2c3..f7600bd 100644 --- a/readme.md +++ b/readme.md @@ -32,38 +32,38 @@ This package analyzes your CSS on a high level and comes up with a score, divide ### Performance -| Metric | What is tested | Points deducted | -|--------|---------------|-----------------| -| `Imports` | Number of `@import` rules | 10 per `@import` | -| `EmptyRules` | Number of empty rules | 1 per empty rule | -| `SelectorDuplications` | Ratio of duplicate selectors | Up to 10 (when uniqueness ratio < 66%) | -| `DeclarationDuplications` | Ratio of duplicate declarations | Up to 10 (when uniqueness ratio < 66%) | -| `CssSize` | Total CSS file size | 5 if size exceeds 200,000 bytes | -| `TooMuchComments` | Total size of comments | 1 per 250 bytes of comments, max 10 | -| `TooMuchEmbeddedContent` | Total size of embedded content (e.g. base64) | 1 per 250 bytes of embedded content, max 20 | +| Metric | What is tested | Points deducted | +| ------------------------- | -------------------------------------------- | ------------------------------------------- | +| `Imports` | Number of `@import` rules | 10 per `@import` | +| `EmptyRules` | Number of empty rules | 1 per empty rule | +| `SelectorDuplications` | Ratio of duplicate selectors | Up to 10 (when uniqueness ratio < 66%) | +| `DeclarationDuplications` | Ratio of duplicate declarations | Up to 10 (when uniqueness ratio < 66%) | +| `CssSize` | Total CSS file size | 5 if size exceeds 200,000 bytes | +| `TooMuchComments` | Total size of comments | 1 per 250 bytes of comments, max 10 | +| `TooMuchEmbeddedContent` | Total size of embedded content (e.g. base64) | 1 per 250 bytes of embedded content, max 20 | ### Maintainability -| Metric | What is tested | Points deducted | -|--------|---------------|-----------------| -| `SourceLinesOfCode` | Total source lines of code | 1 per 1,000 lines over 10,000, max 15 | -| `AverageSelectorsPerRule` | Average number of selectors per rule | 5 per selector over 2 (average), max 15 | -| `AverageDeclarationsPerRule` | Average number of declarations per rule | 5 per declaration over 5 (average), max 15 | -| `MaxSelectorsPerRule` | Maximum number of selectors in a single rule | 0.5 per selector over 10, max 15 | -| `MaxDeclarationsPerRule` | Maximum number of declarations in a single rule | 0.5 per declaration over 10, max 15 | -| `MoreThanMostCommonSelectorsPerRule` | Rules that have more selectors than the most common count | 0.01 per rule, max 15 (when > 10% of rules exceed the mode) | +| Metric | What is tested | Points deducted | +| --------------------------------------- | ------------------------------------------------------------ | ----------------------------------------------------------- | +| `SourceLinesOfCode` | Total source lines of code | 1 per 1,000 lines over 10,000, max 15 | +| `AverageSelectorsPerRule` | Average number of selectors per rule | 5 per selector over 2 (average), max 15 | +| `AverageDeclarationsPerRule` | Average number of declarations per rule | 5 per declaration over 5 (average), max 15 | +| `MaxSelectorsPerRule` | Maximum number of selectors in a single rule | 0.5 per selector over 10, max 15 | +| `MaxDeclarationsPerRule` | Maximum number of declarations in a single rule | 0.5 per declaration over 10, max 15 | +| `MoreThanMostCommonSelectorsPerRule` | Rules that have more selectors than the most common count | 0.01 per rule, max 15 (when > 10% of rules exceed the mode) | | `MoreThanMostCommonDeclarationsPerRule` | Rules that have more declarations than the most common count | 0.01 per rule, max 15 (when > 10% of rules exceed the mode) | ### Complexity -| Metric | What is tested | Points deducted | -|--------|---------------|-----------------| -| `MoreThanMostCommonSelectorComplexity` | Selectors more complex than the most common complexity | 0.01 per selector, max 10 (when > 10% of selectors exceed the mode) | +| Metric | What is tested | Points deducted | +| --------------------------------------- | ------------------------------------------------------------------ | ------------------------------------------------------------------- | +| `MoreThanMostCommonSelectorComplexity` | Selectors more complex than the most common complexity | 0.01 per selector, max 10 (when > 10% of selectors exceed the mode) | | `MoreThanMostCommonSelectorSpecificity` | Selectors with higher specificity than the most common specificity | 0.01 per selector, max 10 (when > 10% of selectors exceed the mode) | -| `MaxSelectorComplexity` | Maximum complexity of a single selector | 0.5 per complexity unit over 5, max 5 | -| `AverageSelectorComplexity` | Average selector complexity | 2 per complexity unit over 2 (average), max 10 | -| `IdSelectorRatio` | Ratio of ID selectors | Up to 5 (when ID selector ratio exceeds 1%) | -| `ImportantRatio` | Ratio of `!important` declarations | Up to 5 (when `!important` ratio exceeds 1%) | +| `MaxSelectorComplexity` | Maximum complexity of a single selector | 0.5 per complexity unit over 5, max 5 | +| `AverageSelectorComplexity` | Average selector complexity | 2 per complexity unit over 2 (average), max 10 | +| `IdSelectorRatio` | Ratio of ID selectors | Up to 5 (when ID selector ratio exceeds 1%) | +| `ImportantRatio` | Ratio of `!important` declarations | Up to 5 (when `!important` ratio exceeds 1%) | ## Installation From 6b0fa90b2a0cc44e40812b039c912d7b392aac6b Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 21 Mar 2026 08:47:56 +0000 Subject: [PATCH 3/3] Move Metrics section to after Installation and Usage https://claude.ai/code/session_011qjCuV5Cpr4xAr5H57tGcv --- readme.md | 74 +++++++++++++++++++++++++++---------------------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/readme.md b/readme.md index f7600bd..4993781 100644 --- a/readme.md +++ b/readme.md @@ -28,43 +28,6 @@ This package analyzes your CSS on a high level and comes up with a score, divide - **Complexity**: how difficult is it for someone to make a change and be confident that they can make that change without side effects? - **Performance**: How likely is the CSS to have a negative impact on performance, based on high-level metrics? (Not including using hardware accelerated transforms and the like, because other tools are more suited for that.) -## Metrics - -### Performance - -| Metric | What is tested | Points deducted | -| ------------------------- | -------------------------------------------- | ------------------------------------------- | -| `Imports` | Number of `@import` rules | 10 per `@import` | -| `EmptyRules` | Number of empty rules | 1 per empty rule | -| `SelectorDuplications` | Ratio of duplicate selectors | Up to 10 (when uniqueness ratio < 66%) | -| `DeclarationDuplications` | Ratio of duplicate declarations | Up to 10 (when uniqueness ratio < 66%) | -| `CssSize` | Total CSS file size | 5 if size exceeds 200,000 bytes | -| `TooMuchComments` | Total size of comments | 1 per 250 bytes of comments, max 10 | -| `TooMuchEmbeddedContent` | Total size of embedded content (e.g. base64) | 1 per 250 bytes of embedded content, max 20 | - -### Maintainability - -| Metric | What is tested | Points deducted | -| --------------------------------------- | ------------------------------------------------------------ | ----------------------------------------------------------- | -| `SourceLinesOfCode` | Total source lines of code | 1 per 1,000 lines over 10,000, max 15 | -| `AverageSelectorsPerRule` | Average number of selectors per rule | 5 per selector over 2 (average), max 15 | -| `AverageDeclarationsPerRule` | Average number of declarations per rule | 5 per declaration over 5 (average), max 15 | -| `MaxSelectorsPerRule` | Maximum number of selectors in a single rule | 0.5 per selector over 10, max 15 | -| `MaxDeclarationsPerRule` | Maximum number of declarations in a single rule | 0.5 per declaration over 10, max 15 | -| `MoreThanMostCommonSelectorsPerRule` | Rules that have more selectors than the most common count | 0.01 per rule, max 15 (when > 10% of rules exceed the mode) | -| `MoreThanMostCommonDeclarationsPerRule` | Rules that have more declarations than the most common count | 0.01 per rule, max 15 (when > 10% of rules exceed the mode) | - -### Complexity - -| Metric | What is tested | Points deducted | -| --------------------------------------- | ------------------------------------------------------------------ | ------------------------------------------------------------------- | -| `MoreThanMostCommonSelectorComplexity` | Selectors more complex than the most common complexity | 0.01 per selector, max 10 (when > 10% of selectors exceed the mode) | -| `MoreThanMostCommonSelectorSpecificity` | Selectors with higher specificity than the most common specificity | 0.01 per selector, max 10 (when > 10% of selectors exceed the mode) | -| `MaxSelectorComplexity` | Maximum complexity of a single selector | 0.5 per complexity unit over 5, max 5 | -| `AverageSelectorComplexity` | Average selector complexity | 2 per complexity unit over 2 (average), max 10 | -| `IdSelectorRatio` | Ratio of ID selectors | Up to 5 (when ID selector ratio exceeds 1%) | -| `ImportantRatio` | Ratio of `!important` declarations | Up to 5 (when `!important` ratio exceeds 1%) | - ## Installation ```bash @@ -124,6 +87,43 @@ etc. etc. */ ``` +## Metrics + +### Performance + +| Metric | What is tested | Points deducted | +| ------------------------- | -------------------------------------------- | ------------------------------------------- | +| `Imports` | Number of `@import` rules | 10 per `@import` | +| `EmptyRules` | Number of empty rules | 1 per empty rule | +| `SelectorDuplications` | Ratio of duplicate selectors | Up to 10 (when uniqueness ratio < 66%) | +| `DeclarationDuplications` | Ratio of duplicate declarations | Up to 10 (when uniqueness ratio < 66%) | +| `CssSize` | Total CSS file size | 5 if size exceeds 200,000 bytes | +| `TooMuchComments` | Total size of comments | 1 per 250 bytes of comments, max 10 | +| `TooMuchEmbeddedContent` | Total size of embedded content (e.g. base64) | 1 per 250 bytes of embedded content, max 20 | + +### Maintainability + +| Metric | What is tested | Points deducted | +| --------------------------------------- | ------------------------------------------------------------ | ----------------------------------------------------------- | +| `SourceLinesOfCode` | Total source lines of code | 1 per 1,000 lines over 10,000, max 15 | +| `AverageSelectorsPerRule` | Average number of selectors per rule | 5 per selector over 2 (average), max 15 | +| `AverageDeclarationsPerRule` | Average number of declarations per rule | 5 per declaration over 5 (average), max 15 | +| `MaxSelectorsPerRule` | Maximum number of selectors in a single rule | 0.5 per selector over 10, max 15 | +| `MaxDeclarationsPerRule` | Maximum number of declarations in a single rule | 0.5 per declaration over 10, max 15 | +| `MoreThanMostCommonSelectorsPerRule` | Rules that have more selectors than the most common count | 0.01 per rule, max 15 (when > 10% of rules exceed the mode) | +| `MoreThanMostCommonDeclarationsPerRule` | Rules that have more declarations than the most common count | 0.01 per rule, max 15 (when > 10% of rules exceed the mode) | + +### Complexity + +| Metric | What is tested | Points deducted | +| --------------------------------------- | ------------------------------------------------------------------ | ------------------------------------------------------------------- | +| `MoreThanMostCommonSelectorComplexity` | Selectors more complex than the most common complexity | 0.01 per selector, max 10 (when > 10% of selectors exceed the mode) | +| `MoreThanMostCommonSelectorSpecificity` | Selectors with higher specificity than the most common specificity | 0.01 per selector, max 10 (when > 10% of selectors exceed the mode) | +| `MaxSelectorComplexity` | Maximum complexity of a single selector | 0.5 per complexity unit over 5, max 5 | +| `AverageSelectorComplexity` | Average selector complexity | 2 per complexity unit over 2 (average), max 10 | +| `IdSelectorRatio` | Ratio of ID selectors | Up to 5 (when ID selector ratio exceeds 1%) | +| `ImportantRatio` | Ratio of `!important` declarations | Up to 5 (when `!important` ratio exceeds 1%) | + ## Related projects - [CSS Analyzer](https://github.com/projectwallace/css-analyzer) -