File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ import {
3939 type StyleContextUnknownLang ,
4040 styleNodeLoc ,
4141 styleNodeRange ,
42+ styleSelectorNodeLoc ,
4243} from "./style-context.js" ;
4344import { getGlobalsForSvelte , getGlobalsForSvelteScript } from "./globals.js" ;
4445import type { NormalizedParserOptions } from "./parser-options.js" ;
@@ -251,6 +252,7 @@ function parseAsSvelte(
251252 } ,
252253 styleNodeLoc,
253254 styleNodeRange,
255+ styleSelectorNodeLoc,
254256 svelteParseContext,
255257 } ) ;
256258 resultScript . visitorKeys = Object . assign ( { } , KEYS , resultScript . visitorKeys ) ;
Original file line number Diff line number Diff line change @@ -141,6 +141,24 @@ export function styleNodeRange(
141141 ] ;
142142}
143143
144+ /**
145+ * Extracts a node location (like that of any ESLint node) from a parsed svelte selector node.
146+ */
147+ export function styleSelectorNodeLoc (
148+ node : SelectorNode ,
149+ ) : Partial < SourceLocation > {
150+ return {
151+ start :
152+ node . source ?. start !== undefined
153+ ? {
154+ line : node . source . start . line ,
155+ column : node . source . start . column - 1 ,
156+ }
157+ : undefined ,
158+ end : node . source ?. end ,
159+ } ;
160+ }
161+
144162/**
145163 * Fixes PostCSS AST locations to be relative to the whole file instead of relative to the <style> element.
146164 */
You can’t perform that action at this time.
0 commit comments