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
4 changes: 2 additions & 2 deletions lib/util/attr.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ function getClassNamesFromAttribute(attrVal) {
return classNames;
}
if (isSingleLine(attrVal)) {
// Fix multiple spaces
attrVal = attrVal.replace(/\s{2,}/g, ' ');
// Fix multiple spaces + trim
attrVal = attrVal.replace(/\s{2,}/g, ' ').trim();
classNames = attrVal.split(' ');
} else {
classNames = attrVal.split('\n');
Expand Down
8 changes: 8 additions & 0 deletions tests/lib/rules/classnames-order.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ ruleTester.run("classnames-order", rule, {
{
code: `<div class='box-content lg:box-border'>Simple quotes</div>`,
},
{
code: `<div class="space-y-0.5 ">Extra space at the end</div>`,
},
{
code: `<div class="p-4 rounded sm:p-6 sm:rounded-lg lg:p-8 lg:rounded-2xl">groupByResponsive</div>`,
options: [
Expand Down Expand Up @@ -161,6 +164,11 @@ ruleTester.run("classnames-order", rule, {
output: `<div class="container w-12 sm:w-6">Classnames will be ordered</div>`,
errors: errors,
},
{
code: `<div class=" flex space-y-0.5 ">Extra spaces</div>`,
output: `<div class="flex space-y-0.5">Extra spaces</div>`,
errors: errors,
},
{
code: `<div class="sm:py-5 p-4 sm:px-7 lg:p-8">Enhancing readability</div>`,
output: `<div class="p-4 lg:p-8 sm:py-5 sm:px-7">Enhancing readability</div>`,
Expand Down