From 44661b53a3b835510be2b78fb99d4b902f04e566 Mon Sep 17 00:00:00 2001 From: Mikhail Bodrov Date: Fri, 21 May 2021 03:29:35 +0300 Subject: [PATCH] Chore: use includes instead of indexOf --- lib/rules/callback-return.js | 4 ++-- lib/rules/comma-spacing.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/rules/callback-return.js b/lib/rules/callback-return.js index fa66e6383b7c..4d7bf2aa10e9 100644 --- a/lib/rules/callback-return.js +++ b/lib/rules/callback-return.js @@ -52,7 +52,7 @@ module.exports = { if (!node.parent) { return null; } - if (types.indexOf(node.parent.type) === -1) { + if (!types.includes(node.parent.type)) { return findClosestParentOfType(node.parent, types); } return node.parent; @@ -86,7 +86,7 @@ module.exports = { * @returns {boolean} Whether or not this function matches our callback name. */ function isCallback(node) { - return containsOnlyIdentifiers(node.callee) && callbacks.indexOf(sourceCode.getText(node.callee)) > -1; + return containsOnlyIdentifiers(node.callee) && callbacks.includes(sourceCode.getText(node.callee)); } /** diff --git a/lib/rules/comma-spacing.js b/lib/rules/comma-spacing.js index 73c10a7711b9..2bf41a00bb66 100644 --- a/lib/rules/comma-spacing.js +++ b/lib/rules/comma-spacing.js @@ -181,7 +181,7 @@ module.exports = { validateCommaItemSpacing({ comma: token, - left: astUtils.isCommaToken(previousToken) || commaTokensToIgnore.indexOf(token) > -1 ? null : previousToken, + left: astUtils.isCommaToken(previousToken) || commaTokensToIgnore.includes(token) ? null : previousToken, right: astUtils.isCommaToken(nextToken) ? null : nextToken }, token); });