create-config icon indicating copy to clipboard operation
create-config copied to clipboard

Default to eslint.config.js when syntax-detection is supported

Open kecrily opened this issue 3 months ago • 4 comments

We could also consider implementing a check in @eslint/create-config during init to verify whether the Node version supports this feature, then determine the output extension accordingly.

Originally posted by @kecrily in #20129


On some Node.js versions[^1], syntax-detection feature can determine if a file is an ES Module (ESM). This means it's not necessary to use an .mjs extension for an ESM-style eslint.config.* file, even in a CJS environment (i.e., a project with no "type" field in package.json).

If the feature is supported but "type" is set to "commonjs", should we still create an ESM-style eslint.config.js?

[^1]: v22.7.0 and v20.19.0 enabled by default

kecrily avatar Sep 27 '25 07:09 kecrily

related: https://github.com/eslint/create-config/pull/206

aladdin-add avatar Oct 10 '25 05:10 aladdin-add

It looks like we're already doing this, so closing: https://github.com/eslint/create-config/blob/3fccf98672ea230981a52fbd6c5f435010edca00/lib/config-generator.js#L148

nzakas avatar Oct 22 '25 14:10 nzakas

@nzakas you may misread the issue. :)

To clarify, the issue proposes, for not setting pkg.type="module" projects, to generate eslint.config.js. The current behavior, however, creates eslint.config.mjs.

aladdin-add avatar Oct 22 '25 15:10 aladdin-add

Ah I see. I still don't think it's worth it. People may not understand this feature and I think it could cause more confusion than it helps.

nzakas avatar Oct 27 '25 21:10 nzakas

Oops! It looks like we lost track of this issue. What do we want to do here? This issue will auto-close in 7 days without an update.

github-actions[bot] avatar Nov 26 '25 22:11 github-actions[bot]