Skip to content

Add no-invalid-z-index rule to stylelint plugin#93

Merged
bartveneman merged 3 commits intomainfrom
claude/implement-no-invalid-z-index-G32zm
Mar 25, 2026
Merged

Add no-invalid-z-index rule to stylelint plugin#93
bartveneman merged 3 commits intomainfrom
claude/implement-no-invalid-z-index-G32zm

Conversation

@bartveneman
Copy link
Copy Markdown
Member

Summary

This PR adds a new stylelint rule projectwallace/no-invalid-z-index that validates z-index values are valid 32-bit signed integers within the range of -2147483648 to 2147483647.

Key Changes

  • New rule implementation (src/rules/no-invalid-z-index/index.ts): Validates that z-index values are integers within the 32-bit signed integer range, with support for checking fallback values in CSS custom properties
  • Comprehensive test suite (src/rules/no-invalid-z-index/index.test.ts): 16 test cases covering valid values (positive, negative, zero, auto), boundary values, invalid values (out of range, floats), var() with fallbacks, and rule disabling
  • Documentation (src/rules/no-invalid-z-index/README.md): Clear explanation of the rule with examples of valid and invalid z-index values
  • Plugin integration: Added the new rule to the main plugin exports and included it in the recommended configuration

Implementation Details

  • Uses the @projectwallace/css-parser library to parse declaration values and extract numeric values
  • Validates both direct z-index values and fallback values within var() functions
  • Properly handles edge cases like z-index: auto and var() without fallbacks (which cannot be validated)
  • Reports violations with the specific invalid value in the error message

https://claude.ai/code/session_01MaWwhMcH7Dv966R834zVUE

claude and others added 3 commits March 25, 2026 10:52
Implements a new rule that disallows z-index values that are not valid
32-bit integers (range: -2147483648 to 2147483647). Also checks fallback
values inside var(), e.g. var(--my-z, 2147483648).

Closes #91

https://claude.ai/code/session_01MaWwhMcH7Dv966R834zVUE
Use PostCSS walkDecls to find z-index declarations, then only invoke
the Wallace CSS parser on the declaration value rather than parsing
the whole stylesheet.

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

codecov-commenter commented Mar 25, 2026

Bundle Report

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

Detailed changes
Bundle name Size Change
stylelintPlugin-esm 62.91kB 1.62kB (2.64%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: stylelintPlugin-esm

Assets Changed:

Asset Name Size Change Total Size Change (%)
index.mjs 1.52kB 58.56kB 2.67%
configs/recommended.d.mts 50 bytes 1.71kB 3.02%
configs/recommended.mjs 45 bytes 1.61kB 2.88%

Files in index.mjs:

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

  • ./src/rules/no-invalid-z-index/index.ts → Total Size: 1.38kB

Files in configs/recommended.mjs:

  • ./src/configs/recommended.ts → Total Size: 1.57kB

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 98.14%. Comparing base (5519ae7) to head (3ae83ab).

Files with missing lines Patch % Lines
src/rules/no-invalid-z-index/index.ts 96.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #93      +/-   ##
==========================================
- Coverage   98.20%   98.14%   -0.07%     
==========================================
  Files          33       34       +1     
  Lines         893      918      +25     
  Branches      230      234       +4     
==========================================
+ Hits          877      901      +24     
- Misses         13       14       +1     
  Partials        3        3              

☔ 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.

@bartveneman bartveneman merged commit 27c09e5 into main Mar 25, 2026
4 of 5 checks passed
@bartveneman bartveneman deleted the claude/implement-no-invalid-z-index-G32zm branch March 25, 2026 11:41
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