From 1c9a702f73c481e4a44722479f0b76009b0acbcf Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Tue, 21 Jun 2022 16:54:32 +0200 Subject: [PATCH] Enable the `prefer-array-index-of` ESLint plugin rule https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-array-index-of.md --- .eslintrc | 1 + src/core/xfa/template.js | 6 ++---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.eslintrc b/.eslintrc index 5e1210e27..2fc29ccce 100644 --- a/.eslintrc +++ b/.eslintrc @@ -51,6 +51,7 @@ "unicorn/no-useless-spread": "error", "unicorn/prefer-array-flat": "error", "unicorn/prefer-array-flat-map": "error", + "unicorn/prefer-array-index-of": "error", "unicorn/prefer-at": "error", "unicorn/prefer-date-now": "error", "unicorn/prefer-dom-node-append": "error", diff --git a/src/core/xfa/template.js b/src/core/xfa/template.js index 49e5f2698..2395484ec 100644 --- a/src/core/xfa/template.js +++ b/src/core/xfa/template.js @@ -5658,7 +5658,7 @@ class Template extends XFAObject { // We must stop the contentAreas filling and go to the next page. targetPageArea = target; } else if (target instanceof ContentArea) { - const index = contentAreas.findIndex(e => e === target); + const index = contentAreas.indexOf(target); if (index !== -1) { if (index > currentIndex) { // In the next loop iteration `i` will be incremented, note the @@ -5671,9 +5671,7 @@ class Template extends XFAObject { } } else { targetPageArea = target[$getParent](); - startIndex = targetPageArea.contentArea.children.findIndex( - e => e === target - ); + startIndex = targetPageArea.contentArea.children.indexOf(target); } } continue;