Skip to content

Commit 353bfe7

Browse files
committed
fix(language_server): check if tsconfig path is a file before starting the LintService (#14126)
`with_tsconfig()` has a debug assertion that the path is a file. This was missing on the language server side and did silently fail on the VSCode tests. https://github.com/oxc-project/oxc/blob/1337811da61a7b30b7a41292b6ad449ee6a168bb/crates/oxc_linter/src/service/mod.rs#L34-L45 <img width="1533" height="341" alt="screenshot of the test panic" src="https://github.com/user-attachments/assets/4cdb6391-9160-4642-a9c3-e196d8712f12" />
1 parent 0029b7f commit 353bfe7

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

crates/oxc_language_server/src/linter/isolated_lint_handler.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,10 @@ impl IsolatedLintHandler {
7272
let mut lint_service_options = LintServiceOptions::new(options.root_path.clone())
7373
.with_cross_module(options.use_cross_module);
7474

75-
if let Some(tsconfig_path) = &options.tsconfig_path {
75+
if let Some(tsconfig_path) = &options.tsconfig_path
76+
&& tsconfig_path.is_file()
77+
{
78+
debug_assert!(tsconfig_path.is_absolute());
7679
lint_service_options = lint_service_options.with_tsconfig(tsconfig_path);
7780
}
7881

crates/oxc_language_server/src/linter/server_linter.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,10 @@ impl ServerLinter {
156156
&IsolatedLintHandlerOptions {
157157
use_cross_module,
158158
root_path: root_path.to_path_buf(),
159-
tsconfig_path: options
160-
.ts_config_path
161-
.as_ref()
162-
.map(|path| Path::new(path).to_path_buf()),
159+
tsconfig_path: options.ts_config_path.as_ref().map(|path| {
160+
let path = Path::new(path).to_path_buf();
161+
if path.is_relative() { root_path.join(path) } else { path }
162+
}),
163163
},
164164
);
165165

0 commit comments

Comments
 (0)