-
-
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: improved check of whether ignore is global #84
Conversation
app/components/ConfigItem.vue
Outdated
@@ -147,7 +147,7 @@ const extraConfigs = computed(() => { | |||
<div v-if="config.ignores" flex="~ gap-2 items-start"> | |||
<div i-ph-eye-closed-duotone my1 flex-none /> | |||
<div flex="~ col gap-2"> | |||
<div v-if="!config.files"> | |||
<div v-if="Object.keys(config).some(configKey => configKey !== 'ignores' && configKey !== 'index') === false"> |
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.
There is also name
- I don't know if there will be any others in the future.
Also, we need to display "invalid config" not just v-else
as the ignores are not functional when other keys presents but not files
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.
Unless it's been changed in a recent release, name
is also disallowed, something I discovered when building https://github.com/neostandard/neostandard/blob/bb370d2cec486eecd0f6057621b95628507eff5d/lib/main.js#L95-L100
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.
Are you sure the ignores are not functional when files
is not there? As I commented here #80 (comment) I think they are?
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 made the fix in humanwhocodes/config-array#131
And which is now in https://github.com/eslint/rewrite/blob/e2a7ec809db20e638abbad250d105ddbde88a8d5/packages/config-array/src/config-array.js#L76
The fix only seems to apply to ESLint 9 tho
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.
Hmm, maybe we should have @eslint/config-array
tell us then? Rather than re-implementing the check ourselves
Ideally it would use the same version of @eslint/config-array
as in the ESLint version that the user is using, but I guess that could be tricky
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.
If we would rework FlatConfigItem
from
config-inspector/shared/types.ts
Lines 4 to 9 in 59672f5
export interface FlatConfigItem extends Omit<Linter.FlatConfig, 'files' | 'ignores'> { | |
name?: string | |
index: number | |
files?: (string | string[])[] | |
ignores?: string[] | |
} |
export interface FlatConfigItem {
config: Linter.FlatConfig
index: number
}
Then we could easily add a new key ignoreGlobal
or such:
export interface FlatConfigItem {
config: Linter.FlatConfig
index: number
ignoreGlobal?: boolean
}
And we could then move the ConfigArray
creation from globMatchedFields()
and into readConfig()
itself and have it be available for such calculations there https://github.com/voxpelli/config-inspector/blob/59672f55fcd8779abbfd1e8a3042235fc8112ae3/src/configs.ts#L291-L300
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.
It wasn't even called @eslint/config-array
before v8. I don't think we could have the capability of getting that information from @eslint/config-array
as we also need to "explains". I'd say they really should backport it to v8, as that is considered a bug. For config inspector, I'd say we better move forward to display based on the latest rule.
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 check for name
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.
If we would rework FlatConfigItem from
I am up to it, we could do that in another PR
Fixes #80
Alternative solution would be:
But I think its clearer when the two indexes are checked explicitly (
'index'
being one added by config inspector)