question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Selector `Property > .key` can't match key in `const {a = 1} = b;`

See original GitHub issue

Tell us about your environment

  • ESLint Version: v7.30.0
  • Node Version: v16.4.2
  • npm Version: v7.9.0
  • Operating System: win32 10.0.19043

What parser (default, @babel/eslint-parser, @typescript-eslint/parser, etc.) are you using?

The default parser.

The issue template doesn’t fit, so I removed these sections.

I was making an eslint plugin, for this code

const {a = 1} = b;

I should be able to use Property > .key to select the key, but ESLint won’t match.

I think this happens because we use the same reference for key and value.left, so they both have the AssignmentPattern as parent. For this reason, I don’t think this is an issue by espree or acorn.

This happens to assignment too.

({a = 1} = b);

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
nzakascommented, Jul 16, 2021

@fisker thanks for the followup. The Espree upgrade will happen with the ESLint v8.0.0 release, which we hope we will have a preview release of in a couple weeks.

We can’t upgrade Espree in ESLint v7.x line due to breaking changes.

0reactions
fiskercommented, Jul 15, 2021

This is a bug in Acorn 7 / Espree 7, nodes in a tree shouldn’t have multiple parents. The bug is fixed in Acorn 8 / Espree 8 (relevant test is here).

Thank you, I didn’t know that.

Can you try by using Espree 8 locally and let us know the result?

Confirmed, updating to Espree 8 fixes this.


Question: ETA for switch to Espree 8.0.0? Do we need workaround in ESLint before that?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Warning: Use the 'defaultValue' or 'value' props on <select ...
I am using selected attribute on option but React generates a warning asking me to use default value on select. For e.g. render:...
Read more >
React key attribute: best practices for performant lists
Looking into how React "key" attribute works, how to use it correctly, ... const sortedCountries = orderBy(countries, 'name', sort);.
Read more >
Uncaught TypeError: Cannot read property of null - iDiallo
All this means is that you are trying to access a property of an object that is undefined.
Read more >
Resolve the "Parameter validation failed" error in AWS ...
1. Open the AWS CloudFormation console. · 2. In the navigation pane, choose Stacks. · 3. Form the Stack name column, choose the...
Read more >
The starting point for learning TypeScript
How to use TypeScript-powered JavaScript tooling. JS Projects Utilizing TypeScript · Type Checking JavaScript Files · JSDoc Reference · Creating .d.ts Files ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found