Skip to content

Commit 5501ed2

Browse files
committed
refactor(language_server): send in memory source text to tsgolint (#14733)
counterpart of oxc-project/tsgolint#291 the downstream PR successfully lints the in memory file: ![tsgolint-in-memory](https://github.com/user-attachments/assets/5409c5e5-bda5-44f9-bea7-6ce0a64f2502) It is just a refactoring because the `TsgoLinter` will still only be used `onSave`
1 parent e860495 commit 5501ed2

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

crates/oxc_linter/src/tsgolint.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ impl TsGoLintState {
101101

102102
let mut resolved_configs: FxHashMap<PathBuf, ResolvedLinterState> = FxHashMap::default();
103103

104-
let json_input = self.json_input(paths, &mut resolved_configs);
104+
let json_input = self.json_input(paths, None, &mut resolved_configs);
105105
if json_input.configs.is_empty() {
106106
return Ok(());
107107
}
@@ -336,8 +336,14 @@ impl TsGoLintState {
336336
source_text: String,
337337
) -> Result<Vec<Message>, String> {
338338
let mut resolved_configs: FxHashMap<PathBuf, ResolvedLinterState> = FxHashMap::default();
339+
let mut source_overrides = FxHashMap::default();
340+
source_overrides.insert(path.to_string_lossy().to_string(), source_text.clone());
339341

340-
let json_input = self.json_input(std::slice::from_ref(path), &mut resolved_configs);
342+
let json_input = self.json_input(
343+
std::slice::from_ref(path),
344+
Some(source_overrides),
345+
&mut resolved_configs,
346+
);
341347
let executable_path = self.executable_path.clone();
342348

343349
let fix = self.fix;
@@ -489,6 +495,7 @@ impl TsGoLintState {
489495
fn json_input(
490496
&self,
491497
paths: &[Arc<OsStr>],
498+
source_overrides: Option<FxHashMap<String, String>>,
492499
resolved_configs: &mut FxHashMap<PathBuf, ResolvedLinterState>,
493500
) -> Payload {
494501
let mut config_groups: FxHashMap<BTreeSet<Rule>, Vec<String>> = FxHashMap::default();
@@ -527,6 +534,7 @@ impl TsGoLintState {
527534
rules: rules.into_iter().collect(),
528535
})
529536
.collect(),
537+
source_overrides,
530538
}
531539
}
532540
}
@@ -550,6 +558,7 @@ impl TsGoLintState {
550558
pub struct Payload {
551559
pub version: i32,
552560
pub configs: Vec<Config>,
561+
pub source_overrides: Option<FxHashMap<String, String>>,
553562
}
554563

555564
#[derive(Debug, Clone, Serialize, Deserialize)]

0 commit comments

Comments
 (0)