Skip to content

Commit

Permalink
test: linting flows
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg committed Jul 18, 2024
1 parent dc333ab commit 708ace8
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
19 changes: 19 additions & 0 deletions packages/eslint-config/eslint-config.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
/* eslint-env node */

const orchestrationFlowRestrictions = [
{
selector: "Identifier[name='heapVowE']",
message: 'Eventual send is not yet supported within an orchestration flow',
},
{
selector: "Identifier[name='E']",
message: 'Eventual send is not yet supported within an orchestration flow',
},
];

module.exports = {
extends: [
'airbnb-base',
Expand Down Expand Up @@ -95,5 +107,12 @@ module.exports = {
'no-unused-vars': 'off',
},
},
{
// Orchestration flows
files: ['**/*.flows.js'],
rules: {
'no-restricted-syntax': ['error', ...orchestrationFlowRestrictions],
},
},
],
};
24 changes: 24 additions & 0 deletions packages/orchestration/test/examples/bad.flows.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* @file Module with linting errors, to verify the linting config detects them.
* This assumes `reportUnusedDisableDirectives: "error" in the local config.
*/

// TODO error on exports that:
// - aren't hardened (probably a new rule in @endo/eslint-plugin )
// - don't satisfy orchestration flow type

// eslint-disable-next-line no-restricted-syntax -- intentional for test
import { E } from '@endo/far';

export function notFlow() {
console.log('This function is not a flow');
}

export async function notHardened() {
console.log('This function is the most minimal flow, but it’s not hardened');
}

export async function usesE(orch, { someEref }) {
// eslint-disable-next-line no-restricted-syntax -- intentional for test
await E(someEref).foo();
}

0 comments on commit 708ace8

Please sign in to comment.