@@ -65,22 +65,20 @@ const createKeyToUserFriendlyMap = () => {
6565 const map = new Map < string , string > ( ) ;
6666
6767 // Map SYNTAX_FILTER_KEYS values to their user-friendly names
68- // eslint-disable-next-line unicorn/no-array-for-each
69- Object . entries ( CONST . SEARCH . SYNTAX_FILTER_KEYS ) . forEach ( ( [ keyName , keyValue ] ) => {
68+ for ( const [ keyName , keyValue ] of Object . entries ( CONST . SEARCH . SYNTAX_FILTER_KEYS ) ) {
7069 if ( ! ( keyName in CONST . SEARCH . SEARCH_USER_FRIENDLY_KEYS ) ) {
71- return ;
70+ continue ;
7271 }
7372 map . set ( keyValue , CONST . SEARCH . SEARCH_USER_FRIENDLY_KEYS [ keyName as keyof typeof CONST . SEARCH . SEARCH_USER_FRIENDLY_KEYS ] ) ;
74- } ) ;
73+ }
7574
7675 // Map SYNTAX_ROOT_KEYS values to their user-friendly names
77- // eslint-disable-next-line unicorn/no-array-for-each
78- Object . entries ( CONST . SEARCH . SYNTAX_ROOT_KEYS ) . forEach ( ( [ keyName , keyValue ] ) => {
76+ for ( const [ keyName , keyValue ] of Object . entries ( CONST . SEARCH . SYNTAX_ROOT_KEYS ) ) {
7977 if ( ! ( keyName in CONST . SEARCH . SEARCH_USER_FRIENDLY_KEYS ) ) {
80- return ;
78+ continue ;
8179 }
8280 map . set ( keyValue , CONST . SEARCH . SEARCH_USER_FRIENDLY_KEYS [ keyName as keyof typeof CONST . SEARCH . SEARCH_USER_FRIENDLY_KEYS ] ) ;
83- } ) ;
81+ }
8482
8583 return map ;
8684} ;
@@ -193,8 +191,7 @@ function buildFilterValuesString(filterName: string, queryFilters: QueryFilter[]
193191 const allowedOps = new Set < string > ( [ CONST . SEARCH . SYNTAX_OPERATORS . EQUAL_TO , CONST . SEARCH . SYNTAX_OPERATORS . NOT_EQUAL_TO ] ) ;
194192
195193 let filterValueString = '' ;
196- // eslint-disable-next-line unicorn/no-array-for-each
197- queryFilters . forEach ( ( queryFilter , index ) => {
194+ for ( const [ index , queryFilter ] of queryFilters . entries ( ) ) {
198195 const previousValueHasSameOp = allowedOps . has ( queryFilter . operator ) && queryFilters ?. at ( index - 1 ) ?. operator === queryFilter . operator ;
199196 const nextValueHasSameOp = allowedOps . has ( queryFilter . operator ) && queryFilters ?. at ( index + 1 ) ?. operator === queryFilter . operator ;
200197
@@ -208,7 +205,7 @@ function buildFilterValuesString(filterName: string, queryFilters: QueryFilter[]
208205 } else {
209206 filterValueString += ` ${ filterName } ${ operatorToCharMap [ queryFilter . operator ] } ${ sanitizeSearchValue ( queryFilter . value . toString ( ) ) } ` ;
210207 }
211- } ) ;
208+ }
212209
213210 return filterValueString ;
214211}
@@ -252,13 +249,12 @@ function getFilters(queryJSON: SearchQueryJSON) {
252249 value : node . right as string | number ,
253250 } ) ;
254251 } else {
255- // eslint-disable-next-line unicorn/no-array-for-each
256- node . right . forEach ( ( element ) => {
252+ for ( const element of node . right ) {
257253 filterArray . push ( {
258254 operator : node . operator ,
259255 value : element ,
260256 } ) ;
261- } ) ;
257+ }
262258 }
263259 filters . push ( { key : nodeKey , filters : filterArray } ) ;
264260 }
@@ -351,26 +347,26 @@ function getQueryHashes(query: SearchQueryJSON): {primaryHash: number; recentSea
351347 // their value when computing the similarSearchHash
352348 const similarSearchValueBasedFilters = new Set < SearchFilterKey > ( [ CONST . SEARCH . SYNTAX_FILTER_KEYS . ACTION ] ) ;
353349
354- query . flatFilters
350+ const flatFilters = query . flatFilters
355351 . map ( ( filter ) => {
356352 const filterKey = filter . key ;
357353 const filters = cloneDeep ( filter . filters ) ;
358354 filters . sort ( ( a , b ) => customCollator . compare ( a . value . toString ( ) , b . value . toString ( ) ) ) ;
359355 return { filterString : buildFilterValuesString ( filterKey , filters ) , filterKey} ;
360356 } )
361- . sort ( ( a , b ) => customCollator . compare ( a . filterString , b . filterString ) )
362- // eslint-disable-next-line unicorn/no-array-for-each
363- . forEach ( ( { filterString, filterKey} ) => {
364- if ( ! similarSearchIgnoredFilters . has ( filterKey ) ) {
365- filterSet . add ( filterKey ) ;
366- }
357+ . sort ( ( a , b ) => customCollator . compare ( a . filterString , b . filterString ) ) ;
367358
368- if ( similarSearchValueBasedFilters . has ( filterKey ) ) {
369- filterSet . add ( filterString . trim ( ) ) ;
370- }
359+ for ( const { filterString, filterKey} of flatFilters ) {
360+ if ( ! similarSearchIgnoredFilters . has ( filterKey ) ) {
361+ filterSet . add ( filterKey ) ;
362+ }
371363
372- orderedQuery += ` ${ filterString } ` ;
373- } ) ;
364+ if ( similarSearchValueBasedFilters . has ( filterKey ) ) {
365+ filterSet . add ( filterString . trim ( ) ) ;
366+ }
367+
368+ orderedQuery += ` ${ filterString } ` ;
369+ }
374370
375371 const similarSearchHash = hashText ( Array . from ( filterSet ) . join ( '' ) , 2 ** 32 ) ;
376372 const recentSearchHash = hashText ( orderedQuery , 2 ** 32 ) ;
@@ -555,14 +551,13 @@ function buildQueryStringFromFilterFormValues(filterValues: Partial<SearchAdvanc
555551 // When switching types/setting the type, ensure we aren't polluting our query with filters that are
556552 // only available for the previous type. Remove all filters that are not allowed for the new type
557553 const providedFilterKeys = Object . keys ( supportedFilterValues ) as SearchAdvancedFiltersKey [ ] ;
558- // eslint-disable-next-line unicorn/no-array-for-each
559- providedFilterKeys . forEach ( ( filter ) => {
554+ for ( const filter of providedFilterKeys ) {
560555 if ( isFilterSupported ( filter , supportedFilterValues . type ?? CONST . SEARCH . DATA_TYPES . EXPENSE ) ) {
561- return ;
556+ continue ;
562557 }
563558
564559 supportedFilterValues [ filter ] = undefined ;
565- } ) ;
560+ }
566561
567562 // We separate type and status filters from other filters to maintain hashes consistency for saved searches
568563 const { type, status, groupBy, ...otherFilters } = supportedFilterValues ;
@@ -701,17 +696,15 @@ function buildQueryStringFromFilterFormValues(filterValues: Partial<SearchAdvanc
701696
702697 filtersString . push ( ...mappedFilters ) ;
703698
704- // eslint-disable-next-line unicorn/no-array-for-each
705- DATE_FILTER_KEYS . forEach ( ( dateKey ) => {
699+ for ( const dateKey of DATE_FILTER_KEYS ) {
706700 const dateFilter = buildDateFilterQuery ( supportedFilterValues , dateKey ) ;
707701 filtersString . push ( dateFilter ) ;
708- } ) ;
702+ }
709703
710- // eslint-disable-next-line unicorn/no-array-for-each
711- AMOUNT_FILTER_KEYS . forEach ( ( filterKey ) => {
704+ for ( const filterKey of AMOUNT_FILTER_KEYS ) {
712705 const amountFilter = buildAmountFilterQuery ( filterKey , supportedFilterValues ) ;
713706 filtersString . push ( amountFilter ) ;
714- } ) ;
707+ }
715708
716709 return filtersString . filter ( Boolean ) . join ( ' ' ) . trim ( ) ;
717710}
0 commit comments