From 87040091393657ee16742815db777505add8ac10 Mon Sep 17 00:00:00 2001 From: Paul Irish Date: Mon, 6 Feb 2023 13:55:10 -0800 Subject: [PATCH] misc(lint): enable no-conditional-assignment rule --- .eslintrc.cjs | 1 + core/lib/page-functions.js | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 922aca5fef53..5d3c2f3a3e41 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -78,6 +78,7 @@ module.exports = { argsIgnorePattern: '(^reject$|^_+$)', varsIgnorePattern: '(^_$|^LH$)', }], + 'no-cond-assign': 2, 'space-infix-ops': 2, 'strict': [2, 'global'], 'prefer-const': 2, diff --git a/core/lib/page-functions.js b/core/lib/page-functions.js index 93175de01155..2a4f38a15659 100644 --- a/core/lib/page-functions.js +++ b/core/lib/page-functions.js @@ -59,7 +59,7 @@ function getElementsInDocument(selector) { /** @param {NodeListOf} nodes */ const _findAllElements = nodes => { - for (let i = 0, el; el = nodes[i]; ++i) { + for (const el of nodes) { if (!selector || realMatchesFn.call(el, selector)) { /** @type {ParseSelector} */ // @ts-expect-error - el is verified as matching above, tsc just can't verify it through the .call(). @@ -265,7 +265,7 @@ function getNodePath(node) { } let index = 0; let prevNode; - while (prevNode = node.previousSibling) { + while (prevNode = node.previousSibling) { // eslint-disable-line no-cond-assign node = prevNode; // skip empty text nodes if (node.nodeType === Node.TEXT_NODE && (node.nodeValue || '').trim().length === 0) continue;