Skip to content

Commit

Permalink
Fix false positives for flex in length-zero-no-unit (#5315)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeddy3 committed May 19, 2021
1 parent a3460ef commit 52a67ab
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/rules/length-zero-no-unit/__tests__/index.js
Expand Up @@ -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`',
Expand Down
6 changes: 6 additions & 0 deletions lib/rules/length-zero-no-unit/index.js
Expand Up @@ -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;

Expand Down Expand Up @@ -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';
}
Expand Down

0 comments on commit 52a67ab

Please sign in to comment.