Skip to content

Commit d5b29f0

Browse files
authored
(feat) throw error on invalid tsconfig includes/excludes and on unknown options (#1974)
#1952 #1951
1 parent 622c02e commit d5b29f0

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

packages/language-server/src/plugins/typescript/service.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424
export interface LanguageServiceContainer {
2525
readonly tsconfigPath: string;
2626
readonly compilerOptions: ts.CompilerOptions;
27+
readonly configErrors: ts.Diagnostic[];
2728
/**
2829
* @internal Public for tests only
2930
*/
@@ -167,6 +168,7 @@ async function createLanguageService(
167168

168169
const {
169170
options: compilerOptions,
171+
errors: configErrors,
170172
fileNames: files,
171173
raw,
172174
extendedConfigPaths
@@ -247,6 +249,7 @@ async function createLanguageService(
247249
return {
248250
tsconfigPath,
249251
compilerOptions,
252+
configErrors,
250253
getService: () => languageService,
251254
updateSnapshot,
252255
deleteSnapshot,

packages/language-server/src/svelte-check.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,12 @@ export class SvelteCheck {
181181

182182
private async getDiagnosticsForTsconfig(tsconfigPath: string) {
183183
const lsContainer = await this.getLSContainer(tsconfigPath);
184+
185+
const noInputsFoundError = lsContainer.configErrors?.find((e) => e.code === 18003);
186+
if (noInputsFoundError) {
187+
throw new Error(noInputsFoundError.messageText.toString());
188+
}
189+
184190
const lang = lsContainer.getService();
185191
const files = lang.getProgram()?.getSourceFiles() || [];
186192
const options = lang.getProgram()?.getCompilerOptions() || {};

packages/svelte-check/src/options.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ export function parseOptions(cb: (opts: SvelteCheckCliOptions) => any) {
8181
});
8282
});
8383

84-
prog.parse(process.argv);
84+
prog.parse(process.argv, {
85+
unknown: (arg) => `Unknown option ${arg}`
86+
});
8587
}
8688

8789
const outputFormats = ['human', 'human-verbose', 'machine'] as const;

packages/svelte-check/src/writers.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,13 @@ export class HumanFriendlyWriter implements Writer {
112112
const message = [
113113
'svelte-check found ',
114114
`${errorCount} ${errorCount === 1 ? 'error' : 'errors'} and `,
115-
`${warningCount} ${warningCount === 1 ? 'warning' : 'warnings'} in `,
116-
`${fileCountWithProblems} ${fileCountWithProblems === 1 ? 'file' : 'files'}\n`
115+
`${warningCount} ${warningCount === 1 ? 'warning' : 'warnings'}`,
116+
`${
117+
fileCountWithProblems
118+
? // prettier-ignore
119+
` in ${fileCountWithProblems} ${fileCountWithProblems === 1 ? 'file' : 'files'}`
120+
: ''
121+
}\n`
117122
].join('');
118123
if (errorCount !== 0) {
119124
this.stream.write(pc.red(message));

0 commit comments

Comments
 (0)