Skip to content

Commit 559795e

Browse files
fix: skip CSS variables in function-linear-gradient-no-nonstandard-direction rule
- Add test cases for CSS variables containing 'stop' - Skip direction validation for CSS variables to prevent false positives - Fixes issue with var(--tw-gradient-stops) and similar variable names Co-authored-by: Gary Gozlan <Mouvedia@users.noreply.github.com>
1 parent ce56d5d commit 559795e

File tree

4 files changed

+28
-0
lines changed

4 files changed

+28
-0
lines changed

.changeset/fluffy-waves-float.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"stylelint": patch
3+
---
4+
5+
Fixed: `function-linear-gradient-no-nonstandard-direction` false positives for CSS variables' names containing a direction substring

lib/rules/function-linear-gradient-no-nonstandard-direction/__tests__/index.mjs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,19 @@ testRule({
102102
{
103103
code: '.foo { background: url(foo.png), -ms-linear-gradient(bottom, #fff, #000 ), url(bar.png); }',
104104
},
105+
// Test cases for CSS variables containing "stop" - should not trigger warnings
106+
{
107+
code: '.foo { background: linear-gradient(var(--stop)); }',
108+
},
109+
{
110+
code: '.foo { background: linear-gradient(var(--tw-gradient-stops)); }',
111+
},
112+
{
113+
code: '.foo { background: linear-gradient(var(--gradient-stop-1), var(--gradient-stop-2)); }',
114+
},
115+
{
116+
code: '.foo { background: linear-gradient(var(--stop-color)); }',
117+
},
105118
],
106119

107120
reject: [

lib/rules/function-linear-gradient-no-nonstandard-direction/index.cjs

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/rules/function-linear-gradient-no-nonstandard-direction/index.mjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ const rule = (primary) => {
8484
return;
8585
}
8686

87+
// Skip direction validation for CSS variables
88+
if (firstArg.startsWith('var(')) {
89+
return;
90+
}
91+
8792
// Ignore gradients with modern syntax that have color space interpolation arguments
8893
if (IN_KEYWORD.test(firstArg)) {
8994
return;

0 commit comments

Comments
 (0)