33 * @copyright 2017 Toru Nagashima. All rights reserved.
44 * See LICENSE file in root directory for full license.
55 */
6- import first from "lodash/first"
7- import last from "lodash/last"
8- import sortedIndexBy from "lodash/sortedIndexBy"
6+ import { sortedIndexBy } from "../utils/utils"
97import type {
108 ESLintArrayExpression ,
119 ESLintArrayPattern ,
@@ -521,7 +519,7 @@ function parseFilter(
521519 }
522520 }
523521
524- const token = last ( ast . tokens ) !
522+ const token = ast . tokens ! . at ( - 1 ) !
525523 return throwUnexpectedTokenError ( token . value , token )
526524 }
527525
@@ -536,7 +534,7 @@ function parseFilter(
536534
537535 // Update range.
538536 const firstToken = tokens [ 0 ]
539- const lastToken = last ( tokens ) !
537+ const lastToken = tokens . at ( - 1 ) !
540538 expression . range = [ firstToken . range [ 0 ] , lastToken . range [ 1 ] ]
541539 expression . loc = { start : firstToken . loc . start , end : lastToken . loc . end }
542540
@@ -778,7 +776,7 @@ export function parseExpression(
778776 }
779777
780778 // Update range.
781- const lastToken = last ( ret . tokens ) !
779+ const lastToken = ret . tokens . at ( - 1 ) !
782780 ret . expression . range [ 1 ] = lastToken . range [ 1 ]
783781 ret . expression . loc . end = lastToken . loc . end
784782
@@ -933,7 +931,7 @@ function parseVForExpressionForEcmaVersion5(
933931 if ( open != null ) {
934932 open . value = "("
935933 }
936- const close = last ( parsedAliases . tokens )
934+ const close = parsedAliases . tokens . at ( - 1 )
937935 if ( close != null ) {
938936 close . value = ")"
939937 }
@@ -977,7 +975,7 @@ function parseVForExpressionForEcmaVersion5(
977975 comments . push ( ...parsedIterator . comments )
978976 const { right, references } = parsedIterator
979977 const firstToken = tokens [ 0 ]
980- const lastToken = last ( tokens ) || firstToken
978+ const lastToken = tokens . at ( - 1 ) || firstToken
981979 const expression : VForExpression = {
982980 type : "VForExpression" ,
983981 range : [ firstToken . range [ 0 ] , lastToken . range [ 1 ] ] ,
@@ -1136,8 +1134,8 @@ function parseVOnExpressionBody(
11361134 ) . argument as ESLintFunctionExpression
11371135 const block = functionDecl . body
11381136 const body = block . body
1139- const firstStatement = first ( body )
1140- const lastStatement = last ( body )
1137+ const firstStatement = body [ 0 ]
1138+ const lastStatement = body . at ( - 1 )
11411139 const expression : VOnExpression = {
11421140 type : "VOnExpression" ,
11431141 range : [
@@ -1231,8 +1229,8 @@ export function parseSlotScopeExpression(
12311229 )
12321230 const references = scope . references
12331231 const variables = scope . variables
1234- const firstParam = first ( params ) !
1235- const lastParam = last ( params ) !
1232+ const firstParam = params [ 0 ]
1233+ const lastParam = params . at ( - 1 ) !
12361234 const expression : VSlotScopeExpression = {
12371235 type : "VSlotScopeExpression" ,
12381236 range : [ firstParam . range [ 0 ] , lastParam . range [ 1 ] ] ,
@@ -1330,8 +1328,8 @@ export function parseGenericExpression(
13301328 )
13311329 const references = scope . references
13321330 const variables = scope . variables
1333- const firstParam = first ( params ) !
1334- const lastParam = last ( params ) !
1331+ const firstParam = params [ 0 ]
1332+ const lastParam = params . at ( - 1 ) !
13351333 const expression : VGenericExpression = {
13361334 type : "VGenericExpression" ,
13371335 range : [ firstParam . range [ 0 ] , lastParam . range [ 1 ] ] ,
0 commit comments