Skip to content
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

Merged
merged 2 commits into from
Aug 15, 2024

Conversation

voxpelli
Copy link
Contributor

Fixes #80

Alternative solution would be:

Object.keys(config).length > 2

But I think its clearer when the two indexes are checked explicitly ('index' being one added by config inspector)

@eslint-github-bot eslint-github-bot bot added the bug Something isn't working label Aug 15, 2024
@@ -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">
Copy link
Collaborator

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

Copy link
Contributor Author

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

Copy link
Contributor Author

@voxpelli voxpelli Aug 15, 2024

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?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

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

Copy link
Contributor Author

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

export interface FlatConfigItem extends Omit<Linter.FlatConfig, 'files' | 'ignores'> {
name?: string
index: number
files?: (string | string[])[]
ignores?: string[]
}
into something like:

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

Copy link
Collaborator

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.

Copy link
Contributor Author

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

Copy link
Collaborator

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

@antfu antfu merged commit 7e66113 into eslint:main Aug 15, 2024
7 checks passed
@github-actions github-actions bot mentioned this pull request Aug 15, 2024
@voxpelli voxpelli deleted the voxpelli/issue80 branch August 19, 2024 10:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error in the label condition
2 participants