-
-
Notifications
You must be signed in to change notification settings - Fork 538
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
feat(linter): add support for nested config files #9153
feat(linter): add support for nested config files #9153
Conversation
CodSpeed Performance ReportMerging #9153 will not alter performanceComparing Summary
|
916676b
to
cbee206
Compare
68e1b61
to
c79e043
Compare
cbee206
to
5d576be
Compare
e946ee1
to
19878f1
Compare
5d576be
to
1edd010
Compare
19878f1
to
cdbcf2b
Compare
Thanks for the great work ❤️ I added some comments and I have a question:
https://eslint.org/docs/latest/use/configure/configuration-files-deprecated#cascading-and-hierarchy Is this part missing? I could not find the code where you merge the different configurations like |
1edd010
to
cded0ad
Compare
cdbcf2b
to
9194935
Compare
9194935
to
20cdf87
Compare
Merge activity
|
@Boshen I'll address the merge conflicts and then merge this EDIT: Actually, I'll see about addressing the comment above on stopping iteration when looping over directories and maybe do some benchmarking tomorrow first. |
20cdf87
to
667768c
Compare
I'm going to use this repository as a candidate for benchmarking: https://github.com/microsoft/fluentui, as it has a lot of nested
BenchmarkSetupUsing the For simulating something similar to the existing ESLint setup, I ran the following command to replace every find . -name ".eslintrc*" -exec sh -c 'printf "{\n}\n" > "$(dirname "{}")/.oxlintrc.json"' \; This resulted in 260 Building // get all of the unique directories among the paths to use for search for
// oxlint config files in those directories
// e.g. `/some/file.js` and `/some/other/file.js` would both result in `/some`
for path in &paths {
if let Some(directory) = path.parent() {
// TODO(perf): benchmark whether or not it is worth it to produce the config files here without
// iterating over the directories again. it might cause the cache for paths to be disrupted, but
// it is unclear whether or not that is a problem in practice.
if let Ok(config) = Self::find_oxlint_config_in_directory(directory) {
num_configs += 1;
nested_oxlintrc.insert(directory, config);
}
}
} The executable version for the single-pass config search is Results![]()
|
I guess this is only when no Could you please resolve the conflicts? The changes are good for me now 👍 A future idea: |
92eaf4f
to
1174024
Compare
@Sysix Sorry, you caught me in the middle of benchmarking and I left the comment in a half written state for a few hours 😅 I updated the post with a better benchmark. Overall, I think performance is looking pretty good (so far), in the range of 5-6% slower so far, so not worth optimizing quite yet. |
- part of #7408 This is the initial implementation for nested config support, without the `extends` keyword factoring into it yet. So we only load a single config file for any given file still, but it will always be the one closest to the file being linted. Performance is somewhat of a big TODO here, obviously there is some inherent cost to adding support for nested configurations since we need to check if any directory contains an `.oxlintrc.json` file, load it if it exists, and then for every file below that directory check if we should use it. I've left a few TODOs of different ways we might be able to cache more data at the cost of memory but at the potential gain of some CPU time. Optimizing iteration over files/directories is one way in which we might be able to make this faster, so we never need to visit the same directory twice. For now, this will remain an experimental feature that should not affect the current functionality until we enable it for everyone. PRs stacked on top of this will focus on ensuring that other features work well with this, such as `--config`, `-D <rule>`, and then we'll add new features like `extends`. The configuration loading all happens upfront currently, while the config resolution happens at lint-time. There is a new `nested_configs` field on the `Linter` that passes all of the configs that are available, so it can pick which one to use later. Eventually we'll refactor this to not have two duplicate config fields, but I'm leaving it as-is to ensure we're not messing up the existing functionality.
1174024
to
9bc3017
Compare
This is the initial implementation for nested config support, without the
extends
keyword factoring into it yet. So we only load a single config file for any given file still, but it will always be the one closest to the file being linted.Performance is somewhat of a big TODO here, obviously there is some inherent cost to adding support for nested configurations since we need to check if any directory contains an
.oxlintrc.json
file, load it if it exists, and then for every file below that directory check if we should use it. I've left a few TODOs of different ways we might be able to cache more data at the cost of memory but at the potential gain of some CPU time. Optimizing iteration over files/directories is one way in which we might be able to make this faster, so we never need to visit the same directory twice.For now, this will remain an experimental feature that should not affect the current functionality until we enable it for everyone. PRs stacked on top of this will focus on ensuring that other features work well with this, such as
--config
,-D <rule>
, and then we'll add new features likeextends
.The configuration loading all happens upfront currently, while the config resolution happens at lint-time. There is a new
nested_configs
field on theLinter
that passes all of the configs that are available, so it can pick which one to use later. Eventually we'll refactor this to not have two duplicate config fields, but I'm leaving it as-is to ensure we're not messing up the existing functionality.