Skip to content

Commit 11ba3dc

Browse files
authored
Refactor for no-extra-lookaround-assertions (#553)
1 parent 0aa9b8f commit 11ba3dc

File tree

1 file changed

+1
-18
lines changed

1 file changed

+1
-18
lines changed

lib/rules/no-extra-lookaround-assertions.ts

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ export default createRule("no-extra-lookaround-assertions", {
4545
assertion: LookaroundAssertion,
4646
) {
4747
for (const alternative of assertion.alternatives) {
48-
const nested = at(
49-
alternative.elements,
48+
const nested = alternative.elements.at(
5049
assertion.kind === "lookahead"
5150
? // The last positive lookahead assertion within
5251
// a lookahead assertion is the same without the assertion.
@@ -99,19 +98,3 @@ export default createRule("no-extra-lookaround-assertions", {
9998
})
10099
},
101100
})
102-
103-
// TODO After dropping support for Node < v16.6.0 we can use native `.at()`.
104-
/**
105-
* `.at()` polyfill
106-
* see https://github.com/tc39/proposal-relative-indexing-method#polyfill
107-
*/
108-
function at<T>(array: T[], n: number) {
109-
// ToInteger() abstract op
110-
let num = Math.trunc(n) || 0
111-
// Allow negative indexing from the end
112-
if (num < 0) num += array.length
113-
// OOB access is guaranteed to return undefined
114-
if (num < 0 || num >= array.length) return undefined
115-
// Otherwise, this is just normal property access
116-
return array[num]
117-
}

0 commit comments

Comments
 (0)