Skip to content

Commit

Permalink
(fix) don't do any diagnostics for node_module files (#1174)
Browse files Browse the repository at this point in the history
Previously, only TS diagnostics were omitted
#1056
  • Loading branch information
dummdidumm committed Sep 13, 2021
1 parent 2f56361 commit 6f3df5f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
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

0 comments on commit 6f3df5f

Please sign in to comment.