Skip to content

Commit c0019fb

Browse files
authored
chore: do not use Array#entries for now (#296)
1 parent 4974093 commit c0019fb

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

packages/eslint-mdx/src/helpers.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,12 @@ export const hasProperties = <T, P extends keyof T = keyof T>(
100100
export const getPositionAt = (code: string, offset: number): ESPosition => {
101101
let currOffset = 0
102102

103-
for (const [index, { length }] of code.split('\n').entries()) {
103+
const lines = code.split('\n')
104+
105+
// eslint-disable-next-line unicorn/no-for-loop
106+
for (let index = 0; index < lines.length; index++) {
104107
const line = index + 1
105-
const nextOffset = currOffset + length
108+
const nextOffset = currOffset + lines[index].length
106109

107110
if (nextOffset >= offset) {
108111
return {

0 commit comments

Comments
 (0)