Skip to content

Expose acorn plugin from espree module #623

Open

Description

@molisani

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;

Activity

  1. moved this to Needs Triage in Triageon Sep 4, 2024
  2. nzakas commented on Sep 4, 2024

    @nzakas
    Member

    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?

  3. moved this from Needs Triage to Feedback Needed in Triageon Sep 4, 2024
  4. molisani commented on Sep 4, 2024

    @molisani
    Author

    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.

  5. nzakas commented on Sep 5, 2024

    @nzakas
    Member

    @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.

  6. added
    tsc waitingIssues that require feedback from a TSC member
    on Sep 10, 2024
  7. nzakas commented on Sep 10, 2024

    @nzakas
    Member

    Ping @eslint/eslint-tsc

  8. fasttime commented on Sep 12, 2024

    @fasttime
    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.

  9. nzakas commented on Sep 12, 2024

    @nzakas
    Member

    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.

  10. sam3k commented on Oct 22, 2024

    @sam3k

    Per TSC meeting on 2024-10-17, @mdjermanovic will look more closely into this so the team can make a decision on next steps.

  11. mdjermanovic commented on Oct 29, 2024

    @mdjermanovic
    Member

    I'm in favor of extracting an ESLint Acorn plugin into a separate package 👍

  12. added and removed
    tsc waitingIssues that require feedback from a TSC member
    on Nov 1, 2024
  13. moved this from Feedback Needed to Ready to Implement in Triageon Nov 1, 2024
  14. nzakas commented on Nov 1, 2024

    @nzakas
    Member

    Marking as accepted. I'll plan on taking a look at this after the CSS and YAML plugins, so if anyone else wants to take a look first, please be my guest.

  15. self-assigned this
    on Nov 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

  • Status
    Ready to Implement

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions