Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(eslint): Enable and auto-fix prefer-array-index-of #88047

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ryan953
Copy link
Member

@ryan953 ryan953 commented Mar 26, 2025

No description provided.

@ryan953 ryan953 requested review from a team as code owners March 26, 2025 23:12
@ryan953 ryan953 enabled auto-merge (squash) March 26, 2025 23:13
@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Mar 26, 2025
Comment on lines +661 to +662
// @ts-expect-error: Mismatched types
const tokenIndex = filterTokens.indexOf(token);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a type error here i didn't dig into, the type of token is huge.

That the types don't match might indicate an (existing?) problem

@billyvg
Copy link
Member

billyvg commented Mar 27, 2025

Is there a functional difference between these two or is it more stylistic? Contrast this to #88049 where it's objectively + functionally better (and subjectively, stylistically better imo)

@ryan953
Copy link
Member Author

ryan953 commented Mar 27, 2025

Is there a functional difference between these two or is it more stylistic? Contrast this to #88049 where it's objectively + functionally better (and subjectively, stylistically better imo)

They should be functionally the same. The changes were made but an auto-fix rule, so i put some trust in that when i chose to turn this on.

The docs for each method are here:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf

I'll call out that indexOf uses the same algorithm used by the === operator which all of the changes in this PR were already using.

I think in terms of types TS is doing a better job now, which is why I stomped on some violations that popped up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: Frontend Automatically applied to PRs that change frontend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants