summaryrefslogtreecommitdiff
path: root/tools/eslint/lib/rules/spaced-comment.js
diff options
context:
space:
mode:
Diffstat (limited to 'tools/eslint/lib/rules/spaced-comment.js')
-rw-r--r--tools/eslint/lib/rules/spaced-comment.js20
1 files changed, 10 insertions, 10 deletions
diff --git a/tools/eslint/lib/rules/spaced-comment.js b/tools/eslint/lib/rules/spaced-comment.js
index 85abd7360e..4e418fd19f 100644
--- a/tools/eslint/lib/rules/spaced-comment.js
+++ b/tools/eslint/lib/rules/spaced-comment.js
@@ -5,6 +5,7 @@
"use strict";
const lodash = require("lodash");
+const astUtils = require("../ast-utils");
//------------------------------------------------------------------------------
// Helpers
@@ -88,8 +89,7 @@ function createExceptionsPattern(exceptions) {
pattern += exceptions.map(escapeAndRepeat).join("|");
pattern += ")";
}
-
- pattern += "(?:$|[\n\r]))";
+ pattern += `(?:$|[${Array.from(astUtils.LINEBREAKS).join("")}]))`;
}
return pattern;
@@ -279,10 +279,10 @@ module.exports = {
end += match[0].length;
}
return fixer.insertTextAfterRange([start, end], " ");
- } else {
- end += match[0].length;
- return fixer.replaceTextRange([start, end], commentIdentifier + (match[1] ? match[1] : ""));
}
+ end += match[0].length;
+ return fixer.replaceTextRange([start, end], commentIdentifier + (match[1] ? match[1] : ""));
+
},
message,
data: { refChar }
@@ -302,12 +302,12 @@ module.exports = {
fix(fixer) {
if (requireSpace) {
return fixer.insertTextAfterRange([node.start, node.end - 2], " ");
- } else {
- const end = node.end - 2,
- start = end - match[0].length;
-
- return fixer.replaceTextRange([start, end], "");
}
+ const end = node.end - 2,
+ start = end - match[0].length;
+
+ return fixer.replaceTextRange([start, end], "");
+
},
message
});