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.

Support/Document `:has()` selectors (per esquery update)

See original GitHub issue

The version of ESLint you are using.

7.19.0

The problem you want to solve.

esquery has just published a new release with the support for custom visitor keys (that may contribute to fixing #13639 ), which brings parser-independent support including for has:() selectors.

However, https://github.com/eslint/eslint/blob/master/docs/developer-guide/selectors.md does not indicate support for :has(), and per https://github.com/eslint/eslint/issues/13639#issuecomment-774577141 there may be some work to do to be able to support them:

ESLint selectors are using esquery, but we’re also doing some optimizations and calculating specificity in NodeEventGenerator, so it’s possible that some additional work has to be done before we can say that ESLint fully supports new selectors.

(Note that in addition to :has() the “subject” indicator is also supported, but per https://github.com/estools/esquery/pull/61 , that implementation is buggy while the :has() one was working enough to be used as a base for the former–though with one issue on relative keys mentioned there.)

Your take on the correct solution to problem.

No special take. Ideally would provide support for the selectors and update the docs.

Are you willing to submit a pull request to implement this change?

No.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:15 (15 by maintainers)

github_iconTop GitHub Comments

2reactions
mdjermanoviccommented, Jun 25, 2021

In the latest esquery on master/1.4.0, it doesn’t error but returns the same Literal as itself.

Sorry, by “error” I meant a linting problem, i.e., the selector in the no-restricted-syntax config matches literal 1.

I filed an issue in esquery repo: https://github.com/estools/esquery/issues/122

1reaction
mdjermanoviccommented, Mar 3, 2021

I’ll champion this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Exceptions when traversing using sibling, adjacent and nth ...
ESLint selectors are using esquery, but we're also doing some ... Support/Document :has() selectors (per esquery update) #14076.
Read more >
Update By Query API | Elasticsearch Guide [8.5] | Elastic
Updates documents that match the specified query. If no query is specified, performs an update on every document in the data stream or...
Read more >
Selectors - ESLint - Pluggable JavaScript Linter
A selector is a string that can be used to match nodes in an Abstract Syntax Tree (AST). This is useful for describing...
Read more >
Document.querySelector() - Web APIs | MDN
The Document method querySelector() returns the first Element within the ... Thrown if the syntax of the specified selectors is invalid.
Read more >
Selectors - WebdriverIO
Please note that even though the command to query elements is called $ and $$, they have nothing to do with ... The...
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