diff --git a/eslint.config.mjs b/eslint.config.mjs index 7eb8a062747a58..26a0dc8dda47a3 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -592,7 +592,7 @@ export default typescript.config([ 'unicorn/prefer-array-find': 'off', // TODO(ryan953): Fix violations and enable this rule 'unicorn/prefer-array-flat-map': 'error', 'unicorn/prefer-array-flat': 'off', // TODO(ryan953): Fix violations and enable this rule - 'unicorn/prefer-array-index-of': 'off', // TODO(ryan953): Fix violations and enable this rule + 'unicorn/prefer-array-index-of': 'error', 'unicorn/prefer-array-some': 'off', // TODO(ryan953): Fix violations and enable this rule 'unicorn/prefer-date-now': 'error', 'unicorn/prefer-default-parameters': 'warn', // TODO(ryan953): Fix violations and enable this rule diff --git a/static/app/components/deprecatedSmartSearchBar/index.tsx b/static/app/components/deprecatedSmartSearchBar/index.tsx index 24ba6a17b5030e..53e8ca95270a61 100644 --- a/static/app/components/deprecatedSmartSearchBar/index.tsx +++ b/static/app/components/deprecatedSmartSearchBar/index.tsx @@ -658,7 +658,8 @@ class DeprecatedSmartSearchBar extends Component { let offset = filterTokens[0]!.location.end.offset; if (token) { - const tokenIndex = filterTokens.findIndex(tok => tok === token); + // @ts-expect-error: Mismatched types + const tokenIndex = filterTokens.indexOf(token); if (tokenIndex !== -1 && tokenIndex + 1 < filterTokens.length) { offset = filterTokens[tokenIndex + 1]!.location.end.offset; } @@ -677,7 +678,8 @@ class DeprecatedSmartSearchBar extends Component { const hasExecCommand = typeof document.execCommand === 'function'; if (token && filterTokens.length > 0) { - const index = filterTokens.findIndex(tok => tok === token) ?? -1; + // @ts-expect-error: Mismatched types + const index = filterTokens.indexOf(token) ?? -1; const newQuery = // We trim to remove any remaining spaces query.slice(0, token.location.start.offset).trim() + diff --git a/static/app/components/replays/useJumpButtons.tsx b/static/app/components/replays/useJumpButtons.tsx index 4273d72fc52b61..312afa88fd881f 100644 --- a/static/app/components/replays/useJumpButtons.tsx +++ b/static/app/components/replays/useJumpButtons.tsx @@ -28,7 +28,10 @@ export default function useJumpButtons({ targetOffsetMs: currentTime, allowExact: true, }); - const index = frames.findIndex(spanFrame => frame === spanFrame); + if (!frame) { + return frames.length - 1; + } + const index = frames.indexOf(frame); // index is -1 at end of replay, so use last index return index === -1 ? frames.length - 1 : index; }, [currentTime, frames]); diff --git a/static/app/stores/selectedGroupStore.tsx b/static/app/stores/selectedGroupStore.tsx index 33d0c4aeece62f..235876e2943e33 100644 --- a/static/app/stores/selectedGroupStore.tsx +++ b/static/app/stores/selectedGroupStore.tsx @@ -139,8 +139,8 @@ const storeConfig: SelectedGroupStoreDefinition = { } const ids = GroupStore.getAllItemIds(); - const lastIdx = ids.findIndex(id => id === this.state.lastSelected); - const currentIdx = ids.findIndex(id => id === itemId); + const lastIdx = ids.indexOf(this.state.lastSelected); + const currentIdx = ids.indexOf(itemId); if (lastIdx === -1 || currentIdx === -1) { return; diff --git a/static/app/views/dashboards/widgetBuilder/buildSteps/groupByStep/groupBySelector.tsx b/static/app/views/dashboards/widgetBuilder/buildSteps/groupByStep/groupBySelector.tsx index 42e5434baebc84..68cfb32173df6a 100644 --- a/static/app/views/dashboards/widgetBuilder/buildSteps/groupByStep/groupBySelector.tsx +++ b/static/app/views/dashboards/widgetBuilder/buildSteps/groupByStep/groupBySelector.tsx @@ -129,9 +129,7 @@ export function GroupBySelector({ }>( (acc, key) => { const value = fieldOptions[key]!; - const optionInColumnsIndex = columnFieldsAsString.findIndex( - column => column === value.value.meta.name - ); + const optionInColumnsIndex = columnFieldsAsString.indexOf(value.value.meta.name); if (optionInColumnsIndex === -1) { acc.filteredFieldOptions[key] = value; return acc; diff --git a/static/app/views/projectDetail/projectCharts.tsx b/static/app/views/projectDetail/projectCharts.tsx index 972e85be9e224c..d7b282421b22e8 100644 --- a/static/app/views/projectDetail/projectCharts.tsx +++ b/static/app/views/projectDetail/projectCharts.tsx @@ -124,7 +124,7 @@ class ProjectCharts extends Component { .map(urlKey => { return decodeScalar( location.query[urlKey], - this.defaultDisplayModes[visibleCharts.findIndex(value => value === urlKey)]! + this.defaultDisplayModes[visibleCharts.indexOf(urlKey)]! ); }); }