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: prepend eslint default configs #66

Merged
merged 3 commits into from
Jun 21, 2024

Conversation

voxpelli
Copy link
Contributor

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

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
@eslint-github-bot eslint-github-bot bot added the bug Something isn't working label Jun 21, 2024
Comment on lines +121 to +127
{
name: 'eslint/defaults/ignores',
ignores: [
'**/node_modules/',
'.git/',
],
} as FlatConfigItem,
Copy link
Contributor Author

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:

ignore: [
'**/node_modules/**',
'**/dist/**',
'**/.git/**',
...configs

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 Thoughts?

Copy link
Collaborator

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.

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 request to expose the ESLint logic: eslint/eslint#18619

@antfu antfu merged commit 4ef77d9 into eslint:main Jun 21, 2024
7 checks passed
@antfu antfu changed the title fix: match default file patterns as well fix: prepend eslint default configs Jun 21, 2024
@github-actions github-actions bot mentioned this pull request Jun 21, 2024
@voxpelli voxpelli deleted the match-default-file-patterns branch June 21, 2024 12:34
voxpelli added a commit to neostandard/neostandard that referenced this pull request Jun 21, 2024
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.

2 participants