From cded0add2314fa40e3274ed8cd49c560062665b6 Mon Sep 17 00:00:00 2001 From: camchenry <1514176+camchenry@users.noreply.github.com> Date: Thu, 20 Feb 2025 02:40:46 +0000 Subject: [PATCH] feat(oxlint): add `--experimental-nested-config` option (#9152) - part of https://github.com/oxc-project/oxc/issues/7408 Since the nested configuration work is too big to fit in one PR or even a stack of PRs, I suggest that we make it temporarily an opt-in CLI flag. Once we feel confident in the implementation replacing the existing code, we can remove the flag and make it true by default. --- apps/oxlint/src/command/lint.rs | 12 ++++++++++++ tasks/website/src/linter/snapshots/cli.snap | 2 ++ tasks/website/src/linter/snapshots/cli_terminal.snap | 2 ++ 3 files changed, 16 insertions(+) diff --git a/apps/oxlint/src/command/lint.rs b/apps/oxlint/src/command/lint.rs index 6dd7fae7d0217..ba145aa2860f5 100644 --- a/apps/oxlint/src/command/lint.rs +++ b/apps/oxlint/src/command/lint.rs @@ -41,6 +41,10 @@ pub struct LintCommand { #[bpaf(external)] pub misc_options: MiscOptions, + /// Enables automatic loading of nested configuration files (experimental feature) + #[bpaf(switch, hide_usage)] + pub experimental_nested_config: bool, + /// Single file, single path or list of paths #[bpaf(positional("PATH"), many, guard(validate_paths, PATHS_ERROR_MESSAGE))] pub paths: Vec, @@ -513,4 +517,12 @@ mod lint_options { let options = get_lint_options("--rules"); assert!(options.list_rules); } + + #[test] + fn experimental_nested_config() { + let options = get_lint_options("--experimental-nested-config"); + assert!(options.experimental_nested_config); + let options = get_lint_options("."); + assert!(!options.experimental_nested_config); + } } diff --git a/tasks/website/src/linter/snapshots/cli.snap b/tasks/website/src/linter/snapshots/cli.snap index 43ec6f254eecd..0ab5268405646 100644 --- a/tasks/website/src/linter/snapshots/cli.snap +++ b/tasks/website/src/linter/snapshots/cli.snap @@ -133,6 +133,8 @@ Arguments: ## Available options: - **` --rules`** — list all the rules that are currently registered +- **` --experimental-nested-config`** — + Enables automatic loading of nested configuration files (experimental feature) - **`-h`**, **`--help`** — Prints help information - **`-V`**, **`--version`** — diff --git a/tasks/website/src/linter/snapshots/cli_terminal.snap b/tasks/website/src/linter/snapshots/cli_terminal.snap index ad85d31807f29..d3e1a429a7770 100644 --- a/tasks/website/src/linter/snapshots/cli_terminal.snap +++ b/tasks/website/src/linter/snapshots/cli_terminal.snap @@ -81,5 +81,7 @@ Available positional items: Available options: --rules list all the rules that are currently registered + --experimental-nested-config Enables automatic loading of nested configuration files + (experimental feature) -h, --help Prints help information -V, --version Prints version information