Skip to content

Commit

Permalink
Fix for border shorthand directional
Browse files Browse the repository at this point in the history
  • Loading branch information
jonrohan committed Jun 19, 2024
1 parent 550eb0c commit 6a3666c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions plugins/borders.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const messages = ruleMessages(ruleName, {
return `Border radius variables can not be used for border widths`
}

if ((propName && propName.includes('width')) || (propName === 'border' && value.includes('borderRadius'))) {
if ((propName && propName.includes('width')) || (borderShorthand(propName) && value.includes('borderRadius'))) {
return `Border width variables can not be used for border radii`
}

Expand All @@ -34,6 +34,8 @@ const radii = []
// Props that we want to check
const propList = ['border', 'border-width', 'border-radius']

const borderShorthand = (prop) => /^border(\-(top|right|bottom|left))?$/.test(prop)

Check failure on line 37 in plugins/borders.js

View workflow job for this annotation

GitHub Actions / lint

Replace `(prop)` with `prop`

Check failure on line 37 in plugins/borders.js

View workflow job for this annotation

GitHub Actions / lint

Unnecessary escape character: \-

for (const variable of variables) {
const name = variable['name']

Expand Down Expand Up @@ -117,7 +119,7 @@ const ruleFunction = (primary, secondaryOptions, context) => {
// if we're looking at the border property that sets color in shorthand, don't bother checking the color
if (
// using border shorthand
prop === 'border' &&
borderShorthand(prop) &&
// includes a color as a third space-separated value
value.split(' ').length > 2 &&
// the color in the third space-separated value includes `node.value`
Expand All @@ -130,7 +132,7 @@ const ruleFunction = (primary, secondaryOptions, context) => {
}

// If the variable is found in the value, skip it.
if (prop.includes('width') || prop === 'border') {
if (prop.includes('width') || borderShorthand(prop)) {
if (checkForVariable(sizes, node.value)) {
return
}
Expand Down

0 comments on commit 6a3666c

Please sign in to comment.