Skip to content

Commit ecd3fb5

Browse files
committed
feat(language_server): send in memory source text to tsgolint
1 parent ace4def commit ecd3fb5

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;
@@ -486,6 +492,7 @@ impl TsGoLintState {
486492
fn json_input(
487493
&self,
488494
paths: &[Arc<OsStr>],
495+
source_overrides: Option<FxHashMap<String, String>>,
489496
resolved_configs: &mut FxHashMap<PathBuf, ResolvedLinterState>,
490497
) -> Payload {
491498
let mut config_groups: FxHashMap<BTreeSet<Rule>, Vec<String>> = FxHashMap::default();
@@ -524,6 +531,7 @@ impl TsGoLintState {
524531
rules: rules.into_iter().collect(),
525532
})
526533
.collect(),
534+
source_overrides,
527535
}
528536
}
529537
}
@@ -547,6 +555,7 @@ impl TsGoLintState {
547555
pub struct Payload {
548556
pub version: i32,
549557
pub configs: Vec<Config>,
558+
pub source_overrides: Option<FxHashMap<String, String>>,
550559
}
551560

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

0 commit comments

Comments
 (0)