1f755e8b0d
* feat: add retry logic for lazy import * try again * add tests * refactor: moves retry helper to subfolder * missing-files * fix * doc comment * tsdoc * fake timers * fix * add eslint rule * try again? * try again? * only dynamic * try again * try again * IT WORKS * add retry * fix * add test * warn -> error * lint * lint * lint * add back cache * rm test * try again * real timers but really short intervals * try returning the promise? * try returning the promise? * try this package * retry * Update src/utils/retry.ts Co-authored-by: Zach Pomerantz <zzmp@uniswap.org> * Update rules/enforce-retry-on-import.js Co-authored-by: Zach Pomerantz <zzmp@uniswap.org> * Update rules/enforce-retry-on-import.js Co-authored-by: Zach Pomerantz <zzmp@uniswap.org> * eslint_rules * test fixes * name * fix --------- Co-authored-by: Zach Pomerantz <zzmp@uniswap.org>
37 lines
1.0 KiB
JavaScript
37 lines
1.0 KiB
JavaScript
/* eslint-env node */
|
|
|
|
module.exports = {
|
|
meta: {
|
|
type: 'problem',
|
|
docs: {
|
|
description: 'enforce use of retry() for dynamic imports',
|
|
category: 'Best Practices',
|
|
recommended: false,
|
|
},
|
|
schema: [],
|
|
},
|
|
create(context) {
|
|
return {
|
|
ImportExpression(node) {
|
|
const grandParent = node.parent.parent
|
|
if (
|
|
!(
|
|
grandParent &&
|
|
grandParent.type === 'CallExpression' &&
|
|
// Technically, we are only checking that a function named `retry` wraps the dynamic import.
|
|
// We do not go as far as enforcing that it is import('utils/retry').retry
|
|
grandParent.callee.name === 'retry' &&
|
|
grandParent.arguments.length === 1 &&
|
|
grandParent.arguments[0].type === 'ArrowFunctionExpression'
|
|
)
|
|
) {
|
|
context.report({
|
|
node,
|
|
message: 'Dynamic import should be wrapped in retry (see `utils/retry.ts`): `retry(() => import(...))`',
|
|
})
|
|
}
|
|
},
|
|
}
|
|
},
|
|
}
|