diff --git a/apps/oxlint/src/lib.rs b/apps/oxlint/src/lib.rs index 4812ac88c741a..b1ea431d996ac 100644 --- a/apps/oxlint/src/lib.rs +++ b/apps/oxlint/src/lib.rs @@ -47,7 +47,7 @@ mod js_plugins; #[global_allocator] static GLOBAL: mimalloc_safe::MiMalloc = mimalloc_safe::MiMalloc; -const DEFAULT_OXLINTRC: &str = ".oxlintrc.json"; +const DEFAULT_OXLINTRC_NAME: &str = ".oxlintrc.json"; /// Return a JSON blob containing metadata for all available oxlint rules. /// diff --git a/apps/oxlint/src/lint.rs b/apps/oxlint/src/lint.rs index 9d4021b8baada..cfd9aff399d79 100644 --- a/apps/oxlint/src/lint.rs +++ b/apps/oxlint/src/lint.rs @@ -18,7 +18,7 @@ use oxc_linter::{ }; use crate::{ - DEFAULT_OXLINTRC, + DEFAULT_OXLINTRC_NAME, cli::{CliRunResult, LintCommand, MiscOptions, ReportUnusedDirectives, WarningOptions}, output_formatter::{LintCommandInfo, OutputFormatter}, walk::Walk, @@ -571,7 +571,7 @@ impl CliRunner { // when no config is provided, it will search for the default file names in the current working directory // when no file is found, the default configuration is returned fn find_oxlint_config(cwd: &Path, config: Option<&PathBuf>) -> Result { - let path: &Path = config.map_or(DEFAULT_OXLINTRC.as_ref(), PathBuf::as_ref); + let path: &Path = config.map_or(DEFAULT_OXLINTRC_NAME.as_ref(), PathBuf::as_ref); let full_path = cwd.join(path); if config.is_some() || full_path.exists() { @@ -583,7 +583,7 @@ impl CliRunner { /// Looks in a directory for an oxlint config file and returns the path if it exists. /// Does not validate the file or apply the default config file. fn find_oxlint_config_path_in_directory(dir: &Path) -> Option { - let possible_config_path = dir.join(DEFAULT_OXLINTRC); + let possible_config_path = dir.join(DEFAULT_OXLINTRC_NAME); if possible_config_path.is_file() { Some(possible_config_path) } else { None } } } @@ -613,7 +613,7 @@ mod test { use std::{fs, path::PathBuf}; use super::CliRunner; - use crate::{DEFAULT_OXLINTRC, tester::Tester}; + use crate::{DEFAULT_OXLINTRC_NAME, tester::Tester}; use oxc_linter::rules::RULES; // lints the full directory of fixtures, @@ -989,14 +989,14 @@ mod test { #[test] fn test_init_config() { - assert!(!fs::exists(DEFAULT_OXLINTRC).unwrap()); + assert!(!fs::exists(DEFAULT_OXLINTRC_NAME).unwrap()); let args = &["--init"]; Tester::new().with_cwd("fixtures".into()).test(args); - assert!(fs::exists(DEFAULT_OXLINTRC).unwrap()); + assert!(fs::exists(DEFAULT_OXLINTRC_NAME).unwrap()); - fs::remove_file(DEFAULT_OXLINTRC).unwrap(); + fs::remove_file(DEFAULT_OXLINTRC_NAME).unwrap(); } #[test] diff --git a/apps/oxlint/src/lsp/config_walker.rs b/apps/oxlint/src/lsp/config_walker.rs index 18eb2a814f584..fd14f6033ef8e 100644 --- a/apps/oxlint/src/lsp/config_walker.rs +++ b/apps/oxlint/src/lsp/config_walker.rs @@ -6,7 +6,7 @@ use std::{ use ignore::DirEntry; -use crate::DEFAULT_OXLINTRC; +use crate::DEFAULT_OXLINTRC_NAME; pub struct ConfigWalker { inner: ignore::WalkParallel, @@ -56,7 +56,7 @@ impl WalkCollector { } let Some(file_name) = entry.path().file_name() else { return false }; - file_name == DEFAULT_OXLINTRC + file_name == DEFAULT_OXLINTRC_NAME } } diff --git a/apps/oxlint/src/lsp/server_linter.rs b/apps/oxlint/src/lsp/server_linter.rs index ceb0b0ca16442..4a11514b3014c 100644 --- a/apps/oxlint/src/lsp/server_linter.rs +++ b/apps/oxlint/src/lsp/server_linter.rs @@ -27,7 +27,7 @@ use oxc_language_server::{ }; use crate::{ - DEFAULT_OXLINTRC, + DEFAULT_OXLINTRC_NAME, lsp::{ code_actions::{ CODE_ACTION_KIND_SOURCE_FIX_ALL_OXC, apply_all_fix_code_action, apply_fix_code_actions, @@ -80,7 +80,7 @@ impl ServerLinterBuilder { FxHashMap::default() }; let config_path = match options.config_path.as_deref() { - Some("") | None => DEFAULT_OXLINTRC, + Some("") | None => DEFAULT_OXLINTRC_NAME, Some(v) => v, }; let config = normalize_path(root_path.join(config_path)); diff --git a/apps/oxlint/src/mode/init.rs b/apps/oxlint/src/mode/init.rs index b5bb6a6949602..0343cc5ee9bdc 100644 --- a/apps/oxlint/src/mode/init.rs +++ b/apps/oxlint/src/mode/init.rs @@ -3,7 +3,7 @@ use std::{fs, path::Path}; use oxc_linter::Oxlintrc; use serde_json::Value; -use crate::{DEFAULT_OXLINTRC, cli::CliRunResult, lint::print_and_flush_stdout}; +use crate::{DEFAULT_OXLINTRC_NAME, cli::CliRunResult, lint::print_and_flush_stdout}; pub fn run_init(cwd: &Path, stdout: &mut dyn std::io::Write) -> CliRunResult { let oxlintrc_for_print = serde_json::to_string_pretty(&Oxlintrc::default()).unwrap(); @@ -22,7 +22,7 @@ pub fn run_init(cwd: &Path, stdout: &mut dyn std::io::Write) -> CliRunResult { oxlintrc_for_print }; - if fs::write(DEFAULT_OXLINTRC, configuration).is_ok() { + if fs::write(DEFAULT_OXLINTRC_NAME, configuration).is_ok() { print_and_flush_stdout(stdout, "Configuration file created\n"); return CliRunResult::ConfigFileInitSucceeded; }