Skip to content

Commit ef91ca5

Browse files
committed
fix(valid-compile): use compiler options if provided
1 parent 426cc10 commit ef91ca5

File tree

6 files changed

+38
-0
lines changed

6 files changed

+38
-0
lines changed

.changeset/late-waves-wonder.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'eslint-plugin-svelte': patch
3+
---
4+
5+
fix(valid-compile): use compiler options if provided

packages/eslint-plugin-svelte/src/shared/svelte-compile-warns/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ export function getSvelteCompileWarnings(context: RuleContext): SvelteCompileWar
8686
if (cache) {
8787
return cache;
8888
}
89+
8990
const result = getSvelteCompileWarningsWithoutCache(context);
9091
cacheAll.set(sourceCode.ast, result);
9192
return result;
@@ -407,6 +408,7 @@ function getWarningsFromCode(
407408
} {
408409
try {
409410
const result = compiler.compile(code, {
411+
...context.sourceCode.parserServices.svelteParseContext?.svelteConfig?.compilerOptions,
410412
generate: false,
411413
...(isCustomElement(context.sourceCode.ast) ? { customElement: true } : {})
412414
});
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"languageOptions": {
3+
"parserOptions": {
4+
"svelteConfig": {
5+
"compilerOptions": {
6+
"runes": true
7+
}
8+
}
9+
}
10+
}
11+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
- message: >-
2+
`count` is updated, but is not declared with `$state(...)`. Changing its
3+
value will not correctly trigger updates
4+
5+
https://svelte.dev/e/non_reactive_update(non_reactive_update)
6+
line: 2
7+
column: 6
8+
suggestions: null
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<script lang="ts">
2+
let count = 0;
3+
function increment() {
4+
count += 1;
5+
}
6+
</script>
7+
8+
{count}<br />
9+
<button onclick={increment} type="button">Increment</button>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"svelte": ">=5.0.0"
3+
}

0 commit comments

Comments
 (0)