eslint / create-config

Utility to create ESLint config files
MIT License
76 stars 19 forks source link

Eslint config file genrate error #102

Closed vfan closed 6 months ago

vfan commented 6 months ago

https://github.com/eslint/create-config/blob/dbd874289676e3b1442bf3d3984070b6fed5586b/lib/config-generator.js#L136

When my module is commonjs type,it generate eslint.config.mjs

Rec0iL99 commented 6 months ago

Hi @vfan, thanks for the issue. I believe this is working as intended. By default, the generated ESLint config always follows JavaScript modules syntax (import/export).

import globals from "globals";
import pluginJs from "@eslint/js";

export default [
  {languageOptions: { globals: globals.node }},
  pluginJs.configs.recommended,
];

In your case since your project follows commonjs syntax (require), the config file will have the .mjs extension to indicate that this file must be evaluated using JavaScript modules syntax.

If your package.json had type: module, which indicates that the project follows JavaScript modules syntax, then a eslint.config.js file would be generated instead of a eslint.config.mjs.