Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions packages/language-server/src/plugins/PluginHost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,20 @@ export class PluginHost implements LSProvider, OnWatchFileChanges {
throw new Error('Cannot call methods on an unopened document');
}

if (
(document.getFilePath()?.includes('/node_modules/') ||
document.getFilePath()?.includes('\\node_modules\\')) &&
// Sapper convention: Put stuff inside node_modules below src
!(
document.getFilePath()?.includes('/src/node_modules/') ||
document.getFilePath()?.includes('\\src\\node_modules\\')
)
) {
// Don't return diagnostics for files inside node_modules. These are considered read-only (cannot be changed)
// and in case of svelte-check they would pollute/skew the output
return [];
}

return flatten(
await this.execute<Diagnostic[]>(
'getDiagnostics',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,6 @@ export class DiagnosticsProviderImpl implements DiagnosticsProvider {
document: Document,
cancellationToken?: CancellationToken
): Promise<Diagnostic[]> {
if (
(document.getFilePath()?.includes('/node_modules/') ||
document.getFilePath()?.includes('\\node_modules\\')) &&
// Sapper convention: Put stuff inside node_modules below src
!(
document.getFilePath()?.includes('/src/node_modules/') ||
document.getFilePath()?.includes('\\src\\node_modules\\')
)
) {
// Don't return diagnostics for files inside node_modules. These are considered read-only (cannot be changed)
// and in case of svelte-check they would pollute/skew the output
return [];
}

const { lang, tsDoc } = await this.getLSAndTSDoc(document);

if (
Expand Down