Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/sweet-poems-chew.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"eslint-plugin-vue-scoped-css": patch
---

fix: error when using ESLint v9.30.0 or later
19 changes: 17 additions & 2 deletions lib/styles/parser/selector/css-selector-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,21 @@ export class CSSSelectorParser {
): VCSSSelectorNode | null {
const { sourceCode } = this;

/**
* Get index from location
*/
function getIndexFromLoc(loc: LineAndColumnData): number {
if (loc.column >= 0) {
return sourceCode.getIndexFromLoc(loc);
}
// A column index can be negative if the starting position contains a newline.
const index = sourceCode.getIndexFromLoc({
line: loc.line,
column: 0,
});
return index + loc.column;
}

const loc = {
start: getESLintLineAndColumnFromPostCSSSelectorParserNode(
offsetLocation,
Expand All @@ -186,8 +201,8 @@ export class CSSSelectorParser {
"end",
),
};
const start = sourceCode.getIndexFromLoc(loc.start);
const end = sourceCode.getIndexFromLoc(loc.end);
const start = getIndexFromLoc(loc.start);
const end = getIndexFromLoc(loc.end);

const astNode = this[typeToConvertMethodName(node.type)](
node as never,
Expand Down
Loading
Loading