Skip to content

Commit 122aff7

Browse files
committed
refactor(linter): rename DEFAULT_OXLINTRC to `DEFAULT_OXLINTRC_NAME
1 parent b393430 commit 122aff7

5 files changed

Lines changed: 14 additions & 14 deletions

File tree

apps/oxlint/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ mod js_plugins;
4747
#[global_allocator]
4848
static GLOBAL: mimalloc_safe::MiMalloc = mimalloc_safe::MiMalloc;
4949

50-
const DEFAULT_OXLINTRC: &str = ".oxlintrc.json";
50+
const DEFAULT_OXLINTRC_NAME: &str = ".oxlintrc.json";
5151

5252
/// Return a JSON blob containing metadata for all available oxlint rules.
5353
///

apps/oxlint/src/lint.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use oxc_linter::{
1818
};
1919

2020
use crate::{
21-
DEFAULT_OXLINTRC,
21+
DEFAULT_OXLINTRC_NAME,
2222
cli::{CliRunResult, LintCommand, MiscOptions, ReportUnusedDirectives, WarningOptions},
2323
output_formatter::{LintCommandInfo, OutputFormatter},
2424
walk::Walk,
@@ -571,7 +571,7 @@ impl CliRunner {
571571
// when no config is provided, it will search for the default file names in the current working directory
572572
// when no file is found, the default configuration is returned
573573
fn find_oxlint_config(cwd: &Path, config: Option<&PathBuf>) -> Result<Oxlintrc, OxcDiagnostic> {
574-
let path: &Path = config.map_or(DEFAULT_OXLINTRC.as_ref(), PathBuf::as_ref);
574+
let path: &Path = config.map_or(DEFAULT_OXLINTRC_NAME.as_ref(), PathBuf::as_ref);
575575
let full_path = cwd.join(path);
576576

577577
if config.is_some() || full_path.exists() {
@@ -583,7 +583,7 @@ impl CliRunner {
583583
/// Looks in a directory for an oxlint config file and returns the path if it exists.
584584
/// Does not validate the file or apply the default config file.
585585
fn find_oxlint_config_path_in_directory(dir: &Path) -> Option<PathBuf> {
586-
let possible_config_path = dir.join(DEFAULT_OXLINTRC);
586+
let possible_config_path = dir.join(DEFAULT_OXLINTRC_NAME);
587587
if possible_config_path.is_file() { Some(possible_config_path) } else { None }
588588
}
589589
}
@@ -613,7 +613,7 @@ mod test {
613613
use std::{fs, path::PathBuf};
614614

615615
use super::CliRunner;
616-
use crate::{DEFAULT_OXLINTRC, tester::Tester};
616+
use crate::{DEFAULT_OXLINTRC_NAME, tester::Tester};
617617
use oxc_linter::rules::RULES;
618618

619619
// lints the full directory of fixtures,
@@ -989,14 +989,14 @@ mod test {
989989

990990
#[test]
991991
fn test_init_config() {
992-
assert!(!fs::exists(DEFAULT_OXLINTRC).unwrap());
992+
assert!(!fs::exists(DEFAULT_OXLINTRC_NAME).unwrap());
993993

994994
let args = &["--init"];
995995
Tester::new().with_cwd("fixtures".into()).test(args);
996996

997-
assert!(fs::exists(DEFAULT_OXLINTRC).unwrap());
997+
assert!(fs::exists(DEFAULT_OXLINTRC_NAME).unwrap());
998998

999-
fs::remove_file(DEFAULT_OXLINTRC).unwrap();
999+
fs::remove_file(DEFAULT_OXLINTRC_NAME).unwrap();
10001000
}
10011001

10021002
#[test]

apps/oxlint/src/lsp/config_walker.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::{
66

77
use ignore::DirEntry;
88

9-
use crate::DEFAULT_OXLINTRC;
9+
use crate::DEFAULT_OXLINTRC_NAME;
1010

1111
pub struct ConfigWalker {
1212
inner: ignore::WalkParallel,
@@ -56,7 +56,7 @@ impl WalkCollector {
5656
}
5757
let Some(file_name) = entry.path().file_name() else { return false };
5858

59-
file_name == DEFAULT_OXLINTRC
59+
file_name == DEFAULT_OXLINTRC_NAME
6060
}
6161
}
6262

apps/oxlint/src/lsp/server_linter.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use oxc_language_server::{
2727
};
2828

2929
use crate::{
30-
DEFAULT_OXLINTRC,
30+
DEFAULT_OXLINTRC_NAME,
3131
lsp::{
3232
code_actions::{
3333
CODE_ACTION_KIND_SOURCE_FIX_ALL_OXC, apply_all_fix_code_action, apply_fix_code_actions,
@@ -80,7 +80,7 @@ impl ServerLinterBuilder {
8080
FxHashMap::default()
8181
};
8282
let config_path = match options.config_path.as_deref() {
83-
Some("") | None => DEFAULT_OXLINTRC,
83+
Some("") | None => DEFAULT_OXLINTRC_NAME,
8484
Some(v) => v,
8585
};
8686
let config = normalize_path(root_path.join(config_path));

apps/oxlint/src/mode/init.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::{fs, path::Path};
33
use oxc_linter::Oxlintrc;
44
use serde_json::Value;
55

6-
use crate::{DEFAULT_OXLINTRC, cli::CliRunResult, lint::print_and_flush_stdout};
6+
use crate::{DEFAULT_OXLINTRC_NAME, cli::CliRunResult, lint::print_and_flush_stdout};
77

88
pub fn run_init(cwd: &Path, stdout: &mut dyn std::io::Write) -> CliRunResult {
99
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 {
2222
oxlintrc_for_print
2323
};
2424

25-
if fs::write(DEFAULT_OXLINTRC, configuration).is_ok() {
25+
if fs::write(DEFAULT_OXLINTRC_NAME, configuration).is_ok() {
2626
print_and_flush_stdout(stdout, "Configuration file created\n");
2727
return CliRunResult::ConfigFileInitSucceeded;
2828
}

0 commit comments

Comments
 (0)