-
-
Notifications
You must be signed in to change notification settings - Fork 91
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
promise/prefer-await-to-callbacks warns on library methods #175
Comments
This plugin doesn't check TypeScript types and was built before TypeScript and ESLint had more integrated tooling with each other. Right now, rules are checking names of arguments and warning, resulting in some false positives for sure. I'm not sure the lengths we could go to in this plugin to support TypeScript type checking 🤔 definitely worth some exploration, but not something I can personally contribute time to right now. Would love some more input on this from you or other ESLint plugin contributors who have been able to support TypeScript language features in an ESLint plugin without forcing JavaScript-only codebases to install TypeScript tooling. We also need some better docs for how/when to use the // https://nodejs.org/api/util.html#util_util_promisify_original
// available in Node 8 or later
import {promisify} from 'util'
// could also use the 3rd party module, pify
// https://www.npmjs.com/package/pify
const {cookies} = window.webContents.session
const setCookie = promisify(cookies.set)
cookies.on('changed', async (_, cookie) => {
const updateCookie = cookie => ({ ...cookie, /* whatever you want to update */ })
try {
const newCookie = updateCookie(cookie)
await setCookie(newCookie)
} catch (err) {
handleError(err)
}
}) Alternatively, you could disable the rule for this case with an I know the issue you reported isn't the ideal developer experience right now, but it's a tricky problem trying to detect usage of 3rd party libraries and Promises in an ESLint plugin, which by default, has no understanding of TypeScript types. I appreciate your feedback and let me know if any of these things help for now or if you have other questions/ideas. |
Thanks for replying so fast. |
Some projects might want to get rid of dependencies which don't offer Promises though. I think it may be reasonable as an optional enhancement, however. |
Description
Rule promise/prefer-await-to-callbacks incorrectly warns on library methods. It should check only code in project.
Steps to Reproduce
Code:
Expected behavior: All should be fine because method comes from library (typings)
Actual behavior: err => {} is marked as error because of callback argument name (WHAT?!)
Versions
Additional Information
Project in TypeScript language. Just to let you know.
The text was updated successfully, but these errors were encountered: