diff --git a/lib/formatters/stringFormatter.js b/lib/formatters/stringFormatter.js index 0ae0cdbd48..58493df198 100644 --- a/lib/formatters/stringFormatter.js +++ b/lib/formatters/stringFormatter.js @@ -195,9 +195,7 @@ module.exports = function (results) { output += deprecationsFormatter(results); - // TODO: Issue #4985 - // eslint-disable-next-line no-shadow - output = results.reduce((output, result) => { + output = results.reduce((accum, result) => { // Treat parseErrors as warnings if (result.parseErrors) { result.parseErrors.forEach((error) => @@ -211,9 +209,9 @@ module.exports = function (results) { ); } - output += formatter(result.warnings, result.source || ''); + accum += formatter(result.warnings, result.source || ''); - return output; + return accum; }, output); // Ensure consistent padding diff --git a/lib/rules/comment-whitespace-inside/index.js b/lib/rules/comment-whitespace-inside/index.js index 059540ed67..7d5b77ec82 100755 --- a/lib/rules/comment-whitespace-inside/index.js +++ b/lib/rules/comment-whitespace-inside/index.js @@ -18,6 +18,22 @@ const messages = ruleMessages(ruleName, { rejectedClosing: 'Unexpected whitespace before "*/"', }); +function addWhitespaceBefore(comment) { + if (comment.text.startsWith('*')) { + comment.text = comment.text.replace(/^(\*+)/, `$1 `); + } else { + comment.raws.left = ' '; + } +} + +function addWhitespaceAfter(comment) { + if (_.last(comment.text) === '*') { + comment.text = comment.text.replace(/(\*+)$/, ` $1`); + } else { + comment.raws.right = ' '; + } +} + function rule(expectation, options, context) { return function (root, result) { const validOptions = validateOptions(result, ruleName, { @@ -65,26 +81,6 @@ function rule(expectation, options, context) { complain(messages.expectedClosing, comment.toString().length - closer.length - 1); } - // TODO: Issue #4985 - // eslint-disable-next-line no-shadow - function addWhitespaceBefore(comment) { - if (comment.text.startsWith('*')) { - comment.text = comment.text.replace(/^(\*+)/, `$1 `); - } else { - comment.raws.left = ' '; - } - } - - // TODO: Issue #4985 - // eslint-disable-next-line no-shadow - function addWhitespaceAfter(comment) { - if (_.last(comment.text) === '*') { - comment.text = comment.text.replace(/(\*+)$/, ` $1`); - } else { - comment.raws.right = ' '; - } - } - function complain(message, index) { if (context.fix) { if (expectation === 'never') { diff --git a/lib/rules/declaration-bang-space-before/index.js b/lib/rules/declaration-bang-space-before/index.js index dc981427ca..0ecbb09680 100644 --- a/lib/rules/declaration-bang-space-before/index.js +++ b/lib/rules/declaration-bang-space-before/index.js @@ -42,22 +42,18 @@ function rule(expectation, options, context) { if (bangIndex < value.length) { target = value; - // TODO: Issue #4985 - // eslint-disable-next-line no-shadow - setFixed = (value) => { + setFixed = (val) => { if (decl.raws.value) { - decl.raws.value.raw = value; + decl.raws.value.raw = val; } else { - decl.value = value; + decl.value = val; } }; } else if (decl.important) { target = decl.raws.important || ' !important'; bangIndex -= value.length; - // TODO: Issue #4985 - // eslint-disable-next-line no-shadow - setFixed = (value) => { - decl.raws.important = value; + setFixed = (val) => { + decl.raws.important = val; }; } else { return false; // not standard diff --git a/lib/rules/max-line-length/index.js b/lib/rules/max-line-length/index.js index 65342c6ecb..87a42c7f0e 100644 --- a/lib/rules/max-line-length/index.js +++ b/lib/rules/max-line-length/index.js @@ -72,15 +72,13 @@ function rule(maxLength, options, context) { checkNewline(rootString, match, root), ); - // TODO: Issue #4985 - // eslint-disable-next-line no-shadow - function complain(index, root) { + function complain(index, rootNode) { report({ index, result, ruleName, message: messages.expected(maxLength), - node: root, + node: rootNode, }); } diff --git a/lib/rules/no-eol-whitespace/index.js b/lib/rules/no-eol-whitespace/index.js index 054004f9c7..82674243ee 100644 --- a/lib/rules/no-eol-whitespace/index.js +++ b/lib/rules/no-eol-whitespace/index.js @@ -131,12 +131,10 @@ function rule(on, options, context) { ); } - // TODO: Issue #4985 - // eslint-disable-next-line no-shadow - function fix(root) { + function fix(rootNode) { let isRootFirst = true; - root.walk((node) => { + rootNode.walk((node) => { fixText( node.raws.before, (fixed) => { @@ -211,22 +209,23 @@ function rule(on, options, context) { }); fixText( - root.raws.after, + rootNode.raws.after, (fixed) => { - root.raws.after = fixed; + rootNode.raws.after = fixed; }, isRootFirst, ); - if (typeof root.raws.after === 'string') { + if (typeof rootNode.raws.after === 'string') { const lastEOL = Math.max( - root.raws.after.lastIndexOf('\n'), - root.raws.after.lastIndexOf('\r'), + rootNode.raws.after.lastIndexOf('\n'), + rootNode.raws.after.lastIndexOf('\r'), ); - if (lastEOL !== root.raws.after.length - 1) { - root.raws.after = - root.raws.after.slice(0, lastEOL + 1) + fixString(root.raws.after.slice(lastEOL + 1)); + if (lastEOL !== rootNode.raws.after.length - 1) { + rootNode.raws.after = + rootNode.raws.after.slice(0, lastEOL + 1) + + fixString(rootNode.raws.after.slice(lastEOL + 1)); } } }