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

Expose acorn plugin from espree module #623

Open
molisani opened this issue Sep 4, 2024 · 6 comments
Open

Expose acorn plugin from espree module #623

molisani opened this issue Sep 4, 2024 · 6 comments
Labels
tsc waiting Issues that require feedback from a TSC member

Comments

@molisani
Copy link

molisani commented Sep 4, 2024

The espree parser is defined as a plugin for the Acorn parser. This plugin used to be accessible via espree/lib/espree.js, but this is now an internal module and cannot be imported directly.

Could this value be exported from the package? Something like export const acornPlugin = espree;

@nzakas
Copy link
Member

nzakas commented Sep 4, 2024

The fact that Espree is currently implemented as an Acorn plugin doesn't mean it always will be, so it doesn't make sense to export the Acorn plugin from the espree package.

However, I've been thinking it might be helpful to look at creating a different package that is more of general "ESLint Acorn plugin" that formats Acorn results in the way ESLint wants them. Espree could then use that, with any additional modifications necessary to get the full Espree experience. That would require a bit of thought, though, as it wouldn't make sense just to take the entire current Espree Acorn plugin and expose that.

@eslint/eslint-team what do you think about this idea?

@molisani
Copy link
Author

molisani commented Sep 4, 2024

I'd be perfectly happy if there was another package that exposed an "ESLint Acorn plugin", rather than exposing it from this package.

For context: I have a use case at work where we build a custom Acorn parser with specific behaviors, then we re-use that parser for ESLint. Right now we depend on espree@7 (which doesn't have exports defined on the package.json) so we can just directly import espree/lib/espree. We include the espree plugin with our own plugins and that produces a parser that works with ESLint. I ran into this exports issue when I went to update espree as it was introduced with espree@8.

@nzakas
Copy link
Member

nzakas commented Sep 5, 2024

@molisani thanks, that's very helpful context, and I think is a vote in favor of exposing the "ESLint Acorn plugin" separately to allow for people to build custom parsers with Acorn that can be used with ESLint.

@nzakas nzakas added the tsc waiting Issues that require feedback from a TSC member label Sep 10, 2024
@nzakas
Copy link
Member

nzakas commented Sep 10, 2024

Ping @eslint/eslint-tsc

@fasttime
Copy link
Member

However, I've been thinking it might be helpful to look at creating a different package that is more of general "ESLint Acorn plugin" that formats Acorn results in the way ESLint wants them. Espree could then use that, with any additional modifications necessary to get the full Espree experience. That would require a bit of thought, though, as it wouldn't make sense just to take the entire current Espree Acorn plugin and expose that.

I like the idea of an Acorn plugin, but to be honest I don't understand what is specific to Espree that is not also specific to ESLint, or was specific to ESLint at some point in time. So I'm not sure what the general "ESLint Acorn plugin" should expose if not the entire current Espree Acorn plugin, as the OP suggested. I'd be happy to comment on a more detailed proposal.

@nzakas
Copy link
Member

nzakas commented Sep 12, 2024

So I'm not sure what the general "ESLint Acorn plugin" should expose if not the entire current Espree Acorn plugin, as the OP suggested.

I'd need to look more closely, but basically it would be Espree without JSX support or impliedStrict (no ecmaFeatures) and would only export the plugin and not a parse() function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tsc waiting Issues that require feedback from a TSC member
Projects
Status: Feedback Needed
Development

Successfully merging a pull request may close this issue.

3 participants