Skip to content

Commit

Permalink
(fix) skip parser error when there's likely another preprocessor invo…
Browse files Browse the repository at this point in the history
…lved

sveltejs#1259
sveltejs#1479
sveltejs#1558

This may give false negatives for people who do not use Vite/forgot to create a svelte.config.js when they use rollup or webpack, but that's likely OK since we can think about these diagnostics as being opt-in: you add a preprocessor config when you want the Svelte warnings, too. Most people who have this problem also likely use TypeScript or a CSS preprocessor. When using TS, errors are caught through the TS intellisense. When using a CSS preprocessor, the only warning they'll miss is the unused CSS warning, which is apparent anyway since those styles are not visible in the browser.
  • Loading branch information
dummdidumm committed Jul 26, 2022
1 parent 2b5d321 commit 28ea7e8
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,13 @@ async function createParserErrorDiagnostic(error: any, document: Document) {
document.scriptInfo || document.moduleScriptInfo
);

if (!document.config?.preprocess && document.getText().includes('lang="')) {
Logger.error(
`Parsing ${document.getFilePath()} failed. No preprocess config found but lang tag exists. Skip showing error because they likely use other preprocessors.`
);
return [];
}

if (isInStyle || isInScript) {
diagnostic.message +=
'\n\nIf you expect this syntax to work, here are some suggestions: ';
Expand Down

0 comments on commit 28ea7e8

Please sign in to comment.