Skip to content

Commit

Permalink
Fix TypeError error "Cannot destructure property..." in custom-proper…
Browse files Browse the repository at this point in the history
…ty-pattern (#5982)
  • Loading branch information
mattxwang committed Mar 24, 2022
1 parent c86e3ac commit 2e3d1f6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions lib/rules/custom-property-pattern/__tests__/index.js
Expand Up @@ -19,6 +19,10 @@ testRule({
{
code: ':root { --foo-sub-color: #f00; } a { color: var(--foo-color, var(--foo-sub-color)); }',
},
{
code: 'a { --foo-color: var(); }',
description: 'empty function',
},
],

reject: [
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/custom-property-pattern/index.js
Expand Up @@ -58,9 +58,9 @@ const rule = (primary) => {

const { nodes, sourceIndex } = node;

const { value: firstNodeValue } = nodes[0];
const firstNode = nodes[0];

if (check(firstNodeValue)) return;
if (!firstNode || check(firstNode.value)) return;

complain(declarationValueIndex(decl) + sourceIndex, decl);
});
Expand Down

0 comments on commit 2e3d1f6

Please sign in to comment.