Skip to content

Commit 3a706a7

Browse files
committed
refactor(linter): rename LintRunner to CliRunner (#14050)
This commit renames `LintRunner` to `CliRunner` . This change is being made in preparation for introducing a new `LintRunner` component in the future. In future, `LintRunner`​ (living in `oxc_linter`​) will handle the tsgolint/oxlint coordination (and state storage between the two phases)
1 parent 1521a1f commit 3a706a7

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

apps/oxlint/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ mod tester;
1212

1313
/// Re-exported CLI-related items for use in `tasks/website`.
1414
pub mod cli {
15-
pub use super::{command::*, lint::LintRunner, result::CliRunResult};
15+
pub use super::{command::*, lint::CliRunner, result::CliRunResult};
1616
}
1717

1818
// Only include code to run linter when the `napi` feature is enabled.

apps/oxlint/src/lint.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ use crate::{
2828
use oxc_linter::LintIgnoreMatcher;
2929

3030
#[derive(Debug)]
31-
pub struct LintRunner {
31+
pub struct CliRunner {
3232
options: LintCommand,
3333
cwd: PathBuf,
3434
external_linter: Option<ExternalLinter>,
3535
}
3636

37-
impl LintRunner {
37+
impl CliRunner {
3838
pub(crate) fn new(options: LintCommand, external_linter: Option<ExternalLinter>) -> Self {
3939
Self {
4040
options,
@@ -411,7 +411,7 @@ impl LintRunner {
411411
}
412412
}
413413

414-
impl LintRunner {
414+
impl CliRunner {
415415
const DEFAULT_OXLINTRC: &'static str = ".oxlintrc.json";
416416

417417
#[must_use]
@@ -618,7 +618,7 @@ fn render_report(handler: &GraphicalReportHandler, diagnostic: &OxcDiagnostic) -
618618
mod test {
619619
use std::{fs, path::PathBuf};
620620

621-
use super::LintRunner;
621+
use super::CliRunner;
622622
use crate::tester::Tester;
623623

624624
// lints the full directory of fixtures,
@@ -988,14 +988,14 @@ mod test {
988988

989989
#[test]
990990
fn test_init_config() {
991-
assert!(!fs::exists(LintRunner::DEFAULT_OXLINTRC).unwrap());
991+
assert!(!fs::exists(CliRunner::DEFAULT_OXLINTRC).unwrap());
992992

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

996-
assert!(fs::exists(LintRunner::DEFAULT_OXLINTRC).unwrap());
996+
assert!(fs::exists(CliRunner::DEFAULT_OXLINTRC).unwrap());
997997

998-
fs::remove_file(LintRunner::DEFAULT_OXLINTRC).unwrap();
998+
fs::remove_file(CliRunner::DEFAULT_OXLINTRC).unwrap();
999999
}
10001000

10011001
#[test]
@@ -1190,17 +1190,17 @@ mod test {
11901190

11911191
// Test case 1: Invalid path that should fail
11921192
let invalid_config = PathBuf::from("child/../../fixtures/linter/eslintrc.json");
1193-
let result = LintRunner::find_oxlint_config(&cwd, Some(&invalid_config));
1193+
let result = CliRunner::find_oxlint_config(&cwd, Some(&invalid_config));
11941194
assert!(result.is_err(), "Expected config lookup to fail with invalid path");
11951195

11961196
// Test case 2: Valid path that should pass
11971197
let valid_config = PathBuf::from("fixtures/linter/eslintrc.json");
1198-
let result = LintRunner::find_oxlint_config(&cwd, Some(&valid_config));
1198+
let result = CliRunner::find_oxlint_config(&cwd, Some(&valid_config));
11991199
assert!(result.is_ok(), "Expected config lookup to succeed with valid path");
12001200

12011201
// Test case 3: Valid path using parent directory (..) syntax that should pass
12021202
let valid_parent_config = PathBuf::from("fixtures/linter/../linter/eslintrc.json");
1203-
let result = LintRunner::find_oxlint_config(&cwd, Some(&valid_parent_config));
1203+
let result = CliRunner::find_oxlint_config(&cwd, Some(&valid_parent_config));
12041204
assert!(result.is_ok(), "Expected config lookup to succeed with parent directory syntax");
12051205

12061206
// Verify the resolved path is correct

apps/oxlint/src/run.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use napi::{
1010
};
1111
use napi_derive::napi;
1212

13-
use crate::{lint::LintRunner, result::CliRunResult};
13+
use crate::{lint::CliRunner, result::CliRunResult};
1414

1515
/// JS callback to load a JS plugin.
1616
#[napi]
@@ -113,7 +113,7 @@ fn lint_impl(load_plugin: JsLoadPluginCb, lint_file: JsLintFileCb) -> CliRunResu
113113
// See `https://github.com/rust-lang/rust/issues/60673`.
114114
let mut stdout = BufWriter::new(std::io::stdout());
115115

116-
LintRunner::new(command, external_linter).run(&mut stdout)
116+
CliRunner::new(command, external_linter).run(&mut stdout)
117117
}
118118

119119
/// Initialize the data which relies on `is_atty` system calls so they don't block subsequent threads.

apps/oxlint/src/tester.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::{env, path::PathBuf};
33
use cow_utils::CowUtils;
44
use lazy_regex::Regex;
55

6-
use crate::cli::{LintRunner, lint_command};
6+
use crate::cli::{CliRunner, lint_command};
77

88
pub struct Tester {
99
cwd: PathBuf,
@@ -32,7 +32,7 @@ impl Tester {
3232

3333
let options = lint_command().run_inner(new_args.as_slice()).unwrap();
3434
let mut output = Vec::new();
35-
let _ = LintRunner::new(options, None).with_cwd(self.cwd.clone()).run(&mut output);
35+
let _ = CliRunner::new(options, None).with_cwd(self.cwd.clone()).run(&mut output);
3636
}
3737

3838
pub fn test_fix(file: &str, before: &str, after: &str) {
@@ -78,7 +78,7 @@ impl Tester {
7878
format!("working directory: {}\n", relative_dir.to_str().unwrap()).as_bytes(),
7979
);
8080
output.extend_from_slice(b"----------\n");
81-
let result = LintRunner::new(options, None).with_cwd(self.cwd.clone()).run(&mut output);
81+
let result = CliRunner::new(options, None).with_cwd(self.cwd.clone()).run(&mut output);
8282

8383
output.extend_from_slice(b"----------\n");
8484
output.extend_from_slice(format!("CLI result: {result:?}\n").as_bytes());

0 commit comments

Comments
 (0)