Description
ESLint version
8.56.0
What problem do you want to solve?
ESLint configs have traditionally been exported by ESLint plugins under a standard configs
object (alongside the rules
object). This has allowed tooling like eslint-doc-generator and lintbase.com to automatically detect/analyze configs and generate documentation regarding them including the list of configs, which rules belong to which configs, etc.
New flat configs can be exported in a variety of ways, including as an arbitrary file export from the plugin, such as require('eslint-plugin-ember/configs/recommended')
in this example I worked on, and not necessarily in the configs
object exported by the plugin.
For existing plugins that want to support both legacy and flat versions of their configs while maintaining backwards-compatability, I've typically seen them leave the configs
object for legacy configs, and add file exports for the new flat configs.
To my knowledge, since there aren't strict requirements around how or where flat configs are exported from, the user has to manually look up in the plugin's README to find out what the configs are and how exactly to import and use them (including whether they are arrays or objects). As you can imagine, depending on the README to discover configs is not conducive to automated tooling.
What do you think is the correct solution?
Note: See updated proposal in: #18095 (comment)
Could there be a convention or requirement for how plugins should export flat configs? Presumably, this would keep legacy config exporting the same through the configs
object for backwards-compatability so plugins can support both config types, at least for some time.
One idea is to require or suggest plugins to export a new configurations
object containing a mapping of config name to each loaded flat config.
And what about recommendations around the direct file path entrypoint for exporting flat configs? I've seen plugins using eslint-plugin-example/configs/config-name
or variations of this. Perhaps we could at least recommend a path format.
Ideally, any convention or requirement would enable programmatic discoverability of flat configs, with the added benefit of simply making it easier to use flat configs.
Participation
- I am willing to submit a pull request for this change.
Additional comments
Related:
Metadata
Metadata
Assignees
Labels
Type
Projects
Status