Skip to content

Commit 164dd17

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
1 parent ce56d5d commit 164dd17

File tree

7 files changed

+27
-13
lines changed

7 files changed

+27
-13
lines changed

lib/createStylelint.cjs

Lines changed: 1 addition & 10 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/__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;

lib/rules/function-no-unknown/index.cjs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/utils/FileCache.cjs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/utils/mathMLTags.cjs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)