Skip to content

Commit 340b35b

Browse files
committed
Fixed error
1 parent 7be0416 commit 340b35b

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

lib/styles/parser/css-parser.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -136,27 +136,27 @@ export class CSSParser {
136136
parent?: VCSSContainerNode,
137137
): VCSSNode | null {
138138
const { sourceCode } = this
139-
const loc: SourceLocation = {
140-
start: getESLintLineAndColumnFromPostCSSNode(
141-
offsetLocation,
142-
node,
143-
"start",
144-
) || { line: 0, column: 1 },
145-
end: getESLintLineAndColumnFromPostCSSNode(
139+
const startLoc = getESLintLineAndColumnFromPostCSSNode(
140+
offsetLocation,
141+
node,
142+
"start",
143+
) || { line: 0, column: 1 }
144+
const start = sourceCode.getIndexFromLoc(startLoc)
145+
const endLoc =
146+
getESLintLineAndColumnFromPostCSSNode(
146147
offsetLocation,
147148
node,
148149
"end",
149-
) || { line: 0, column: 1 },
150-
}
151-
152-
const start = sourceCode.getIndexFromLoc(loc.start)
153-
if (!loc.end) {
150+
) ||
154151
// for node type: `root`
155-
loc.end = sourceCode.getLocFromIndex(
152+
sourceCode.getLocFromIndex(
156153
start + (node as PostCSSRoot).source.input.css.length,
157154
)
155+
const end = sourceCode.getIndexFromLoc(endLoc)
156+
const loc: SourceLocation = {
157+
start: startLoc,
158+
end: endLoc,
158159
}
159-
const end = sourceCode.getIndexFromLoc(loc.end)
160160

161161
const astNode = this[typeToConvertMethodName(node.type)](
162162
node as any,

0 commit comments

Comments
 (0)