@junoflow/eslint-plugin 0.15.0 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -16
- package/index.js +17 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -17,22 +17,22 @@ These are about the replay contract: a Juno run re-executes your handler from
|
|
|
17
17
|
the top after every suspension and every retry, replaying completed steps from a
|
|
18
18
|
journal instead of re-running them. Everything below follows from that.
|
|
19
19
|
|
|
20
|
-
| Rule | | Catches
|
|
21
|
-
| --------------------------------- | --- |
|
|
22
|
-
| `juno/no-dynamic-step-id` | ⛔ | `step.run(id)` / `step.llm(id)` where `id` is not a static string literal, or contains the reserved `#`
|
|
23
|
-
| `juno/no-dynamic-scoped-name` | ⛔ | `state.scoped(name)` where `name` is not a static string literal
|
|
24
|
-
| `juno/no-journaled-in-step` | ⛔ | anything journaled inside a `step.run` callback — `wait`, a handle constructor (`ask` included) or `cancel()`, `sleep`, `invoke`/`invokeAll`, `findings.*`, `state.scoped`, `notify`, a step |
|
|
25
|
-
| `juno/no-concurrent-capabilities` | ⛔ | `Promise.all([…])` over two suspending calls — `wait`, `sleep`, `invoke`/`invokeAll`. The first to fire exits; the rest never run
|
|
26
|
-
| `juno/no-nondeterminism` | ⛔ | `Date.now()`, `new Date()`, `Math.random()`, `crypto.randomUUID()` outside a step, and `process.env` anywhere
|
|
27
|
-
| `juno/no-floating-capability` | ⛔ | a capability call used as a statement without `await`
|
|
28
|
-
| `juno/no-credential-leak` | ⛔ | `ctx.credentials.*` passed to `log`/`console`, put in a finding, or returned directly from a step
|
|
29
|
-
| `juno/valid-duration` | ⛔ | a duration string that `time.ParseDuration` rejects — `'1d'`, `'10 minutes'`. Checks `sleep`, `after`, `timeout` and `ttl` arguments
|
|
30
|
-
| `juno/require-effects-in-step` | ⚠️ | a side effect outside a step, **in a handler that already takes a step or suspends**. Reads (`state.get`, `now`, `getState`) are exempt
|
|
31
|
-
| `juno/require-suspension-label` | ⚠️ | `wait` / `sleep` with no operator-facing label
|
|
32
|
-
| `juno/prefer-using-for-handles` | ⚠️ | a handle opened in a loop and bound with `const`/`let` but never `cancel()`ed there. It stays open; a run holds at most 100 — use `using`
|
|
33
|
-
| `juno/no-duplicate-step-id` | ⚠️ | the same literal step ID at two call sites in one handler
|
|
34
|
-
| `juno/prefer-step-for-clock` | ⚠️ | `now()` / `solar()` outside a step in a handler that suspends
|
|
35
|
-
| `juno/no-module-state` | ⚠️ | module-scope `let`/`var` written from a handler. It does not persist — the sandbox is a fresh process per dispatch
|
|
20
|
+
| Rule | | Catches |
|
|
21
|
+
| --------------------------------- | --- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
22
|
+
| `juno/no-dynamic-step-id` | ⛔ | `step.run(id)` / `step.llm(id)` where `id` is not a static string literal, or contains the reserved `#` |
|
|
23
|
+
| `juno/no-dynamic-scoped-name` | ⛔ | `state.scoped(name)` where `name` is not a static string literal |
|
|
24
|
+
| `juno/no-journaled-in-step` | ⛔ | anything journaled inside a `step.run` callback — `wait`, a handle constructor (`ask` included) or `cancel()`, `sleep`, `invoke`/`invokeAll`, `findings.*`, `state.scoped`, `notify`, `tasks.<b>.open`, `ongoing.<n>.start`/`end`, a step |
|
|
25
|
+
| `juno/no-concurrent-capabilities` | ⛔ | `Promise.all([…])` over two suspending calls — `wait`, `sleep`, `invoke`/`invokeAll`. The first to fire exits; the rest never run |
|
|
26
|
+
| `juno/no-nondeterminism` | ⛔ | `Date.now()`, `new Date()`, `Math.random()`, `crypto.randomUUID()` outside a step, and `process.env` anywhere |
|
|
27
|
+
| `juno/no-floating-capability` | ⛔ | a capability call used as a statement without `await` |
|
|
28
|
+
| `juno/no-credential-leak` | ⛔ | `ctx.credentials.*` passed to `log`/`console`, put in a finding, or returned directly from a step |
|
|
29
|
+
| `juno/valid-duration` | ⛔ | a duration string that `time.ParseDuration` rejects — `'1d'`, `'10 minutes'`. Checks `sleep`, `after`, `timeout` and `ttl` arguments |
|
|
30
|
+
| `juno/require-effects-in-step` | ⚠️ | a side effect outside a step, **in a handler that already takes a step or suspends**. Reads (`state.get`, `now`, `getState`) are exempt |
|
|
31
|
+
| `juno/require-suspension-label` | ⚠️ | `wait` / `sleep` with no operator-facing label |
|
|
32
|
+
| `juno/prefer-using-for-handles` | ⚠️ | a handle opened in a loop and bound with `const`/`let` but never `cancel()`ed there. It stays open; a run holds at most 100 — use `using` |
|
|
33
|
+
| `juno/no-duplicate-step-id` | ⚠️ | the same literal step ID at two call sites in one handler |
|
|
34
|
+
| `juno/prefer-step-for-clock` | ⚠️ | `now()` / `solar()` outside a step in a handler that suspends |
|
|
35
|
+
| `juno/no-module-state` | ⚠️ | module-scope `let`/`var` written from a handler. It does not persist — the sandbox is a fresh process per dispatch |
|
|
36
36
|
|
|
37
37
|
## Integration rules
|
|
38
38
|
|
package/index.js
CHANGED
|
@@ -339,19 +339,29 @@ function isSuspending(p) {
|
|
|
339
339
|
}
|
|
340
340
|
|
|
341
341
|
/**
|
|
342
|
-
*
|
|
342
|
+
* `<root>.<binding>.<method>` bare or directly on `ctx` — never as the tail of
|
|
343
343
|
* an arbitrary chain, where `this.tasks.x.open` is someone else's. The display
|
|
344
344
|
* name, or null.
|
|
345
345
|
*/
|
|
346
|
-
function
|
|
346
|
+
function bindingCall(p, root, methods) {
|
|
347
347
|
if (!p) return null;
|
|
348
348
|
const q = p.length === 4 && p[0] === 'ctx' ? p.slice(1) : p;
|
|
349
|
-
if (q.length !== 3 || q[0] !==
|
|
349
|
+
if (q.length !== 3 || q[0] !== root || !methods.includes(q[2])) {
|
|
350
350
|
return null;
|
|
351
351
|
}
|
|
352
|
-
return
|
|
352
|
+
return `${root}.${q[1]}.${q[2]}()`;
|
|
353
353
|
}
|
|
354
354
|
|
|
355
|
+
/** `tasks.<binding>.<method>`, bare or on `ctx` (bindingCall). */
|
|
356
|
+
const taskCall = (p, methods) => bindingCall(p, 'tasks', methods);
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* `ongoing.<name>.<method>`, bare or on `ctx` (bindingCall). `boost.end()` on
|
|
360
|
+
* the handle `start()` returned is not matched: the receiver cannot be typed,
|
|
361
|
+
* and a false positive on any `foo.end()` would be an error at deploy.
|
|
362
|
+
*/
|
|
363
|
+
const ongoingCall = (p, methods) => bindingCall(p, 'ongoing', methods);
|
|
364
|
+
|
|
355
365
|
/** Recorded in the journal, so it must not be replayed from inside a step. */
|
|
356
366
|
function journaledKind(p) {
|
|
357
367
|
const step = isStepCall(p);
|
|
@@ -367,6 +377,9 @@ function journaledKind(p) {
|
|
|
367
377
|
// `__task:<n>`: one counter per execution, notify's pattern.
|
|
368
378
|
const open = taskCall(p, ['open']);
|
|
369
379
|
if (open) return open;
|
|
380
|
+
// `__ongoing:<n>`: one counter across start and end and every name.
|
|
381
|
+
const ongoing = ongoingCall(p, ['start', 'end']);
|
|
382
|
+
if (ongoing) return ongoing;
|
|
370
383
|
return null;
|
|
371
384
|
}
|
|
372
385
|
|