Skip to content

Commit

Permalink
Fix autofix for single-line comments within maps in value-keyword-case (
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-schranz authored and jeddy3 committed Apr 13, 2019
1 parent 49fa75f commit 9b76cec
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/rules/value-keyword-case/__tests__/index.js
Expand Up @@ -691,6 +691,10 @@ testRule(rule, {
code: "a { width: 1em; \n// display: BLOCK\n }",
description: "ignore unit within comments"
},
{
code: '$list: (\n key: "vAluE", // single quote comment\n );',
description: "ignore list single quote comment"
},
{
code: "a { $display: block; }"
},
Expand Down
5 changes: 4 additions & 1 deletion lib/rules/value-keyword-case/index.js
Expand Up @@ -59,6 +59,8 @@ const rule = function(expectation, options, context) {
decl.raws.value ? decl.raws.value.raw : decl.value
);

let needFix = false;

parsed.walk(node => {
const valueLowerCase = node.value.toLowerCase();

Expand Down Expand Up @@ -210,6 +212,7 @@ const rule = function(expectation, options, context) {
}

if (context.fix) {
needFix = true;
node.value = expectedKeyword;

return;
Expand All @@ -224,7 +227,7 @@ const rule = function(expectation, options, context) {
});
});

if (context.fix) {
if (context.fix && needFix) {
decl.value = parsed.toString();
}
});
Expand Down

0 comments on commit 9b76cec

Please sign in to comment.