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): added new rule await-promise #192

Conversation

JoshuaKGoldberg
Copy link
Member

Adds the equivalent of TSLint's await-promise rule.

Adds the equivalent of TSLint's `await-promise` rule.
@codecov
Copy link

codecov bot commented Feb 3, 2019

Codecov Report

Merging #192 into master will increase coverage by 0.01%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master     #192      +/-   ##
==========================================
+ Coverage   96.95%   96.96%   +0.01%     
==========================================
  Files          71       72       +1     
  Lines        2694     2705      +11     
  Branches      435      436       +1     
==========================================
+ Hits         2612     2623      +11     
  Misses         49       49              
  Partials       33       33
Impacted Files Coverage Δ
packages/eslint-plugin/src/rules/await-thenable.ts 100% <100%> (ø)

@JoshuaKGoldberg JoshuaKGoldberg changed the title feat(eslint-plugin) added new rule await-promise feat: (eslint-plugin) added new rule await-promise Feb 3, 2019
j-f1
j-f1 previously requested changes Feb 3, 2019
packages/eslint-plugin/docs/rules/await-promise.md Outdated Show resolved Hide resolved
packages/eslint-plugin/tests/lib/rules/await-promise.js Outdated Show resolved Hide resolved
@armano2 armano2 changed the title feat: (eslint-plugin) added new rule await-promise feat(eslint-plugin): added new rule await-promise Feb 3, 2019
@JoshuaKGoldberg
Copy link
Member Author

Btw, this ended up using the same containsType(ByName) util as #194, so I moved it to utils/types.js.

@armano2 armano2 added the enhancement: new plugin rule New rule request for eslint-plugin label Feb 3, 2019
bradzacher
bradzacher previously approved these changes Feb 3, 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.

code LGTM

bradzacher
bradzacher previously approved these changes Feb 7, 2019
@JamesHenry
Copy link
Member

Apologies for the conflicts, we decided to remove the counts from the ROADMAP here: #225

They are too awkward to maintain manually, so this is the last time you will have to deal with syncing that up!

bradzacher
bradzacher previously approved these changes Feb 7, 2019
@JoshuaKGoldberg
Copy link
Member Author

Awesome, glad the type checker works out that way! That looks like it'll need to be a shared method by this, #194, and other promise-checking functions.

Would you still want the allowedPromiseNames option as part of the rule? I can't think of a way for it to be particularly useful unless folks have improperly written Promise-like typings, so I'll add test cases for definitions mirroring Bluebird's and other popular polyfills.

@mysticatea
Copy link
Member

Would you still want the allowedPromiseNames option as part of the rule?

I don't think so.

And, I think we should rename the rule to require-await-thenable.

  • In practice, Rules which disallow arbitary notation if something is lacking have require- prefix.
  • Now the rule checks then property rather than Promise.

@JoshuaKGoldberg
Copy link
Member Author

JoshuaKGoldberg commented Feb 24, 2019

Turns out tsutils already has a isThenableType method, so I used that one and removed allowedPromiseNames. ✔

require-await-thenable

👍 on promise -> thenable, but I'm still hesitant to sustain the require- prefix tradition for similar reasons to the no- prefix tradition:

  • it's rather inconvenient to work with larger eslintrc files when the names' alphabetical ordering isn't very useful
  • it's hard to tell when rules will eventually allow the opposite of the require- behavior; for example, if this rule eventually also handles whether we should or shouldn't await values of type any and/or unknown
  • require- has a naming relevancy to require() and modules, which is confusing for newcomers to look at

I don't want to bikeshed in your repository (especially if the focus is to adhere to existing ESLint traditions) 😄 so if you'd like I can rename to require-await-thenable in this PR! Just a couple of cents.

@merlinnot
Copy link

Hey guys, is it still blocked? It looks like the TS migration is done.

@JamesHenry
Copy link
Member

@mysticatea @j-f1 please can you update your reviews of this PR?

Probably worth just getting it in at this point!

Copy link
Member

@mysticatea mysticatea left a comment

Choose a reason for hiding this comment

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

I'm sorry for my disappeared. I have lost track in busy of working for ESLint 6.

I left some fixes and suggestions.

packages/eslint-plugin/ROADMAP.md Outdated Show resolved Hide resolved
packages/eslint-plugin/ROADMAP.md Outdated Show resolved Hide resolved
packages/eslint-plugin/README.md Outdated Show resolved Hide resolved
packages/eslint-plugin/docs/rules/await-thenable.md Outdated Show resolved Hide resolved
packages/eslint-plugin/docs/rules/await-thenable.md Outdated Show resolved Hide resolved
packages/eslint-plugin/src/rules/await-thenable.ts Outdated Show resolved Hide resolved
mysticatea and others added 6 commits April 3, 2019 08:08
Co-Authored-By: JoshuaKGoldberg <joshuakgoldberg@outlook.com>
Co-Authored-By: JoshuaKGoldberg <joshuakgoldberg@outlook.com>
Co-Authored-By: JoshuaKGoldberg <joshuakgoldberg@outlook.com>
Co-Authored-By: JoshuaKGoldberg <joshuakgoldberg@outlook.com>
@JamesHenry
Copy link
Member

Perfectly understandable @mysticatea! Thanks for looping back to it.

Looks like @JoshuaKGoldberg addressed your most recent feedback, would you agree?

@JamesHenry JamesHenry added awaiting response Issues waiting for a reply from the OP or another party and removed awaiting response Issues waiting for a reply from the OP or another party labels Apr 4, 2019
@bradzacher bradzacher merged commit 5311342 into typescript-eslint:master Apr 11, 2019
@JoshuaKGoldberg JoshuaKGoldberg deleted the typescript-eslint-await-promise branch April 11, 2019 11:22
kaicataldo pushed a commit to kaicataldo/typescript-eslint that referenced this pull request Aug 27, 2019
…int#192)

The vscode autoformatter is completely at odds with prettier, so if you don't have the prettier extension installed, you end up with wild changes.

Additionally if you've got both the beautify and prettier extensions installed, it can cause some serious issues.

Forcing it to be on will probably cause a lot of headaches to anyone trying to contribute unless they get their environment setup perfectly (sorry @weirdpattern for earlier!!)
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 21, 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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants