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

feat(no-in-array): Disallow using in operator for arrays #5851

Closed
wants to merge 12 commits into from

Conversation

mahdi-farnia
Copy link

PR Checklist

Overview

Before:
Error expected because in operator can't be used for checking array values.

const array = [4, 5, 6];

if(4 in array) {
  // ...
}

After:

const array = [4, 5, 6];
// vvv Error: 'in' operator for arrays is forbidden. Use array.indexOf or array.includes instead.
if(4 in array) {
  // ...
}

Closes: #5474

mahdi-farnia and others added 12 commits October 19, 2022 00:00
I rewrite it again after one month, and i figured out that the last
clone is outdated and i cloned the latest repo and just copied & pasted
the file.
Because of that there is no history available for this project.
Unnecessary Information Removed

Co-authored-by: Josh Goldberg <git@joshuakgoldberg.com>
Rule Is Now Off By Default

Co-authored-by: Josh Goldberg <git@joshuakgoldberg.com>
My bad!😱

Co-authored-by: Josh Goldberg <git@joshuakgoldberg.com>
This option is unneeded because users can simply turn off the rule
Support for literal method names & better error message for computed and
non-computed method names.
@nx-cloud
Copy link

nx-cloud bot commented Oct 20, 2022

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 4e9da68. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch


✅ Successfully ran 46 targets

Sent with 💌 from NxCloud.

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @mahdi-farnia!

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. As a thank you, your profile/company logo will be added to our main README which receives thousands of unique visitors per day.

@netlify
Copy link

netlify bot commented Oct 20, 2022

Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit 4e9da68
🔍 Latest deploy log https://app.netlify.com/sites/typescript-eslint/deploys/6350ff4d1166e400093395ad
😎 Deploy Preview https://deploy-preview-5851--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.

@mahdi-farnia
Copy link
Author

I have opened another pull request here: #5848

And that PR history comes here too! (I'm not really experienced using github & git)

This shouldn't cause a problem. (should it?)

@codecov
Copy link

codecov bot commented Oct 20, 2022

Codecov Report

Merging #5851 (4e9da68) into main (733b359) will increase coverage by 0.00%.
The diff coverage is 92.85%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5851   +/-   ##
=======================================
  Coverage   91.35%   91.35%           
=======================================
  Files         361      363    +2     
  Lines       12024    12066   +42     
  Branches     3499     3513   +14     
=======================================
+ Hits        10984    11023   +39     
  Misses        743      743           
- Partials      297      300    +3     
Flag Coverage Δ
unittest 91.35% <92.85%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
.../eslint-plugin/src/rules/call-super-on-override.ts 90.32% <90.32%> (ø)
packages/eslint-plugin/src/rules/no-in-array.ts 100.00% <100.00%> (ø)

@JoshuaKGoldberg
Copy link
Member

We don't mind messy Git histories! The commits all get squash merged down to a single merge commit anyway. Git can be excruciatingly difficult system to use for new developers; requiring rewriting history for clean commits is IMO an exclusionary practice.

Can you just delete the unrelated files from this branch? Each PR should only have files that relate to it.

@JoshuaKGoldberg
Copy link
Member

Also, sorry for the redirect @mahdi-farnia - we realized later on that no-in-array is really a subset of what no-misused-in would cover (#5677). I'm going to close this PR for now, but feel free to send a new one that covers no-misused-in overall.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 17, 2022
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.

Rule proposal: Ban 'in' operator for arrays
2 participants