Open vneogi199 opened 8 months ago
Thank you @vneogi199 for the suggestion.
The early versions on flat config parser were failing with ESM syntax so we implemented it with CJS. We can look into this again, since there were several versions of eslint released in the meantime.
🔝 This. And I also noticed that if I migrate the eslint.config.js
to ESM, the generators for new libraries stop working, because it expects module.exports
to be present.
https://github.com/nrwl/nx/blob/8f9ea6a8c55423f28d6a2159a572d0d90d0a4e13/packages/eslint/src/generators/utils/flat-config/ast-utils.ts#L352
TypeError: Cannot read properties of undefined (reading 'length')
The workaround is to set linter
to none
for generators, and then generate eslint-related code manually. That, or having to deal with renaming eslint.config.js
to eslint.config.cjs
.
Any updates on this? Seems like the support for Flat Config isn't really there yet and the announcement was a bit premature? Maybe? Would like to know if it is more of a "beta" feature support
Once ESM is supported, it would be nice to have a CJS=>ESM migration. Should I open a distinct issue for that?
Description
Currently, @nx/eslint:convert-to-flat-config creates an eslint.config.js with CJS syntax (require). It should also allow user to create same file with ESM syntax (import/export).
Motivation
When source code is in ESM, it is better to have eslint.config.js also to be in ESM. It will help to use
"type": "module"
in package.jsonSuggested Implementation
Convert
require
toimport
andmodule.exports
toexport default
.Alternate Implementations