Skip to content

Commit

Permalink
lint: warn on non-resumable code (#9543)
Browse files Browse the repository at this point in the history
refs: #9449

## Description
A lint rule to help identify code that doesn't conform to the membrane passing requirements in #9449. 

Once we've brought all the modules into conformance this should be upgraded from a warning to an error.

### Security Considerations
none

### Scaling Considerations
none

### Documentation Considerations
none

### Testing Considerations
CI

### Upgrade Considerations
none
  • Loading branch information
mergify[bot] authored Jun 20, 2024
2 parents 0cfea88 + 608b882 commit f9bd118
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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'],
Expand Down

0 comments on commit f9bd118

Please sign in to comment.