Skip to content

Commit 7db1382

Browse files
committed
remove util for retrieving the last element of array
1 parent 00c9c0e commit 7db1382

File tree

2 files changed

+4
-15
lines changed

2 files changed

+4
-15
lines changed

lib/rules/prefer-use-template-ref.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,14 @@ function addUseTemplateRefImport(context, fixer) {
7575
)
7676

7777
if (vueDestructuredImport) {
78-
const importSpecifierLast = utils.getLastArrayElement(
79-
vueDestructuredImport.specifiers
80-
)
78+
const importSpecifiers = vueDestructuredImport.specifiers
79+
const lastImportSpecifier = importSpecifiers[importSpecifiers.length - 1]
8180

8281
// @ts-ignore
83-
return fixer.insertTextAfter(importSpecifierLast, `,useTemplateRef`)
82+
return fixer.insertTextAfter(lastImportSpecifier, `,useTemplateRef`)
8483
}
8584

86-
const lastImport = utils.getLastArrayElement(imports)
85+
const lastImport = imports[imports.length - 1]
8786

8887
const importStatement = "import {useTemplateRef} from 'vue';"
8988

lib/utils/index.js

-10
Original file line numberDiff line numberDiff line change
@@ -2208,16 +2208,6 @@ module.exports = {
22082208
(token, i) =>
22092209
token.type === tokensR[i].type && token.value === tokensR[i].value
22102210
)
2211-
},
2212-
2213-
/**
2214-
* TODO: replace usages with 'array.at(-1)' once the minimum supported Node.js version is at least 16.6.0
2215-
* @template T
2216-
* @param array {T[]}
2217-
* @returns {T | undefined}
2218-
* */
2219-
getLastArrayElement(array) {
2220-
return array[array.length - 1]
22212211
}
22222212
}
22232213

0 commit comments

Comments
 (0)