Skip to content

Commit cb5d090

Browse files
mountinycursoragent
andcommitted
fix: hoist getUserFriendlyKey out of map and justify eslint-disable
Address AI reviewer feedback: - PERF-13: Hoist iterator-independent getUserFriendlyKey() call outside the .map() in the currency case - CONSISTENCY-5: Add justification comment for eslint-disable in tests Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 8051efe commit cb5d090

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/hooks/useAutocompleteSuggestions.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,9 @@ function useAutocompleteSuggestions({
158158
.sort()
159159
.slice(0, 10);
160160

161+
const friendlyKey = getUserFriendlyKey(autocompleteKey);
161162
return filteredCurrencies.map((currencyName) => ({
162-
filterKey: getUserFriendlyKey(autocompleteKey),
163+
filterKey: friendlyKey,
163164
text: currencyName,
164165
}));
165166
}

tests/unit/hooks/useAutocompleteSuggestions.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ jest.mock('@libs/SearchUIUtils', () => ({
7878
getHasOptions: jest.fn(() => [{value: 'attachment'}, {value: 'note'}]),
7979
}));
8080

81-
// eslint-disable-next-line @typescript-eslint/naming-convention
81+
// eslint-disable-next-line @typescript-eslint/naming-convention -- jest.requireMock returns a module-shaped object; destructured name must match the original export
8282
const {parseForAutocomplete} = jest.requireMock<{parseForAutocomplete: jest.Mock}>('@libs/SearchAutocompleteUtils');
8383

8484
const defaultParams = {

0 commit comments

Comments
 (0)