Skip to content

docs(website): fix wrong example in prefer-includes #7036

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

Merged
merged 1 commit into from
May 17, 2023
Merged

docs(website): fix wrong example in prefer-includes #7036

merged 1 commit into from
May 17, 2023

Conversation

Juneezee
Copy link
Contributor

PR Checklist

  • Addresses an existing open issue: Is this necessary for a minor documentation change 🤔 ?
  • That issue was marked as accepting prs
  • Steps in Contributing were taken

Overview

readonlyArray.indexOf(value) === -1 is checking if value is not included in readonlyArray. So it should be
!readonlyArray.includes(value).

// negative
{
code: `
function f(a: string): void {
a.indexOf(b) === -1;
}
`,
output: `
function f(a: string): void {
!a.includes(b);
}
`,
errors: [{ messageId: 'preferIncludes' }],
},
{
code: `
function f(a: string): void {
a.indexOf(b) == -1;
}
`,
output: `
function f(a: string): void {
!a.includes(b);
}
`,
errors: [{ messageId: 'preferIncludes' }],
},

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @Juneezee!

typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community.

The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately.

Thanks again!


🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/typescript-eslint.

@netlify
Copy link

netlify bot commented May 17, 2023

Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit df6e6e7
🔍 Latest deploy log https://app.netlify.com/sites/typescript-eslint/deploys/6464e1aea3d36e00089d1fb1
😎 Deploy Preview https://deploy-preview-7036--typescript-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@Juneezee Juneezee changed the title docs(prefer-includes): fix wrong example docs(website): fix wrong example in prefer-includes May 17, 2023
`readonlyArray.indexOf(value) === -1` is checking if `value` is **not
included** in `readonlyArray`. So it should be
`!readonlyArray.includes(value)`.

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
@nx-cloud
Copy link

nx-cloud bot commented May 17, 2023

Copy link
Member

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Choose a reason for hiding this comment

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

Addresses an existing open issue: Is this necessary for a minor documentation change 🤔 ?

Nope, it's not - thanks for sending!

@JoshuaKGoldberg
Copy link
Member

Amusingly, I think the typo could arguably be the other way - that we used === instead of !==. But this works too. And I think better shows the rule off.

@JoshuaKGoldberg JoshuaKGoldberg merged commit 8951732 into typescript-eslint:main May 17, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants