Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix at-rule pattern warnings to range only one line #639

Merged
merged 2 commits into from Jul 20, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
36 changes: 36 additions & 0 deletions src/rules/at-function-pattern/__tests__/index.js
Expand Up @@ -77,6 +77,9 @@ testRule({
}
`,
line: 2,
column: 7,
endLine: 3,
endColumn: 0,
message: messages.expected,
description: "Regexp: sequence part. Example: symbol in between."
}
Expand Down Expand Up @@ -120,6 +123,9 @@ testRule({
}
`,
line: 2,
column: 7,
endLine: 3,
endColumn: 0,
message: messages.expected,
description: "String: sequence part. Example: symbol in between."
},
Expand All @@ -129,6 +135,9 @@ testRule({
}
`,
line: 2,
column: 7,
endLine: 3,
endColumn: 0,
message: messages.expected,
description: "String: sequence part. Example: not a full sequence."
}
Expand Down Expand Up @@ -191,6 +200,9 @@ testRule({
}
`,
line: 2,
column: 7,
endLine: 3,
endColumn: 0,
message: messages.expected,
description: "Regexp: strict match. Example: matches at the end."
},
Expand All @@ -200,6 +212,9 @@ testRule({
}
`,
line: 2,
column: 7,
endLine: 3,
endColumn: 0,
message: messages.expected,
description: "Regexp: strict match. Example: matches at the beginning."
},
Expand All @@ -209,6 +224,9 @@ testRule({
}
`,
line: 2,
column: 7,
endLine: 3,
endColumn: 0,
message: messages.expected,
description: "Regexp: strict match. Example: symbol in between."
},
Expand All @@ -220,6 +238,9 @@ testRule({
}
`,
line: 2,
column: 7,
endLine: 3,
endColumn: 0,
message: messages.expected,
description:
"Regexp: strict match. Example: function name divided by newlines."
Expand Down Expand Up @@ -258,6 +279,9 @@ testRule({
}
`,
line: 2,
column: 7,
endLine: 3,
endColumn: 0,
message: messages.expected,
description:
"Regexp: pattern at the beginning. Example: matches at the end."
Expand All @@ -268,6 +292,9 @@ testRule({
}
`,
line: 2,
column: 7,
endLine: 3,
endColumn: 0,
message: messages.expected,
description:
"Regexp: pattern at the beginning. Example: symbol in between."
Expand Down Expand Up @@ -296,19 +323,28 @@ testRule({
{
code: "@function boo-Foo-bar ( $p) {}",
line: 1,
column: 1,
endLine: 2,
endColumn: 0,
message: messages.expected,
description:
"Regexp: SUIT component. Example: starts with lowercase, two elements"
},
{
code: "@function foo-bar ($p) {}",
line: 1,
column: 1,
endLine: 2,
endColumn: 0,
message: messages.expected,
description: "Regexp: SUIT component. Example: starts with lowercase"
},
{
code: "@function Foo-Bar ($p) {}",
line: 1,
column: 1,
endLine: 2,
endColumn: 0,
message: messages.expected,
description:
"Regexp: SUIT component. Example: element starts with uppercase"
Expand Down
7 changes: 6 additions & 1 deletion src/rules/at-function-pattern/index.js
Expand Up @@ -37,11 +37,16 @@ export default function rule(pattern) {
return;
}

const funcTopLine = Object.assign({}, decl.source.start);
funcTopLine.line += 1;
funcTopLine.column = 0;

utils.report({
message: messages.expected,
node: decl,
result,
ruleName
ruleName,
end: funcTopLine
});
});
};
Expand Down
36 changes: 36 additions & 0 deletions src/rules/at-mixin-pattern/__tests__/index.js
Expand Up @@ -75,6 +75,9 @@ testRule({
}
`,
line: 2,
column: 7,
endLine: 3,
endColumn: 0,
message: messages.expected,
description: "Regexp: sequence part. Example: symbol in between."
}
Expand Down Expand Up @@ -118,6 +121,9 @@ testRule({
}
`,
line: 2,
column: 7,
endLine: 3,
endColumn: 0,
message: messages.expected,
description: "String: sequence part. Example: symbol in between."
},
Expand All @@ -127,6 +133,9 @@ testRule({
}
`,
line: 2,
column: 7,
endLine: 3,
endColumn: 0,
message: messages.expected,
description: "String: sequence part. Example: not a full sequence."
}
Expand Down Expand Up @@ -198,6 +207,9 @@ testRule({
}
`,
line: 2,
column: 7,
endLine: 3,
endColumn: 0,
message: messages.expected,
description: "Regexp: strict match. Example: matches at the end."
},
Expand All @@ -207,6 +219,9 @@ testRule({
}
`,
line: 2,
column: 7,
endLine: 3,
endColumn: 0,
message: messages.expected,
description: "Regexp: strict match. Example: matches at the beginning."
},
Expand All @@ -216,6 +231,9 @@ testRule({
}
`,
line: 2,
column: 7,
endLine: 3,
endColumn: 0,
message: messages.expected,
description: "Regexp: strict match. Example: symbol in between."
},
Expand All @@ -227,6 +245,9 @@ testRule({
}
`,
line: 2,
column: 7,
endLine: 3,
endColumn: 0,
message: messages.expected,
description:
"Regexp: strict match. Example: mixin name divided by newlines."
Expand Down Expand Up @@ -265,6 +286,9 @@ testRule({
}
`,
line: 2,
column: 7,
endLine: 3,
endColumn: 0,
message: messages.expected,
description:
"Regexp: pattern at the beginning. Example: matches at the end."
Expand All @@ -275,6 +299,9 @@ testRule({
}
`,
line: 2,
column: 7,
endLine: 3,
endColumn: 0,
message: messages.expected,
description:
"Regexp: pattern at the beginning. Example: symbol in between."
Expand Down Expand Up @@ -303,19 +330,28 @@ testRule({
{
code: "@mixin boo-Foo-bar ( $p) {}",
line: 1,
column: 1,
endLine: 2,
endColumn: 0,
message: messages.expected,
description:
"Regexp: SUIT component. Example: starts with lowercase, two elements"
},
{
code: "@mixin foo-bar ($p) {}",
line: 1,
column: 1,
endLine: 2,
endColumn: 0,
message: messages.expected,
description: "Regexp: SUIT component. Example: starts with lowercase"
},
{
code: "@mixin Foo-Bar ($p) {}",
line: 1,
column: 1,
endLine: 2,
endColumn: 0,
message: messages.expected,
description:
"Regexp: SUIT component. Example: element starts with uppercase"
Expand Down
7 changes: 6 additions & 1 deletion src/rules/at-mixin-pattern/index.js
Expand Up @@ -37,11 +37,16 @@ export default function rule(pattern) {
return;
}

const mixinTopLine = Object.assign({}, decl.source.start);
mixinTopLine.line += 1;
mixinTopLine.column = 0;

utils.report({
message: messages.expected,
node: decl,
result,
ruleName
ruleName,
end: mixinTopLine
});
});
};
Expand Down