Skip to content

Commit

Permalink
(fix) don't diagnose node_module files
Browse files Browse the repository at this point in the history
node_modules are considered read-only and unchangeable, so they should not be diagnosed. Make an exception for src/node_modules as this is a Sapper convention
sveltejs#1056, sveltejs#1100
  • Loading branch information
Simon Holthausen committed Jul 17, 2021
1 parent 6e0396c commit 5f43c51
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,20 @@ 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
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ export function createSvelteModuleLoader(

const resolvedSvelteModule: ts.ResolvedModuleFull = {
extension: getExtensionFromScriptKind(snapshot && snapshot.scriptKind),
resolvedFileName
resolvedFileName,
isExternalLibraryImport: svelteResolvedModule.isExternalLibraryImport
};
return resolvedSvelteModule;
}
Expand Down

0 comments on commit 5f43c51

Please sign in to comment.