Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/oxlint/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand Down
14 changes: 7 additions & 7 deletions apps/oxlint/src/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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<Oxlintrc, OxcDiagnostic> {
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() {
Expand All @@ -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<PathBuf> {
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 }
}
}
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions apps/oxlint/src/lsp/config_walker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::{

use ignore::DirEntry;

use crate::DEFAULT_OXLINTRC;
use crate::DEFAULT_OXLINTRC_NAME;

pub struct ConfigWalker {
inner: ignore::WalkParallel,
Expand Down Expand Up @@ -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
}
}

Expand Down
4 changes: 2 additions & 2 deletions apps/oxlint/src/lsp/server_linter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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));
Expand Down
4 changes: 2 additions & 2 deletions apps/oxlint/src/mode/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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;
}
Expand Down
Loading