Skip to content

Commit 8b13c92

Browse files
committed
Only parsing styles on-demand
1 parent d42120a commit 8b13c92

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/parser/index.ts

Lines changed: 4 additions & 1 deletion
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)