summaryrefslogtreecommitdiff
path: root/tools/eslint/lib/rules/no-multiple-empty-lines.js
diff options
context:
space:
mode:
authorRich Trott <rtrott@gmail.com>2016-08-13 15:06:43 -0700
committerEvan Lucas <evanlucas@me.com>2016-08-20 10:00:31 -0500
commitcdcf23ab7f111c4ae531192d2eaa6045778965bc (patch)
tree5782d53c16ead52396b58826afe340448fb6ca6b /tools/eslint/lib/rules/no-multiple-empty-lines.js
parentbe41f584f3e6a5b7ec342984dc5152717b6eb600 (diff)
downloadnode-new-cdcf23ab7f111c4ae531192d2eaa6045778965bc.tar.gz
tools: update ESLint to 3.3.0 and enable rules
Update ESLint 3.3.0 and update .eslintrc: * replace deprecated no-negated-in-lhs rule with no-unsafe-negation * http://eslint.org/docs/rules/no-negated-in-lhs * http://eslint.org/docs/rules/no-unsafe-negation * enable no-template-curly-in-string * http://eslint.org/docs/rules/no-template-curly-in-string * enable no-global-assign * http://eslint.org/docs/rules/no-global-assign * enable func-call-spacing * http://eslint.org/docs/rules/func-call-spacing PR-URL: https://github.com/nodejs/node/pull/8097 Reviewed-By: targos - Michaƫl Zasso <mic.besace@gmail.com> Reviewed-By: jasnell - James M Snell <jasnell@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io>
Diffstat (limited to 'tools/eslint/lib/rules/no-multiple-empty-lines.js')
-rw-r--r--tools/eslint/lib/rules/no-multiple-empty-lines.js27
1 files changed, 15 insertions, 12 deletions
diff --git a/tools/eslint/lib/rules/no-multiple-empty-lines.js b/tools/eslint/lib/rules/no-multiple-empty-lines.js
index cede2d5e78..7b8c73d0ac 100644
--- a/tools/eslint/lib/rules/no-multiple-empty-lines.js
+++ b/tools/eslint/lib/rules/no-multiple-empty-lines.js
@@ -50,7 +50,7 @@ module.exports = {
maxBOF;
// store lines that appear empty but really aren't
- let notEmpty = [];
+ const notEmpty = [];
if (context.options.length) {
max = context.options[0].max;
@@ -58,7 +58,7 @@ module.exports = {
maxBOF = typeof context.options[0].maxBOF !== "undefined" ? context.options[0].maxBOF : max;
}
- let sourceCode = context.getSourceCode();
+ const sourceCode = context.getSourceCode();
//--------------------------------------------------------------------------
// Public
@@ -68,7 +68,7 @@ module.exports = {
TemplateLiteral: function(node) {
let start = node.loc.start.line;
- let end = node.loc.end.line;
+ const end = node.loc.end.line;
while (start <= end) {
notEmpty.push(start);
@@ -77,28 +77,31 @@ module.exports = {
},
"Program:exit": function checkBlankLines(node) {
- let lines = sourceCode.lines,
+ const lines = sourceCode.lines,
fullLines = sourceCode.text.match(/.*(\r\n|\r|\n|\u2028|\u2029)/g) || [],
- firstNonBlankLine = -1,
+ linesRangeStart = [];
+ let firstNonBlankLine = -1,
trimmedLines = [],
- linesRangeStart = [],
blankCounter = 0,
currentLocation,
lastLocation,
- location,
firstOfEndingBlankLines,
diff,
- fix,
rangeStart,
rangeEnd;
- fix = function(fixer) {
+ /**
+ * Fix code.
+ * @param {RuleFixer} fixer - The fixer of this context.
+ * @returns {Object} The fixing information.
+ */
+ function fix(fixer) {
return fixer.removeRange([rangeStart, rangeEnd]);
- };
+ }
linesRangeStart.push(0);
lines.forEach(function(str, i) {
- let length = i < fullLines.length ? fullLines[i].length : 0,
+ const length = i < fullLines.length ? fullLines[i].length : 0,
trimmed = str.trim();
if ((firstNonBlankLine === -1) && (trimmed !== "")) {
@@ -157,7 +160,7 @@ module.exports = {
if (lastLocation === currentLocation - 1) {
blankCounter++;
} else {
- location = {
+ const location = {
line: lastLocation + 1,
column: 1
};