diff --git a/packages/language-server/src/plugins/typescript/features/DiagnosticsProvider.ts b/packages/language-server/src/plugins/typescript/features/DiagnosticsProvider.ts index f0334143d..4f7e7dfc2 100644 --- a/packages/language-server/src/plugins/typescript/features/DiagnosticsProvider.ts +++ b/packages/language-server/src/plugins/typescript/features/DiagnosticsProvider.ts @@ -15,6 +15,20 @@ export class DiagnosticsProviderImpl implements DiagnosticsProvider { document: Document, cancellationToken?: CancellationToken ): Promise { + 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 ( diff --git a/packages/language-server/src/plugins/typescript/module-loader.ts b/packages/language-server/src/plugins/typescript/module-loader.ts index 2801d59f1..b023318b1 100644 --- a/packages/language-server/src/plugins/typescript/module-loader.ts +++ b/packages/language-server/src/plugins/typescript/module-loader.ts @@ -146,7 +146,8 @@ export function createSvelteModuleLoader( const resolvedSvelteModule: ts.ResolvedModuleFull = { extension: getExtensionFromScriptKind(snapshot && snapshot.scriptKind), - resolvedFileName + resolvedFileName, + isExternalLibraryImport: svelteResolvedModule.isExternalLibraryImport }; return resolvedSvelteModule; } diff --git a/packages/language-server/test/plugins/typescript/module-loader.test.ts b/packages/language-server/test/plugins/typescript/module-loader.test.ts index 5f1cd5bed..51fe58f2c 100644 --- a/packages/language-server/test/plugins/typescript/module-loader.test.ts +++ b/packages/language-server/test/plugins/typescript/module-loader.test.ts @@ -114,7 +114,8 @@ describe('createSvelteModuleLoader', () => { assert.deepStrictEqual(result, [ { extension: ts.Extension.Jsx, - resolvedFileName: 'filename.svelte' + resolvedFileName: 'filename.svelte', + isExternalLibraryImport: undefined } ]); assert.deepStrictEqual(lastCall(resolveStub).args, [ @@ -141,7 +142,8 @@ describe('createSvelteModuleLoader', () => { assert.deepStrictEqual(result, [ { extension: ts.Extension.Jsx, - resolvedFileName: 'filename.svelte' + resolvedFileName: 'filename.svelte', + isExternalLibraryImport: undefined } ]); assert.deepStrictEqual(lastCall(resolveStub).args, [ diff --git a/packages/svelte-check/README.md b/packages/svelte-check/README.md index caafd31ca..7fb518536 100644 --- a/packages/svelte-check/README.md +++ b/packages/svelte-check/README.md @@ -56,7 +56,7 @@ Usage: | `--output ` | | `--watch` | Will not exit after one pass but keep watching files for changes and rerun diagnostics | | `--tsconfig ` | Pass a path to a tsconfig or jsconfig file. The path can be relative to the workspace path or absolute. Doing this means that only files matched by the files/include/exclude pattern of the config file are diagnosed. It also means that errors from TypeScript and JavaScript files are reported. | -| `--ignore ` | Files/folders to ignore - relative to workspace root, comma-separated, inside quotes. Example: `--ignore "dist,build"`. When used in conjunction with `--tsconfig`, this will only have effect on the files watched, not on the files that are diagnosed, which is then determined by the `tsconfig.json` | +| `--ignore ` | Files/folders to ignore - relative to workspace root, comma-separated, inside quotes. Example: `--ignore "dist,build"`. When used in conjunction with `--tsconfig`, this will only have effect on the files watched, not on the files that are diagnosed, which is then determined by the `tsconfig.json` | | `--fail-on-warnings` | Will also exit with error code when there are warnings | | `--fail-on-hints` | Will also exit with error code when there are hints | | `--compiler-warnings ` | A list of Svelte compiler warning codes. Each entry defines whether that warning should be ignored or treated as an error. Warnings are comma-separated, between warning code and error level is a colon; all inside quotes. Example: `--compiler-warnings "css-unused-selector:ignore,unused-export-let:error"` |