Skip to content

Commit

Permalink
Fix implementation and add a test case
Browse files Browse the repository at this point in the history
  • Loading branch information
ybiquitous committed Jul 19, 2021
1 parent 5d55e43 commit 8f66725
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
18 changes: 12 additions & 6 deletions src/rules/comment-no-empty/__tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ testRule(rule, {
},
{
code: `
/*
/*
*/
`,
description: "Empty multline block comment",
Expand All @@ -41,7 +41,7 @@ testRule(rule, {
},
{
code: `
/*
/*
*/
`,
Expand All @@ -60,7 +60,7 @@ testRule(rule, {
},
{
code: `
//
//
`,
description: "Empty double slash comment with spaces",
message: messages.rejected,
Expand All @@ -78,7 +78,7 @@ testRule(rule, {
},
{
code: `
width: 100px; //
width: 100px; //
`,
description: "Empty inline comment",
message: messages.rejected,
Expand All @@ -96,12 +96,18 @@ testRule(rule, {
},
{
code: `
/* */width: 100px;
/* */width: 100px;
`,
description: "Empty inline block comment prepends code",
message: messages.rejected,
line: 2,
column: 7
}
}
]
});

test("messages", () => {
expect(messages.rejected).toBe(
"Unexpected empty comment (scss/comment-no-empty)"
);
});
9 changes: 4 additions & 5 deletions src/rules/comment-no-empty/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ const coreRuleName = "comment-no-empty";
export const ruleName = namespace(coreRuleName);

export const messages = utils.ruleMessages(ruleName, {
rejected: (...args) => {
return rules[coreRuleName].messages
.rejected(...args)
.replace(` (${coreRuleName})`, "");
}
rejected: rules[coreRuleName].messages.rejected.replace(
` (${coreRuleName})`,
""
)
});

function rule(primary) {
Expand Down

0 comments on commit 8f66725

Please sign in to comment.