Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix TypeError error "Cannot destructure property..." in custom-property-pattern #5972

Closed
jeddy3 opened this issue Mar 17, 2022 · 1 comment · Fixed by #5982
Closed

Fix TypeError error "Cannot destructure property..." in custom-property-pattern #5972

jeddy3 opened this issue Mar 17, 2022 · 1 comment · Fixed by #5982
Labels
status: ready to implement is ready to be worked on by someone type: bug a problem with a feature or rule

Comments

@jeddy3
Copy link
Member

jeddy3 commented Mar 17, 2022

What steps are needed to reproduce the bug?

a { prop: var(); }

Demo

This is a regression affecting everyone using the standard config.

What Stylelint configuration is needed to reproduce the bug?

{
  "rules": {
    "custom-property-pattern": [
      "^([a-z][a-z0-9]*)(-[a-z0-9]+)*$",
      {
        "message": "Expected custom property name to be kebab-case"
      }
    ]
  }
}

How did you run Stylelint?

Demo

Which version of Stylelint are you using?

14.6.0

What did you expect to happen?

No TypeError

What actually happened?

TypeError

Does the bug relate to non-standard syntax?

No

Proposal to fix the bug

Check that nodes is available before destructuring.

Follow-up PR to add "empty functions" to commonly overlooked edge cases.

@mattxwang
Copy link
Member

Submitted a quick fix, though I check if nodes[0] exists rather than nodes (checking for nodes doesn't resolve the problem). Let me know what you think!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: ready to implement is ready to be worked on by someone type: bug a problem with a feature or rule
Development

Successfully merging a pull request may close this issue.

2 participants