diff --git a/apps/oxlint/fixtures/auto_config_detection/oxlint.json b/apps/oxlint/fixtures/auto_config_detection/.oxlintrc.json similarity index 100% rename from apps/oxlint/fixtures/auto_config_detection/oxlint.json rename to apps/oxlint/fixtures/auto_config_detection/.oxlintrc.json diff --git a/apps/oxlint/src/command/lint.rs b/apps/oxlint/src/command/lint.rs index 844f66e896058..e444cb9f623e3 100644 --- a/apps/oxlint/src/command/lint.rs +++ b/apps/oxlint/src/command/lint.rs @@ -63,11 +63,7 @@ pub struct BasicOptions { /// * only `.json` extension is supported /// * tries to be compatible with the ESLint v8's format /// - /// If not provided, Oxlint will look for the following files in the current working directory: - /// * `oxlintrc.json` - /// * `oxlint.json` - /// * `.oxlintrc.json` - /// * `.oxlint.json` + /// If not provided, Oxlint will look for `.oxlintrc.json` in the current working directory. #[bpaf(long, short, argument("./oxlintrc.json"))] pub config: Option, diff --git a/apps/oxlint/src/lint.rs b/apps/oxlint/src/lint.rs index f4ef7fce319ea..644537e7d2779 100644 --- a/apps/oxlint/src/lint.rs +++ b/apps/oxlint/src/lint.rs @@ -176,6 +176,8 @@ impl Runner for LintRunner { } impl LintRunner { + const DEFAULT_OXLINTRC: &'static str = ".oxlintrc.json"; + #[must_use] pub fn with_cwd(mut self, cwd: PathBuf) -> Self { self.cwd = cwd; @@ -259,22 +261,13 @@ impl LintRunner { } // no config argument is provided, - // auto detect possible files from current work directory - let search_configs = &[ - "oxlintrc.json", - "oxlint.json", - ".oxlintrc.json", - ".oxlint.json" - ]; - - for config_file in search_configs { - let mut config_path = cwd.to_path_buf(); - config_path.push(config_file); + // auto detect default config file from current work directory + let mut config_path = cwd.to_path_buf(); + config_path.push(Self::DEFAULT_OXLINTRC); - if let Ok(result) = Oxlintrc::from_file(&config_path) { - return Ok(result); - }; - } + if let Ok(result) = Oxlintrc::from_file(&config_path) { + return Ok(result); + }; Ok(Oxlintrc::default()) } diff --git a/tasks/website/src/linter/snapshots/cli.snap b/tasks/website/src/linter/snapshots/cli.snap index 0edb318fe178b..e7653edd16d2a 100644 --- a/tasks/website/src/linter/snapshots/cli.snap +++ b/tasks/website/src/linter/snapshots/cli.snap @@ -12,11 +12,7 @@ snapshot_kind: text * only `.json` extension is supported * tries to be compatible with the ESLint v8's format - If not provided, Oxlint will look for the following files in the current working directory: -* `oxlintrc.json` -* `oxlint.json` -* `.oxlintrc.json` -* `.oxlint.json` + If not provided, Oxlint will look for `.oxlintrc.json` in the current working directory. - **` --tsconfig`**=_`<./tsconfig.json>`_ — TypeScript `tsconfig.json` path for reading path alias and project references for import plugin