From afe4086b795fdf5ac845085798c4c64891383a64 Mon Sep 17 00:00:00 2001 From: im3dabasia Date: Mon, 18 Aug 2025 15:29:28 +0530 Subject: [PATCH 1/3] feat: Consolidate rules for simplification --- .stylelintrc.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/.stylelintrc.js b/.stylelintrc.js index e3e6d82a9ab805..34ef68b0d37a42 100644 --- a/.stylelintrc.js +++ b/.stylelintrc.js @@ -17,11 +17,24 @@ module.exports = { ], 'declaration-property-value-disallowed-list': [ { + 'flex-direction': [ '/-reverse$/' ], '/.*/': [ '/--wp-components-color-/' ], }, { - message: ( property, value ) => - `Avoid using "${ value }" in "${ property }". --wp-components-color-* variables are not ready to be used outside of the components package.`, + message: ( property, value ) => { + // Don't allow reverse values for flex-direction. + if ( + property === 'flex-direction' && + /-reverse$/.test( value ) + ) { + return `Avoid "${ value }" value for the "${ property }" property. For accessibility reasons, visual, reading, and DOM order must match. Only use the reverse values when they do not affect reading order, meaning, and interaction.`; + } + // Don't allow --wp-components-color-* variables outside of the components package. + if ( /--wp-components-color-/.test( value ) ) { + return `Avoid using "${ value }" in "${ property }". --wp-components-color-* variables are not ready to be used outside of the components package.`; + } + return `Avoid "${ value }" for "${ property }".`; + }, }, ], 'font-weight-notation': null, From 3359d05d0277ecbcf8baa8822694ad68f046f152 Mon Sep 17 00:00:00 2001 From: im3dabasia Date: Mon, 18 Aug 2025 15:39:35 +0530 Subject: [PATCH 2/3] feat: Remove allowed list array --- .stylelintrc.js | 9 --------- 1 file changed, 9 deletions(-) diff --git a/.stylelintrc.js b/.stylelintrc.js index 34ef68b0d37a42..9863b3a746cd7f 100644 --- a/.stylelintrc.js +++ b/.stylelintrc.js @@ -6,15 +6,6 @@ module.exports = { 'at-rule-empty-line-before': null, 'at-rule-no-unknown': null, 'comment-empty-line-before': null, - 'declaration-property-value-allowed-list': [ - { - 'flex-direction': '/^(?!(row|column)-reverse).*$/', - }, - { - message: ( property, value ) => - `Avoid "${ value }" value for the "${ property }" property. For accessibility reasons, visual, reading, and DOM order must match. Only use the reverse values when they do not affect reading order, meaning, and interaction.`, - }, - ], 'declaration-property-value-disallowed-list': [ { 'flex-direction': [ '/-reverse$/' ], From a81357bb70b33d5437c34359fc14c5689fba0a77 Mon Sep 17 00:00:00 2001 From: im3dabasia Date: Mon, 9 Feb 2026 17:33:28 +0530 Subject: [PATCH 3/3] chore: Switch case implementation --- .stylelintrc.js | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/.stylelintrc.js b/.stylelintrc.js index 9863b3a746cd7f..8476dfe52e9bed 100644 --- a/.stylelintrc.js +++ b/.stylelintrc.js @@ -13,17 +13,22 @@ module.exports = { }, { message: ( property, value ) => { - // Don't allow reverse values for flex-direction. - if ( - property === 'flex-direction' && - /-reverse$/.test( value ) - ) { - return `Avoid "${ value }" value for the "${ property }" property. For accessibility reasons, visual, reading, and DOM order must match. Only use the reverse values when they do not affect reading order, meaning, and interaction.`; - } - // Don't allow --wp-components-color-* variables outside of the components package. - if ( /--wp-components-color-/.test( value ) ) { - return `Avoid using "${ value }" in "${ property }". --wp-components-color-* variables are not ready to be used outside of the components package.`; + switch ( property ) { + // Don't allow reverse values for flex-direction. + case 'flex-direction': + if ( /-reverse$/.test( value ) ) { + return 'Avoid "-reverse" values for the "flex-direction" property.'; + } + break; + + // Don't allow --wp-components-color-* variables outside of the components package. + default: + if ( /--wp-components-color-/.test( value ) ) { + return 'Avoid using "--wp-components-color-*" variables outside of the components package.'; + } + break; } + return `Avoid "${ value }" for "${ property }".`; }, },