-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Description
ESLint version
v9.0.0-rc.0
What problem do you want to solve?
(This is more like an RFC, but since it's rather simple, I started here first, but up to moving it to a proper RFC if you think it's necessary)
The new flat config format is truly great in many ways - I guess I don't need to list them - but thank you for making this move!
While it's great and much more composable, I often find it hard to tell the meaning/scope of each flat config item just by looking at the config among a large number of configs.
That's why I made https://github.com/antfu/eslint-flat-config-viewer, an interactive web UI to display the resolved flat configure structure with a search to understand how rules are applied. But still - given that the flat config items are anonymous, it not obvious what config are for what purpose.
Thus in the config viewer, and my own eslint-config, I spontaneously invented the convention of having that name field convention in my config and displaying name in the viewer. for example like this:
import eslint from '@eslint/js'
export default [
{
name: 'eslint:js', // assign custom name to other config
...eslint
},
{
name: 'antfu:ts',
// ts plugins & rules...
},
{
name: 'antfu:vue',
// vue plugins & rules...
}
{
name: 'antfu:vue:disables':
// ...
}
]Which I believe helps a lot on communications as well as some userland overrides like:
flatConfigs
.find(c => c.name === 'stylistic')
.rules['indent'] = 'off'
export default flatConfigsWhat do you think is the correct solution?
Even if it "kinda works" right now, as ESLint is not compliant about the extra name properties (#17842 (comment)). But I think it would be great for the ecosystem to make it an official supported way and develop a convention across the ecosystem. The shared configs from plugins could have their plugin name as the prefix for their configs for example.
To achieve that, I think we could:
- Add
nameto the flat config schema, and add it in@types/eslint - Add a doc section to recommend plugins/configs authors to provide that field with a convention (could be
namespace:scope:sub-scopeornamespace/scopeetc, but more like a convention, not a constraint) - Integrations like https://github.com/antfu/eslint-flat-config-viewer could follow up that convention to provide a better DX for users,
Participation
- I am willing to submit a pull request for this change.
Additional comments
No response
Metadata
Metadata
Assignees
Labels
Type
Projects
Status