Skip to content

Commit

Permalink
Fix length-zero-no-unit false positives on new math functions (#6871)
Browse files Browse the repository at this point in the history
---------

Co-authored-by: Masafumi Koba <473530+ybiquitous@users.noreply.github.com>
  • Loading branch information
romainmenke and ybiquitous committed May 29, 2023
1 parent 30678bb commit c81e63f
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/calm-rivers-wink.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"stylelint": patch
---

Fixed: `length-zero-no-unit` false positives on new math functions
24 changes: 23 additions & 1 deletion lib/reference/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,29 @@ const camelCaseFunctions = new Set([
'skewY',
]);

const mathFunctions = new Set(['calc', 'clamp', 'max', 'min']);
const mathFunctions = new Set([
'abs',
'acos',
'asin',
'atan',
'atan2',
'calc',
'clamp',
'cos',
'exp',
'hypot',
'log',
'max',
'min',
'mod',
'pow',
'rem',
'round',
'sign',
'sin',
'sqrt',
'tan',
]);

module.exports = {
camelCaseFunctions,
Expand Down
4 changes: 4 additions & 0 deletions lib/rules/length-zero-no-unit/__tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ testRule({
code: 'a { padding: calc(1in + 0in * 2)) 0 calc(0px) 0 }',
description: 'ignore calc. several `calc`s',
},
{
code: 'a { padding: abs(0px) acos(0px) asin(0px) atan(0px) atan2(0px) calc(0px) clamp(0px) cos(0px) exp(0px) hypot(0px) log(0px) max(0px) min(0px) mod(0px) pow(0px) rem(0px) round(0px) sign(0px) sin(0px) sqrt(0px) tan(0px) }',
description: 'ignore new math functions.',
},
{
code: 'padding: calc(var(--foo, 0px) + 10px) 0',
description: 'ignore calc, and inner functions',
Expand Down

0 comments on commit c81e63f

Please sign in to comment.