Skip to content

Commit

Permalink
Fix function-calc-no-unspaced-operator TypeError on empty calc() (#…
Browse files Browse the repository at this point in the history
…6634)

* function-calc-no-unspaced-operator: fix exception on empty calc

* Update lib/rules/function-calc-no-unspaced-operator/index.js

Co-authored-by: Richard Hallows <jeddy3@users.noreply.github.com>

* Create silver-owls-develop.md

---------

Co-authored-by: Richard Hallows <jeddy3@users.noreply.github.com>
  • Loading branch information
romainmenke and jeddy3 committed Feb 10, 2023
1 parent b04ac41 commit c64065e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/silver-owls-develop.md
@@ -0,0 +1,5 @@
---
"stylelint": patch
---

Fixed: `function-calc-no-unspaced-operator` TypeError on empty `calc()`
Expand Up @@ -225,6 +225,9 @@ testRule({
{
code: 'a { top: calc(10px/var(--foo)); }',
},
{
code: 'a { padding: calc(); }',
},
],

reject: [
Expand Down
3 changes: 3 additions & 0 deletions lib/rules/function-calc-no-unspaced-operator/index.js
Expand Up @@ -313,6 +313,9 @@ const rule = (primary, _secondaryOptions, context) => {
if (node.type !== 'function' || node.value.toLowerCase() !== 'calc') return;

const { nodes } = node;

if (!nodes.length) return;

let foundOperatorNode = false;

for (const [nodeIndex, currNode] of nodes.entries()) {
Expand Down

0 comments on commit c64065e

Please sign in to comment.