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 <otameshiyo23@gmail.com>
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

Lines changed: 5 additions & 0 deletions
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

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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy