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(eslint-plugin): add prefer-includes rule (fixes #284) #294

Merged
merged 13 commits into from Apr 11, 2019

Conversation

mysticatea
Copy link
Member

Fixes #284.

This PR adds new @typescript-eslint/prefer-includes rule.

This rule suggests using includes method if:

  • all of the following conditions satisfied on indexOf method calls:
    1. the call is used to check if the receiver object contains a given value or not.
    2. the receiver object has includes method also.
    3. the indexOf method and includes method have the same parameters.
  • all of the following conditions satisfied on test method calls:
    1. the receiver object is a RegExp object.
    2. the content of the RegExp object can be determined to a unique string.

This PR adds two packages as same as #289.

@mysticatea mysticatea added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin enhancement: new plugin rule New rule request for eslint-plugin labels Feb 18, 2019
@codecov
Copy link

codecov bot commented Feb 18, 2019

Codecov Report

Merging #294 into master will increase coverage by 0.08%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master     #294      +/-   ##
==========================================
+ Coverage   96.87%   96.95%   +0.08%     
==========================================
  Files          70       71       +1     
  Lines        2625     2694      +69     
  Branches      424      435      +11     
==========================================
+ Hits         2543     2612      +69     
  Misses         49       49              
  Partials       33       33
Impacted Files Coverage Δ
...ackages/eslint-plugin/src/rules/prefer-includes.ts 100% <100%> (ø)

@mysticatea
Copy link
Member Author

Side note:

Because I have "format on save by ESLint" always, I have sometimes forgotten to run prettier manually.
I wanted to use .vscode/settings.json to enable editor.formatOnSave option.

…es/new

# Conflicts:
#	packages/eslint-plugin/package.json
#	packages/eslint-plugin/typings/ts-eslint.d.ts
Co-Authored-By: mysticatea <star.ctor@gmail.com>
bradzacher
bradzacher previously approved these changes Feb 23, 2019
Copy link
Member

@bradzacher bradzacher left a comment

Choose a reason for hiding this comment

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

one nit otherwise lgtm

@mysticatea
Copy link
Member Author

Thank you for the review!
I updated this PR.

JamesHenry
JamesHenry previously approved these changes Apr 4, 2019
@JamesHenry
Copy link
Member

Thanks a lot! Just need to resolve the conflicts

@JamesHenry JamesHenry added the awaiting response Issues waiting for a reply from the OP or another party label Apr 4, 2019
# Conflicts:
#	packages/eslint-plugin/package.json
@mysticatea
Copy link
Member Author

Hi. I updated this PR to resolve conflicts.

@bradzacher bradzacher merged commit 01c4dae into master Apr 11, 2019
@bradzacher bradzacher deleted the prefer-array-includes/new branch April 11, 2019 00:40
@sindresorhus
Copy link

This rule was not added to the readme: https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin#supported-rules

@bradzacher bradzacher removed the awaiting response Issues waiting for a reply from the OP or another party label Apr 13, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement: new plugin rule New rule request for eslint-plugin package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rule proposal: Prefer .includes()
5 participants