diff --git a/.eslintrc.cjs b/.eslintrc.cjs index d54d1466f19..5b12991ba4a 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -27,6 +27,25 @@ const deprecatedTerminology = Object.fromEntries( ]), ); +/** + * Rules for code that crosses an asyncFlow membrane. + */ +const resumable = [ + { + selector: 'FunctionExpression[async=true]', + message: 'Non-immediate functions must return vows, not promises', + }, + { + selector: 'ArrowFunctionExpression[async=true]', + message: 'Non-immediate functions must return vows, not promises', + }, + { + selector: "Identifier[name='callWhen']", + message: + 'callWhen wraps the function in a promise; instead immediately return a vow', + }, +]; + module.exports = { root: true, parser: '@typescript-eslint/parser', @@ -135,6 +154,14 @@ module.exports = { ], }, }, + { + // Modules with exports that must be resumable + files: ['packages/orchestration/src/exos/**'], + rules: { + // TODO tighten to error + 'no-restricted-syntax': ['warn', ...resumable], + }, + }, { // Allow "loan" contracts to mention the word "loan". files: ['packages/zoe/src/contracts/loan/*.js'],