Skip to content

Commit 9236c41

Browse files
committed
Fix second variable reported location
1 parent 063819a commit 9236c41

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/rules/no-invalid-properties.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,14 @@ function replaceWithOffsets(text, varName, replaceValue) {
4242

4343
while ((match = regex.exec(text)) !== null) {
4444
result += text.slice(lastIndex, match.index);
45+
46+
/*
47+
* We need the offset of the replacement after other replacements have
48+
* been made, so we push the current length of the result before appending
49+
* the replacement value.
50+
*/
51+
offsets.push(result.length);
4552
result += replaceValue;
46-
offsets.push(match.index);
4753
lastIndex = match.index + match[0].length;
4854
}
4955

tests/rules/no-invalid-properties.test.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,5 +386,22 @@ ruleTester.run("no-invalid-properties", rule, {
386386
},
387387
],
388388
},
389+
{
390+
code: "a { --width: 1px; border-top: var(--width) solid var(--width); }",
391+
errors: [
392+
{
393+
messageId: "invalidPropertyValue",
394+
data: {
395+
property: "border-top",
396+
value: "1px",
397+
expected: "<line-width> || <line-style> || <color>",
398+
},
399+
line: 1,
400+
column: 50,
401+
endLine: 1,
402+
endColumn: 62,
403+
},
404+
],
405+
},
389406
],
390407
});

0 commit comments

Comments
 (0)