Skip to content

Commit

Permalink
fix: expanded shorthand check
Browse files Browse the repository at this point in the history
  • Loading branch information
AndyOGo committed Apr 16, 2021
1 parent 0753d4f commit 91cdf8c
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ type RegExpArray = [string, string?];
* @internal
* @param value - Any string.
*/
const checkCssValue = (prop: string, value: unknown) =>
(/color/.test(prop) && value === 'transparent') || cssValues(prop, value);
const isRegexString = (value: string): value is RegExpString =>
reRegex.test(value);
/**
Expand Down Expand Up @@ -376,14 +378,19 @@ const ruleFunction: StylelintRuleFunction = (
}
}

if (isExpanded) {
console.log(
`${nodeProp}: ${nodeValue} -> ${longhandProp}: ${longhandValue}`,
checkCssValue(longhandProp!, longhandValue)
);
}

// test expanded shorthands are valid
if (
isExpanded &&
ignoreVariables &&
!validVar &&
ignoreFunctions &&
!validFunc &&
cssValues(longhandProp, longhandValue) !== true
(!ignoreVariables || (ignoreVariables && !validVar)) &&
(!ignoreFunctions || (ignoreFunctions && !validFunc)) &&
checkCssValue(longhandProp!, longhandValue) !== true
) {
return false;
}
Expand Down

0 comments on commit 91cdf8c

Please sign in to comment.