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

Support ESM config (.eslintrc.mjs) #13440

Closed
jsejcksn opened this issue Jun 23, 2020 · 19 comments
Closed

Support ESM config (.eslintrc.mjs) #13440

jsejcksn opened this issue Jun 23, 2020 · 19 comments
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion auto closed The bot closed this issue core Relates to ESLint's core APIs and features enhancement This change enhances an existing feature of ESLint evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion

Comments

@jsejcksn
Copy link

Search terms used: is:issue is:open mjs OR esm OR "es module"

cf. #12593, which was auto-closed. All of the issues/RFCs mentioned as blockers in that issue are now closed/merged.

What is the status of ES module support for config files? In the form of

  • .eslintrc.mjs or
  • .eslintrc.js where the nearest package.json includes "type": "module"
@jsejcksn jsejcksn added core Relates to ESLint's core APIs and features enhancement This change enhances an existing feature of ESLint triage An ESLint team member will look at this issue soon labels Jun 23, 2020
@kaicataldo
Copy link
Member

Now that we have an asynchronous API, I believe that supporting .mjs is unblocked from a technical standpoint. For the second bullet point, ESLint does already support .eslintrc.cjs files, so this should not be an issue (see here for more details).

@kaicataldo
Copy link
Member

Would you like to create an RFC for adding support for .mjs?

@kaicataldo kaicataldo added evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion and removed triage An ESLint team member will look at this issue soon labels Jun 25, 2020
@jsejcksn
Copy link
Author

@kaicataldo Oh, wow—I thought this was already on the roadmap based on all of the discussion around it. I’ll take a look at the RFC process. Does it require having any knowledge of ESLint’s internal API (not user API)?

@kaicataldo
Copy link
Member

The RFC template is a section for outlining what kind of changes would be required to implement it, which is really useful both for evaluating trade offs as well as for whoever ends up implementing the accepted RFC.

This is definitely something we want to do, but I do think it makes sense to go through this process to make sure we approach it thoughtfully.

@jsejcksn
Copy link
Author

@kaicataldo I looked and I don't think I have enough knowledge about ESLint internals to provide implementation details. Is there an RFC for an RFC 😄?

@kaicataldo
Copy link
Member

Ha! My personal take is that this is something we’re going to have to implement eventually anyway, if you’re willing to wait :)

In the meantime, it should be possible to use a .eslintrc.cjs configuration file.

@jsejcksn
Copy link
Author

Sure—I just didn't see a place to track ESM configs specifically, so I created this issue.

@Rishabh-malhotraa
Copy link

@kaicataldo I would like to try to solve this issue :)

@kaicataldo
Copy link
Member

@Rishabh-malhotraa Great! As mentioned above, the next step is create an RFC for this so that we can decide how this should be implemented.

@nzakas
Copy link
Member

nzakas commented Jul 6, 2020

Given that we are moving forward with a different config system, I think any changes should be proposed for the new system rather than continuing to modify the current system.
eslint/rfcs#9

@jsejcksn
Copy link
Author

jsejcksn commented Jul 6, 2020

Given that we are moving forward with a different config system

@nzakas I thought it was just an RFC at this point. Especially in consideration of the statement in your most recent message, isn’t it prudent to support ESM in the current system?

@nzakas
Copy link
Member

nzakas commented Jul 7, 2020

The RFC was accepted several months ago and will be the new config system for ESLint. There were some outstanding questions that had to be answered so I kept iterating until we got most of them ironed out. It will be formally merged this week with development starting next week.

I don’t see a scenario where it makes sense to update the eslintrc config system to support ESM. The simple config system actually makes supporting ESM super easy, though I’m not sure I’d want to support the .mjs extension as I think that will be a relic in the next couple years. However, we could support ESM in simple config files relatively easily.

@ljharb
Copy link
Sponsor Contributor

ljharb commented Jul 7, 2020

@nzakas i'm not sure why it'd be a relic; it'll be supported by node for the foreseeable future, and is the best way to avoid ambiguity about what .js means (which is "not a module", unless you use the type field to subvert that).

@nzakas
Copy link
Member

nzakas commented Jul 7, 2020

@ljharb I just don't foresee people using it much after the transition period from CJS to ESM. Right now, it's a stopgap for needing to support both in Node.js packages, but eventually (and probably sooner than we realize), no one is going to be writing CJS, so I'm not sure it's worth adding in support for a stopgap measure that eventually won't be used.

@ljharb
Copy link
Sponsor Contributor

ljharb commented Jul 7, 2020

imo that's entirely false :-) people are still writing ES5, and sloppy code, and Scripts, and I think CJS will be around for effectively ever. Obv we don't have to agree here, but the node modules group is expecting a minimum of 10 years before it'd even be remotely possible to consider deprecating any CJS features.

@nzakas
Copy link
Member

nzakas commented Jul 9, 2020

Here's the nice thing about my approach: if I'm wrong, we can always add support for .mjs later. I'm just less inclined to add a feature that may or may not be needed because we already have nearly seven years of backwards compatibility cruft in ESLint that we really can't remove, so I don't want to add more unless we need it.

@eslint-deprecated eslint-deprecated bot added the auto closed The bot closed this issue label Aug 10, 2020
@eslint-deprecated
Copy link

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.

@nzakas
Copy link
Member

nzakas commented Aug 11, 2020

As a final note here: ESM config will be part of the eslint/rfcs#9 implementation.

@KilianKilmister
Copy link

KilianKilmister commented Sep 11, 2020

@kaicataldo

In the meantime, it should be possible to use a .eslintrc.cjs configuration file.

Well yes, but only sort of. I just tried to use a dynamit import( ) statement in my config, but eslint isn't able to use that.
I'm in the process of filing an issue about it with the details. issue filed

@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 7, 2021
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Feb 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion auto closed The bot closed this issue core Relates to ESLint's core APIs and features enhancement This change enhances an existing feature of ESLint evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion
Projects
None yet
Development

No branches or pull requests

6 participants