File tree Expand file tree Collapse file tree 4 files changed +396
-210
lines changed
lib/styles/parser/selector Expand file tree Collapse file tree 4 files changed +396
-210
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " eslint-plugin-vue-scoped-css " : patch
3+ ---
4+
5+ fix: error when using ESLint v9.30.0 or later
Original file line number Diff line number Diff line change @@ -174,6 +174,21 @@ export class CSSSelectorParser {
174174 ) : VCSSSelectorNode | null {
175175 const { sourceCode } = this ;
176176
177+ /**
178+ * Get index from location
179+ */
180+ function getIndexFromLoc ( loc : LineAndColumnData ) : number {
181+ if ( loc . column >= 0 ) {
182+ return sourceCode . getIndexFromLoc ( loc ) ;
183+ }
184+ // A column index can be negative if the starting position contains a newline.
185+ const index = sourceCode . getIndexFromLoc ( {
186+ line : loc . line ,
187+ column : 0 ,
188+ } ) ;
189+ return index + loc . column ;
190+ }
191+
177192 const loc = {
178193 start : getESLintLineAndColumnFromPostCSSSelectorParserNode (
179194 offsetLocation ,
@@ -186,8 +201,8 @@ export class CSSSelectorParser {
186201 "end" ,
187202 ) ,
188203 } ;
189- const start = sourceCode . getIndexFromLoc ( loc . start ) ;
190- const end = sourceCode . getIndexFromLoc ( loc . end ) ;
204+ const start = getIndexFromLoc ( loc . start ) ;
205+ const end = getIndexFromLoc ( loc . end ) ;
191206
192207 const astNode = this [ typeToConvertMethodName ( node . type ) ] (
193208 node as never ,
You can’t perform that action at this time.
0 commit comments