@junoflow/eslint-plugin 0.3.0 → 0.6.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.
Files changed (3) hide show
  1. package/README.md +4 -0
  2. package/index.js +17 -0
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -59,6 +59,10 @@ run again from the top. Anything effectful left outside a step happens again on
59
59
  that pass. That transition is the gate, and it is why the rule fires on a
60
60
  handler that suspends even when it takes no step at all.
61
61
 
62
+ A control's `press()` and `extend()` count as effects — each call is one more
63
+ press, one more extension — while `activate()` and `release()` do not: they name
64
+ the end state, so a replay lands where the first call did.
65
+
62
66
  It stays at warning level because it is the rule most likely to misjudge correct
63
67
  code, and Juno runs these rules on deploy: at warning level a misjudgement costs
64
68
  an author a message rather than a release.
package/index.js CHANGED
@@ -213,6 +213,17 @@ function isTargetCall(p) {
213
213
  return !!p && p.length >= 3 && p[p.length - 3] === 'targets';
214
214
  }
215
215
 
216
+ // The four verbs a control handle carries. Which of them a given handle has
217
+ // follows from the control's type, but the verb alone says what it does.
218
+ const CONTROL_METHODS = ['press', 'activate', 'extend', 'release'];
219
+
220
+ /** `controls.<binding>.<verb>()` — the verb, or null. */
221
+ function isControlCall(p) {
222
+ if (!p || p.length < 3) return null;
223
+ const [obj, method] = [p[p.length - 3], p[p.length - 1]];
224
+ return obj === 'controls' && CONTROL_METHODS.includes(method) ? method : null;
225
+ }
226
+
216
227
  /** A flow target's invoke()/invokeAll(): a target call that suspends. */
217
228
  function isFlowInvoke(p) {
218
229
  if (!isTargetCall(p)) return null;
@@ -269,6 +280,10 @@ function isCapabilityCall(p) {
269
280
  * suspension, which is usually the opposite of what the author wants. When one
270
281
  * of them must be stable, `prefer-step-for-clock` says so at warning level
271
282
  * rather than this rule saying it at error level.
283
+ *
284
+ * Of a control's verbs only `press` and `extend` are here: each call is one
285
+ * more press, one more extension. `activate` and `release` name the end state,
286
+ * so a replay lands where the first call did, and they are left alone.
272
287
  */
273
288
  function isRepeatedEffect(p) {
274
289
  if (isTargetCall(p)) {
@@ -277,6 +292,8 @@ function isRepeatedEffect(p) {
277
292
  }
278
293
  const state = isStateCall(p);
279
294
  if (state) return state !== 'get' && state !== 'scoped';
295
+ const control = isControlCall(p);
296
+ if (control) return control === 'press' || control === 'extend';
280
297
  return isFetch(p) || isLog(p);
281
298
  }
282
299
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@junoflow/eslint-plugin",
3
- "version": "0.3.0",
3
+ "version": "0.6.0",
4
4
  "description": "ESLint rules for Juno flows and integrations",
5
5
  "license": "MIT",
6
6
  "repository": {