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.

Expose ast-utils in the api

See original GitHub issue

The version of ESLint you are using. 6.x

The problem you want to solve. In order to customize some rules for our specific use cases, the eslint team has at times suggested forking a core rule or creating our own. Most of the core rules us the ast-utils module internally.

In order to fork these rules, we either need to fork ast-utils.js as well, or require the module by reaching deep into eslint codebase. In order to keep maintenance down on our plugin, we decided to go with the second route and require the file from the eslint code.

When upgrading to eslint v6.x from v5 we found that our plugin broke because the file was moved internally.

In addition to the problem with forking rules, this module would be very useful for creating custom rules, as the team put a lot of work into these very useful helper functions.

Your take on the correct solution to problem.

If these, and possibly other utilities, were exposed in the api export itself we could simply require the eslint module and use the ast-utlis property. (i.e. require('eslint').astUtils or similar)

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

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
kaicataldocommented, Jan 28, 2020

I think this would be a nice thing to have. I’ve started a repository here and plan to copy over general utilities (though at this point there’s no guarantee they’ll work with anything but ASTs that follow the ESTree spec).

1reaction
ilyavolodincommented, Jan 28, 2020

I agree. ast-utils were never meant to be public. I would highly suggest somebody copy and refactor them into external package if needed, since this package might be useful for other purposes as well (babel, etc.)

Read more comments on GitHub >

github_iconTop Results From Across the Web

AstUtils (Spring Boot 2.5.10 API)
Determine if a ClassNode has one or more of the specified annotations on the class or any of its methods. static boolean, hasAtLeastOneFieldOrMethod(org....
Read more >
Expose a new libflux-based API for flux formatting in go #3474
We need a go interface, akin to ast.Format, but using the libflux-based formatter instead of the go formatter. This new API should live...
Read more >
api - What does it mean to "expose" something?
It means that you enable objects to be accessed through some means. In your examples, you could let the users create, read, update...
Read more >
Overview (Hibernate API Documentation)
A Hibernate Type is a strategy for mapping a Java property type to a JDBC type or types. Miscellaneous API. org.hibernate.jmx, This package...
Read more >
How to use the asteval.Interpreter function in asteval | Snyk
To help you get started, we've selected a few asteval.Interpreter examples, based on popular ways it is used in public projects.
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