Skip to content

Commit b1c0f28

Browse files
committed
feat(language_server): send in memory source text to tsgolint
1 parent 109f452 commit b1c0f28

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
@@ -78,7 +78,7 @@ impl TsGoLintState {
7878

7979
let mut resolved_configs: FxHashMap<PathBuf, ResolvedLinterState> = FxHashMap::default();
8080

81-
let json_input = self.json_input(paths, &mut resolved_configs);
81+
let json_input = self.json_input(paths, None, &mut resolved_configs);
8282
if json_input.configs.is_empty() {
8383
return Ok(());
8484
}
@@ -294,8 +294,14 @@ impl TsGoLintState {
294294
source_text: String,
295295
) -> Result<Vec<Message>, String> {
296296
let mut resolved_configs: FxHashMap<PathBuf, ResolvedLinterState> = FxHashMap::default();
297+
let mut source_overrides = FxHashMap::default();
298+
source_overrides.insert(path.to_string_lossy().to_string(), source_text.clone());
297299

298-
let json_input = self.json_input(std::slice::from_ref(path), &mut resolved_configs);
300+
let json_input = self.json_input(
301+
std::slice::from_ref(path),
302+
Some(source_overrides),
303+
&mut resolved_configs,
304+
);
299305
let executable_path = self.executable_path.clone();
300306

301307
let handler = std::thread::spawn(move || {
@@ -426,6 +432,7 @@ impl TsGoLintState {
426432
fn json_input(
427433
&self,
428434
paths: &[Arc<OsStr>],
435+
source_overrides: Option<FxHashMap<String, String>>,
429436
resolved_configs: &mut FxHashMap<PathBuf, ResolvedLinterState>,
430437
) -> Payload {
431438
let mut config_groups: FxHashMap<BTreeSet<Rule>, Vec<String>> = FxHashMap::default();
@@ -464,6 +471,7 @@ impl TsGoLintState {
464471
rules: rules.into_iter().collect(),
465472
})
466473
.collect(),
474+
source_overrides,
467475
}
468476
}
469477
}
@@ -487,6 +495,7 @@ impl TsGoLintState {
487495
pub struct Payload {
488496
pub version: i32,
489497
pub configs: Vec<Config>,
498+
pub source_overrides: Option<FxHashMap<String, String>>,
490499
}
491500

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

0 commit comments

Comments
 (0)