-
-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: prepend eslint default configs #66
Conversation
The default config in ESLint is always prepended to the config before it uses the config, making it so that `**/*.js`, `**/*.mjs`, `**/*.cjs` are always matching file patterns: https://github.com/eslint/eslint/blob/21d3766c3f4efd981d3cc294c2c82c8014815e6e/lib/config/default-config.js#L66-L69 This PR copies those two configs and prepends them here as well, with some added names for them to make sense. This is somewhat of a blunt fix. UI-wise it can be handled better and ideally one or more of `defaultConfig`, `FlatConfigArray` and `calculateConfigArray` would be exposed by ESLint so that this inspector can make use of the very same logic rather than attempt to reimplement it. If additionally `defaultConfig` were to eg. add names, then this inspector could opt to eg. hide all `eslint/` prefixed rules and as such get the correct prepended config without having to confuse users with showing a config they never themselves added
{ | ||
name: 'eslint/defaults/ignores', | ||
ignores: [ | ||
'**/node_modules/', | ||
'.git/', | ||
], | ||
} as FlatConfigItem, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can remove them from here then:
config-inspector/src/configs.ts
Lines 186 to 190 in f22548b
ignore: [ | |
'**/node_modules/**', | |
'**/dist/**', | |
'**/.git/**', | |
...configs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@antfu Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't mind either way - in the end this globbing things is more or less a approximation for reference. Would be nice if we could reuse the ESLint's logic to get the same result. Otherwise I see no much differences, and honestly would slightly prefer to keep it as-is to make sure we don't over scan.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@antfu Added a request to expose the ESLint logic: eslint/eslint#18619
The default config in ESLint is always prepended to the config before it uses the config, making it so that
**/*.js
,**/*.mjs
,**/*.cjs
are always matching file patterns: https://github.com/eslint/eslint/blob/21d3766c3f4efd981d3cc294c2c82c8014815e6e/lib/config/default-config.js#L66-L69This PR copies those two configs and prepends them here as well, with some added names for them to make sense.
This is somewhat of a blunt fix. UI-wise it can be handled better and ideally one or more of
defaultConfig
,FlatConfigArray
andcalculateConfigArray
would be exposed by ESLint so that this inspector can make use of the very same logic rather than attempt to reimplement it.If additionally
defaultConfig
were to eg. add names, then this inspector could opt to eg. hide alleslint/
prefixed rules and as such get the correct prepended config without having to confuse users with showing a config they never themselves added