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
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
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ describe('createSvelteModuleLoader', () => {
assert.deepStrictEqual(result, [
<ts.ResolvedModuleFull>{
extension: ts.Extension.Jsx,
resolvedFileName: 'filename.svelte'
resolvedFileName: 'filename.svelte',
isExternalLibraryImport: undefined
}
]);
assert.deepStrictEqual(lastCall(resolveStub).args, [
Expand All @@ -141,7 +142,8 @@ describe('createSvelteModuleLoader', () => {
assert.deepStrictEqual(result, [
<ts.ResolvedModuleFull>{
extension: ts.Extension.Jsx,
resolvedFileName: 'filename.svelte'
resolvedFileName: 'filename.svelte',
isExternalLibraryImport: undefined
}
]);
assert.deepStrictEqual(lastCall(resolveStub).args, [
Expand Down
2 changes: 1 addition & 1 deletion packages/svelte-check/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Usage:
| `--output <human\|human-verbose\|machine>` |
| `--watch` | Will not exit after one pass but keep watching files for changes and rerun diagnostics |
| `--tsconfig <path>` | 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 <path1,path2>` | 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 <path1,path2>` | 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 <code1:error\|ignore,code2:error\|ignore>` | 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"` |
Expand Down