From 7db13827e7204365bd31547d6fb7c049ddaa41ae Mon Sep 17 00:00:00 2001 From: Thomasan1999 Date: Sat, 30 Nov 2024 13:04:19 +0100 Subject: [PATCH] remove util for retrieving the last element of array --- lib/rules/prefer-use-template-ref.js | 9 ++++----- lib/utils/index.js | 10 ---------- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/lib/rules/prefer-use-template-ref.js b/lib/rules/prefer-use-template-ref.js index 1aac8f0f8..6d07c04ac 100644 --- a/lib/rules/prefer-use-template-ref.js +++ b/lib/rules/prefer-use-template-ref.js @@ -75,15 +75,14 @@ function addUseTemplateRefImport(context, fixer) { ) if (vueDestructuredImport) { - const importSpecifierLast = utils.getLastArrayElement( - vueDestructuredImport.specifiers - ) + const importSpecifiers = vueDestructuredImport.specifiers + const lastImportSpecifier = importSpecifiers[importSpecifiers.length - 1] // @ts-ignore - return fixer.insertTextAfter(importSpecifierLast, `,useTemplateRef`) + return fixer.insertTextAfter(lastImportSpecifier, `,useTemplateRef`) } - const lastImport = utils.getLastArrayElement(imports) + const lastImport = imports[imports.length - 1] const importStatement = "import {useTemplateRef} from 'vue';" diff --git a/lib/utils/index.js b/lib/utils/index.js index ace71b919..167edf208 100644 --- a/lib/utils/index.js +++ b/lib/utils/index.js @@ -2208,16 +2208,6 @@ module.exports = { (token, i) => token.type === tokensR[i].type && token.value === tokensR[i].value ) - }, - - /** - * TODO: replace usages with 'array.at(-1)' once the minimum supported Node.js version is at least 16.6.0 - * @template T - * @param array {T[]} - * @returns {T | undefined} - * */ - getLastArrayElement(array) { - return array[array.length - 1] } }