-
Notifications
You must be signed in to change notification settings - Fork 44
Feedback Request: ESLint ES Module Compatibility #447
Comments
This is similar to my current plan for nyc, the only difference is that nyc will support ESM in I plan to reevaluate this when it is possible to detect the format of |
@coreyfarrell That's good to hear 👍 Quick question, How do you get |
@evanplaice I didn't / it fails. Users with |
/to @evanplaice
Can't you use createRequire like this? As far as feedback, I'm not opposed to ESLint's config remaining with CJS entry points. It will not affect my current setup of writing my ESLint config in ESM format because I am currently doing as is described in the following Stack Overflow post. |
@coreyfarrell See for discussion on detecting package/file type: nodejs/node#30514 |
@DerekNonGeneric No, for 2 reasons
Custom resolvers are cool but they introduce additional complexity that may break userland in unforseen/unexpected ways. |
I see what you're saying about it not being feasible due to needing to support Node 8+ since module.createRequire() was added in v12.2.0. Thanks for mentioning |
|
Interesting, I missed most of that convo before. So, it's possible but complex to implement. I wonder how difficult it would be to package that solution in a way for other projects to use since this is going to be a common issue. |
That PR is more of a hack than anything I’d recommend. I think they should go the route of the other PR, and start supporting |
My config loading process already uses |
The RFC landed successfully. Big thank you to everybody who participated. |
New: ES Module Compatibility
The RFC to add ES module compatibility support to ESLint is ready. Feedback is welcome.
Summary
Currently,
.eslintrc.js
files are defined using the Common JS module format. When included in an ESM package (ietype: module
) using the.js
extension Node will (correctly) throw an error. The fix for this is to rename.eslintrc.js
->.eslintrc.cjs
so Node will correctly load the file as a Common JS module.This RFC identifies the reasoning as well as the modifications necessary to make ESLint recognize
.cjs
as a valid module format.Scope
This does not cover defining the config in ES module format. For now, there are no plans to add support for that approach.
Is this a viable resolution for...
The text was updated successfully, but these errors were encountered: