Skip to content

Detect more browser hacks in values#584

Merged
bartveneman merged 8 commits intomainfrom
claude/add-browserhack-detection-zs8Tx
Apr 28, 2026
Merged

Detect more browser hacks in values#584
bartveneman merged 8 commits intomainfrom
claude/add-browserhack-detection-zs8Tx

Conversation

@bartveneman
Copy link
Copy Markdown
Member

Summary

Extends browser hack detection to identify Internet Explorer-specific CSS hacks used in property values, beyond the existing \9 hack detection. This provides more comprehensive analysis of legacy IE compatibility code.

Key Changes

  • New isValueBrowserhack() function in src/values/browserhacks.ts that detects multiple IE hack patterns:

    • progid: prefix for DXImageTransform filters (case-insensitive)
    • Trailing \9 (IE9) and \7 (IE7) escape hacks on identifiers
    • alpha() function for IE opacity (case-insensitive)
    • expression() function for IE dynamic values (case-insensitive)
    • .htc behavior files in url() functions (case-insensitive)
  • Updated detection logic in src/index.ts:

    • Replaced single isIe9Hack() check with comprehensive isValueBrowserhack() callback
    • Added guard to exclude custom properties (--*) from hack detection
    • Maintains existing text trimming for \9 and \7 hacks
  • Comprehensive test coverage with 26 new test cases covering:

    • Detection of each hack type with various formats (quoted, unquoted, case variations)
    • Multiple hacks in single declaration
    • False positive prevention (regular URLs, gradients, custom properties, aspect-ratio values)
  • Public API export of isValueBrowserhack() function for external use

Implementation Details

  • Uses regex pattern matching for progid: detection to handle quoted and unquoted values
  • Walks the CSS AST to identify function nodes (alpha(), expression()) and URL nodes (.htc files)
  • Properly excludes custom properties from all hack detection patterns to avoid false positives
  • Maintains backward compatibility with existing isIe9Hack() function

https://claude.ai/code/session_016WKR6cnpvkF5ApX7tt7KoC

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 27, 2026

Codecov Report

❌ Patch coverage is 92.30769% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.48%. Comparing base (16ff190) to head (edb1cd8).

Files with missing lines Patch % Lines
src/index.ts 87.50% 1 Missing ⚠️
src/values/browserhacks.ts 94.44% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #584      +/-   ##
==========================================
- Coverage   95.20%   94.48%   -0.72%     
==========================================
  Files          18       18              
  Lines        1000     1016      +16     
  Branches      314      321       +7     
==========================================
+ Hits          952      960       +8     
- Misses         40       46       +6     
- Partials        8       10       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 27, 2026

Bundle Report

Changes will increase total bundle size by 1.32kB (1.68%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
analyzeCss-esm 79.75kB 1.32kB (1.68%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: analyzeCss-esm

Assets Changed:

Asset Name Size Change Total Size Change (%)
index.js 6 bytes 33.1kB 0.02%
index.d.ts 45 bytes 14.63kB 0.31%
browserhacks-BZeV9_0h.js (New) 8.97kB 8.97kB 100.0% 🚀
values/index.d.ts -41 bytes 1.49kB -2.69%
values-DI2FP2Ey.d.ts (New) 1.31kB 1.31kB 100.0% 🚀
values/index.js 45 bytes 462 bytes 10.79% ⚠️
browserhacks-TJ8g2OK2.js (Deleted) -8.19kB 0 bytes -100.0% 🗑️
values-D6esXWUv.d.ts (Deleted) -820 bytes 0 bytes -100.0% 🗑️

Files in index.js:

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

Files in browserhacks-BZeV9_0h.js:

  • ./src/values/browserhacks.ts → Total Size: 1.02kB

Files in values/index.js:

  • ./src/values/index.ts → Total Size: 0 bytes

@bartveneman bartveneman changed the title Detect IE browser hacks in CSS values Detect more browser hacks in values Apr 28, 2026
@bartveneman bartveneman merged commit 6b2b158 into main Apr 28, 2026
5 checks passed
@bartveneman bartveneman deleted the claude/add-browserhack-detection-zs8Tx branch April 28, 2026 09:30
bartveneman added a commit to projectwallace/stylelint-plugin that referenced this pull request Apr 29, 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