From 52a67abea5b6c1735b4369e2e0745acc406ec3ce Mon Sep 17 00:00:00 2001 From: Richard Hallows Date: Wed, 19 May 2021 13:16:34 +0100 Subject: [PATCH] Fix false positives for flex in length-zero-no-unit (#5315) --- lib/rules/length-zero-no-unit/__tests__/index.js | 8 ++++++++ lib/rules/length-zero-no-unit/index.js | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/lib/rules/length-zero-no-unit/__tests__/index.js b/lib/rules/length-zero-no-unit/__tests__/index.js index 00718b22cd..d14d5def39 100644 --- a/lib/rules/length-zero-no-unit/__tests__/index.js +++ b/lib/rules/length-zero-no-unit/__tests__/index.js @@ -220,6 +220,14 @@ testRule({ { code: 'a { lIne-hEight: 0px; }', }, + { + code: 'a { flex: 0px; }', + description: 'ignore flex property', + }, + { + code: 'a { Flex: 0px; }', + description: 'ignore cased flex property', + }, { code: 'a { grid-auto-columns: 0fr; }', description: 'ignore some grid properties with `fr`', diff --git a/lib/rules/length-zero-no-unit/index.js b/lib/rules/length-zero-no-unit/index.js index 042b2ec5d0..5daf8e8eb2 100644 --- a/lib/rules/length-zero-no-unit/index.js +++ b/lib/rules/length-zero-no-unit/index.js @@ -107,6 +107,8 @@ function rule(primary, secondary, context) { if (isLineHeight(prop)) return; + if (isFlex(prop)) return; + if (optionsMatches(secondary, 'ignore', 'custom-properties') && isCustomProperty(prop)) return; @@ -142,6 +144,10 @@ function isLineHeight(prop) { return prop.toLowerCase() === 'line-height'; } +function isFlex(prop) { + return prop.toLowerCase() === 'flex'; +} + function isWord({ type }) { return type === 'word'; }