Skip to content

Commit

Permalink
Fix false positives for level 4 math functions in length-zero-no-unit
Browse files Browse the repository at this point in the history
Closes #5199
  • Loading branch information
Tomás Hayes committed Mar 19, 2021
1 parent 725802e commit a143e5e
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/reference/mathFunctions.js
@@ -1,3 +1,3 @@
'use strict';

module.exports = ['calc'];
module.exports = ['calc', 'clamp', 'max', 'min'];
37 changes: 37 additions & 0 deletions lib/rules/length-zero-no-unit/__tests__/index.js
Expand Up @@ -31,6 +31,30 @@ testRule({
code: 'padding: calc(var(--foo, 0) + 10px) 0',
description: 'ignore calc, but not inner functions',
},
{
code: 'a { right: max(100vw, 0rem)); }',
description: 'ignore max',
},
{
code: 'a { right: calc(max(100vw, 0rem))); }',
description: 'ignore max inside calc',
},
{
code: 'a { right: min(100vw, 0rem)); }',
description: 'ignore min',
},
{
code: 'a { right: calc(min(100vw, 0rem))); }',
description: 'ignore min inside calc',
},
{
code: 'a { right: clamp(50rem, 50vw, 0rem))); }',
description: 'ignore clamp',
},
{
code: 'a { right: clac(clamp(50rem, 50vw, 0rem)))); }',
description: 'ignore clamp inside calc',
},
{
code: 'a { padding: 0 /* 0px */; }',
description: 'united zero in comment',
Expand Down Expand Up @@ -364,6 +388,19 @@ testRule({
},
],
},
{
description: 'ignore min, max, clamp. has another zero units',
code: 'padding: min(1vw, 0in) max(1vw, 0px) clamp(0em, 1vw, 10px) 0px;',
fixed: 'padding: min(1vw, 0in) max(1vw, 0px) clamp(0em, 1vw, 10px) 0;',

warnings: [
{
message: messages.rejected,
line: 1,
column: 61,
},
],
},
{
code: '@media (min-width: 0px) {}',
fixed: '@media (min-width: 0) {}',
Expand Down

0 comments on commit a143e5e

Please sign in to comment.