-
Notifications
You must be signed in to change notification settings - Fork 18
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
Augment templates configs with more opinionated stricter rules for actor development #89
Comments
We discussed many times that we should have a I think from SDK v3, we plan to fully migrate to ES modules (which we should probably do a long while ago). Not sure about |
I read the article and I think there isn't much useful rules for writing actors, very rarely you would need to construct promises by hand via |
dealing with events (and listeners), dealing with callbacks, this is very common to have let c = 0;
return Promise.race([
new Promise(async (resolve) => {
while (c < 10) {
await page.doSomeScrolling();
c++;
await el = page.$('#id');
if (el) {
resolve(el);
break;
}
}
}),
sleep(30000),
]); can be solved by IIFE (that it's a promise without the callbacks) let c = 0;
return Promise.race([
(async () => {
while (c < 10) {
await page.doSomeScrolling();
c++;
await el = page.$('#id');
if (el) {
resolve(el);
break;
}
}
})(),
sleep(30000),
]); for page events: const f = (page) => {
return new Promise((resolve, reject) => {
page.on('popup', (newPage) => {
newPage.waitForNavigation().then(() => resolve(newPage), reject);
});
})
} also I've seen this quite a lot: await Promises.all(requests.map((req) => requestQueue.addRequest(req)));
// or the good intent one, they are the same
requests.forEach(async (req) => {
await requestQueue.addRequest(req);
}); I've also seen 4, 5, 7, 10 (people don't know there are |
this: https://maximorlov.com/linting-rules-for-asynchronous-code-in-javascript
and also:
Apify.getValue('INPUT')
->Apify.getInput()
async
event listeners onpage.on()
or any other event listener that is synchronous. if it's there, ask to add try/catch blocktype: "module"
, require adding the extension for.js
files (not.mjs
)jsconfig.json
by default, a lot of VSCode devs have no idea this exists (and they code contains 0 warnings/errors/hints) and helps a lot with "closer to tsconfig" intellisense and even a companion to eslintthis means it shouldn't be added to top level
@apify/eslint-config
because there will be many rules that only make sense while dealing with the SDK on a daily basisThe text was updated successfully, but these errors were encountered: