Skip to content

Commit 91cdf8c

Browse files
committed
fix: expanded shorthand check
1 parent 0753d4f commit 91cdf8c

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/index.ts

+12-5
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ type RegExpArray = [string, string?];
6868
* @internal
6969
* @param value - Any string.
7070
*/
71+
const checkCssValue = (prop: string, value: unknown) =>
72+
(/color/.test(prop) && value === 'transparent') || cssValues(prop, value);
7173
const isRegexString = (value: string): value is RegExpString =>
7274
reRegex.test(value);
7375
/**
@@ -376,14 +378,19 @@ const ruleFunction: StylelintRuleFunction = (
376378
}
377379
}
378380

381+
if (isExpanded) {
382+
console.log(
383+
`${nodeProp}: ${nodeValue} -> ${longhandProp}: ${longhandValue}`,
384+
checkCssValue(longhandProp!, longhandValue)
385+
);
386+
}
387+
379388
// test expanded shorthands are valid
380389
if (
381390
isExpanded &&
382-
ignoreVariables &&
383-
!validVar &&
384-
ignoreFunctions &&
385-
!validFunc &&
386-
cssValues(longhandProp, longhandValue) !== true
391+
(!ignoreVariables || (ignoreVariables && !validVar)) &&
392+
(!ignoreFunctions || (ignoreFunctions && !validFunc)) &&
393+
checkCssValue(longhandProp!, longhandValue) !== true
387394
) {
388395
return false;
389396
}

0 commit comments

Comments
 (0)