Skip to content

Commit

Permalink
Add endIndex to parsing error report call (#385)
Browse files Browse the repository at this point in the history
Stylelint v16.13 and up raises a deprecation warning when you report
with index but no endIndex
  • Loading branch information
BPScott authored Jan 27, 2025
1 parent 1f9feab commit 536ad1a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,17 @@ const ruleFunction = (expectation, options, context) => {
message = message.replace(/ \(\d+:\d+\)$/, '');
}

const startIndex = getIndexFromLoc(source, err.loc.start);

stylelint.utils.report({
ruleName,
result,
message,
node: root,
index: getIndexFromLoc(source, err.loc.start),
index: startIndex,
endIndex: err.loc.end
? getIndexFromLoc(source, err.loc.end)
: startIndex + 1,
});

return;
Expand Down

0 comments on commit 536ad1a

Please sign in to comment.