From 4f68dfdb9856a6712e3444a5fbe76fb1dee29b83 Mon Sep 17 00:00:00 2001 From: Jack Franklin Date: Mon, 3 Jul 2023 11:01:56 +0100 Subject: [PATCH] Fix stylelint errors on border: usage with custom vars Fixed: 1442257 Change-Id: Idbfab3c09655303ffd7e8ca383f87ec3cf89465b Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/4660608 Commit-Queue: Jack Franklin Commit-Queue: Alex Rudenko Auto-Submit: Jack Franklin Reviewed-by: Alex Rudenko --- scripts/stylelint_rules/lib/use_theme_colors.js | 2 +- scripts/stylelint_rules/tests/use_theme_colors_test.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/stylelint_rules/lib/use_theme_colors.js b/scripts/stylelint_rules/lib/use_theme_colors.js index 90f0ce2e6f..bba86fcf38 100644 --- a/scripts/stylelint_rules/lib/use_theme_colors.js +++ b/scripts/stylelint_rules/lib/use_theme_colors.js @@ -33,7 +33,7 @@ const CSS_PROPS_TO_CHECK_FOR_COLOR_USAGE = new Set([ 'outline' ]); -const borderCombinedDeclarations = new Set(['border-top', 'border-bottom', 'border-left', 'border-right']); +const borderCombinedDeclarations = new Set(['border', 'border-top', 'border-bottom', 'border-left', 'border-right']); const COLOR_INDICATOR_REGEXES = new Set([ // We don't have to check for named colors ("blue") as we lint to ban those separately. diff --git a/scripts/stylelint_rules/tests/use_theme_colors_test.js b/scripts/stylelint_rules/tests/use_theme_colors_test.js index 69203dbeee..622571760f 100644 --- a/scripts/stylelint_rules/tests/use_theme_colors_test.js +++ b/scripts/stylelint_rules/tests/use_theme_colors_test.js @@ -239,6 +239,12 @@ describe('use_theme_colors', () => { ]); }); + it('does not error when there is a var for the border width', async () => { + const warnings = await lint('p { border: var(--button-border-size) solid var(--color-primary); }'); + + assert.lengthOf(warnings, 0); + }); + it('is silent when linting code that has an empty var()', async () => { /** * This is a weird test case but if you've got Stylelint in your editor and