Skip to content

Commit 438be64

Browse files
Only parsing styles on-demand (#358)
* Only parsing styles on-demand * Added a changeset for on-demand style parsing --------- Co-authored-by: Yosuke Ota <[email protected]>
1 parent 8b28d21 commit 438be64

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

.changeset/yellow-cats-impress.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"svelte-eslint-parser": minor
3+
---
4+
5+
only parsing styles on-demand

src/parser/index.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ export function parseForESLint(
189189
const styleElement = ast.body.find(
190190
(b): b is SvelteStyleElement => b.type === "SvelteStyleElement"
191191
);
192-
const styleContext = parseStyleContext(styleElement, ctx);
192+
let styleContext: StyleContext | null = null;
193193

194194
resultScript.ast = ast as any;
195195
resultScript.services = Object.assign(resultScript.services || {}, {
@@ -198,6 +198,9 @@ export function parseForESLint(
198198
return resultTemplate.svelteAst.html;
199199
},
200200
getStyleContext() {
201+
if (styleContext === null) {
202+
styleContext = parseStyleContext(styleElement, ctx);
203+
}
201204
return styleContext;
202205
},
203206
styleNodeLoc,

0 commit comments

Comments
 (0)