From 6c6a5fd8e1950991bca308e4dcf9abbd42cbcba3 Mon Sep 17 00:00:00 2001 From: Teddy Katz Date: Wed, 24 Oct 2018 16:30:25 -0400 Subject: [PATCH] Chore: avoid using legacy report API in no-irregular-whitespace This updates the no-irregular-whitespace rule to avoid using the legacy multi-argument `context.report` API. We have a linting rule to enforce against using the API, but the rule wasn't enforcing it in this case. This was originally found by Aladdin-ADD in https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/issues/64. --- lib/rules/no-irregular-whitespace.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/rules/no-irregular-whitespace.js b/lib/rules/no-irregular-whitespace.js index 729f829a1f71..de6934c635ac 100644 --- a/lib/rules/no-irregular-whitespace.js +++ b/lib/rules/no-irregular-whitespace.js @@ -81,9 +81,7 @@ module.exports = { const locStart = node.loc.start; const locEnd = node.loc.end; - errors = errors.filter(error => { - const errorLoc = error[1]; - + errors = errors.filter(({ loc: errorLoc }) => { if (errorLoc.line >= locStart.line && errorLoc.line <= locEnd.line) { if (errorLoc.column >= locStart.column && (errorLoc.column <= locEnd.column || errorLoc.line < locEnd.line)) { return false; @@ -157,7 +155,7 @@ module.exports = { column: match.index }; - errors.push([node, location, "Irregular whitespace not allowed."]); + errors.push({ node, message: "Irregular whitespace not allowed.", loc: location }); } }); } @@ -182,7 +180,7 @@ module.exports = { column: sourceLines[lineIndex].length }; - errors.push([node, location, "Irregular whitespace not allowed."]); + errors.push({ node, message: "Irregular whitespace not allowed.", loc: location }); lastLineIndex = lineIndex; } } @@ -224,9 +222,7 @@ module.exports = { } // If we have any errors remaining report on them - errors.forEach(error => { - context.report(...error); - }); + errors.forEach(error => context.report(error)); }; } else { nodes.Program = noop;