Skip to content

Commit 6f3df5f

Browse files
authored
(fix) don't do any diagnostics for node_module files (#1174)
Previously, only TS diagnostics were omitted #1056
1 parent 2f56361 commit 6f3df5f

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

packages/language-server/src/plugins/PluginHost.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,20 @@ export class PluginHost implements LSProvider, OnWatchFileChanges {
7575
throw new Error('Cannot call methods on an unopened document');
7676
}
7777

78+
if (
79+
(document.getFilePath()?.includes('/node_modules/') ||
80+
document.getFilePath()?.includes('\\node_modules\\')) &&
81+
// Sapper convention: Put stuff inside node_modules below src
82+
!(
83+
document.getFilePath()?.includes('/src/node_modules/') ||
84+
document.getFilePath()?.includes('\\src\\node_modules\\')
85+
)
86+
) {
87+
// Don't return diagnostics for files inside node_modules. These are considered read-only (cannot be changed)
88+
// and in case of svelte-check they would pollute/skew the output
89+
return [];
90+
}
91+
7892
return flatten(
7993
await this.execute<Diagnostic[]>(
8094
'getDiagnostics',

packages/language-server/src/plugins/typescript/features/DiagnosticsProvider.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,6 @@ export class DiagnosticsProviderImpl implements DiagnosticsProvider {
1515
document: Document,
1616
cancellationToken?: CancellationToken
1717
): Promise<Diagnostic[]> {
18-
if (
19-
(document.getFilePath()?.includes('/node_modules/') ||
20-
document.getFilePath()?.includes('\\node_modules\\')) &&
21-
// Sapper convention: Put stuff inside node_modules below src
22-
!(
23-
document.getFilePath()?.includes('/src/node_modules/') ||
24-
document.getFilePath()?.includes('\\src\\node_modules\\')
25-
)
26-
) {
27-
// Don't return diagnostics for files inside node_modules. These are considered read-only (cannot be changed)
28-
// and in case of svelte-check they would pollute/skew the output
29-
return [];
30-
}
31-
3218
const { lang, tsDoc } = await this.getLSAndTSDoc(document);
3319

3420
if (

0 commit comments

Comments
 (0)