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 querying for nodes using the eslint node selector syntax from an individual node

See original GitHub issue

The version of ESLint you are using.

6.4.0

The problem you want to solve.

Want to be able to query for nodes using the eslint node selector syntax from a particular node, instead of the main visitor body callback, to make it easier to locate nodes that maybe relevant for writing descriptive error messages or fixes. Eslint already has an amazing selector syntax, so it would be great to be able to utilize it here too.

Currently, once you’re in the visitor, all the traversal has to be done manually.

Your take on the correct solution to problem.

Like how .querySelector() exists not only for the document but for every element in the DOM, I think that adding a similar method for each node would be nice. Another approach could be to add it to the context object, something like context.queryNodes(rootNode, selector).

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

Sure but could be easier for someone with a more intimate knowledge of ESLint internals

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
kaicataldocommented, Feb 20, 2020

I really like this idea! I think it would be better to include it in the context object that’s passed to each rule (maybe on SourceCode)? Since this is a change to core, we’ll probably want to write up an RFC.

Simplifying traversal of children nodes sounds really useful and would improve the DX of rules immensely.

0reactions
eslint-deprecated[bot]commented, Apr 18, 2020

Unfortunately, it looks like there wasn’t enough interest from the team or community to implement this change. While we wish we’d be able to accommodate everyone’s requests, we do need to prioritize. We’ve found that issues failing to reach accepted status after 21 days tend to never be accepted, and as such, we close those issues. This doesn’t mean the idea isn’t interesting or useful, just that it’s not something the team can commit to.

Thanks for contributing to ESLint and we appreciate your understanding.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Selectors - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
Placing pods on specific nodes using node selectors
A node selector specifies a map of key/value pairs that are defined using custom labels on nodes and selectors specified in pods.
Read more >
Document.querySelector() - Web APIs | MDN
The Document method querySelector() returns the first Element within the document that matches the specified selector, or group of selectors ...
Read more >
Learn How to Assign Pods to Nodes in Kubernetes Using ...
Learn How to Assign Pods to Nodes in Kubernetes Using nodeSelector and Affinity Features. As we've already discussed in our earlier tutorials, ...
Read more >
Assigning Pods to Nodes - Kubernetes
Add labels with the node-restriction.kubernetes.io/ prefix to your nodes, and use those labels in your node selectors.
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