Skip to content

Commit

Permalink
Fix percent-placeholder-pattern end positions (#920)
Browse files Browse the repository at this point in the history
  • Loading branch information
ybiquitous committed Dec 13, 2023
1 parent 0dcff6c commit a05bcf2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
14 changes: 13 additions & 1 deletion src/rules/percent-placeholder-pattern/__tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ testRule({
{
code: "%floo { top: 1em; }",
line: 1,
column: 1,
endLine: 1,
endColumn: 6,
message: messages.expected("floo"),
description: "Regexp: sequence part. Example: symbol in between."
}
Expand Down Expand Up @@ -113,6 +116,9 @@ testRule({
{
code: "% foo { top: 1em; }",
line: 1,
column: 1,
endLine: 1,
endColumn: 2,
message: messages.expected(""),
description:
"Regexp: strict match. Example: matches, but has a space after '%'."
Expand Down Expand Up @@ -223,7 +229,10 @@ testRule({
a,
&1oo {}
}`,
line: 3,
line: 2,
column: 7,
endLine: 3,
endColumn: 14,
message: messages.expected("Foo-bar1oo"),
description:
"Regexp: SUIT component. Example: nesting, only lv1 part comply."
Expand All @@ -235,6 +244,9 @@ testRule({
}
}`,
line: 1,
column: 1,
endLine: 1,
endColumn: 4,
message: messages.expected("Fo"),
description:
"Regexp: pattern at the beginning. Example: nesting, with nesting selector; first lv doesn't comply."
Expand Down
4 changes: 2 additions & 2 deletions src/rules/percent-placeholder-pattern/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function rule(pattern) {
function checkSelector(fullSelector, rule) {
// postcss-selector-parser gives %placeholders' nodes a "tag" type
fullSelector.walkTags(compoundSelector => {
const { value, sourceIndex } = compoundSelector;
const { value } = compoundSelector;

if (value[0] !== "%") {
return;
Expand All @@ -87,7 +87,7 @@ function rule(pattern) {
ruleName,
message: messages.expected(placeholder),
node: rule,
index: sourceIndex
word: value
});
});
}
Expand Down

0 comments on commit a05bcf2

Please sign in to comment.