@junoflow/eslint-plugin 0.3.0 → 0.9.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 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.
@@ -76,6 +80,7 @@ import juno from '@junoflow/eslint-plugin';
76
80
 
77
81
  juno.configs.flow; // the flow rules, by severity
78
82
  juno.configs.integration; // the integration rules
83
+ juno.configs.app; // the app handler rules
79
84
  juno.configs.bundle; // what may run against esbuild output
80
85
  ```
81
86
 
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
 
@@ -973,7 +990,7 @@ const noEventCast = {
973
990
  // see the *source*, where it is still an import statement. Same rule, same
974
991
  // message, both ends.
975
992
  const MESSAGE =
976
- "Must not import from juno:sdk — it is the runtime shim, not a types package. A flow's types are ambient globals from flow-api.d.ts; an integration imports its own types/integration-env.d.ts";
993
+ 'Must not import from juno:sdk — it is the runtime shim, not a types package. A flow imports its types from types/flow-env.d.ts, an integration from types/integration-env.d.ts';
977
994
 
978
995
  const noJunoSdkImport = {
979
996
  meta: {
@@ -1165,6 +1182,7 @@ module.exports = {
1165
1182
  configs: {
1166
1183
  flow: rulesets.flow,
1167
1184
  integration: rulesets.integration,
1185
+ app: rulesets.app,
1168
1186
  bundle: rulesets.bundle,
1169
1187
  },
1170
1188
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@junoflow/eslint-plugin",
3
- "version": "0.3.0",
3
+ "version": "0.9.0",
4
4
  "description": "ESLint rules for Juno flows and integrations",
5
5
  "license": "MIT",
6
6
  "repository": {
package/rulesets.json CHANGED
@@ -23,6 +23,12 @@
23
23
  "juno/no-process-exit": "error",
24
24
  "juno/require-signal-in-listener": "warn"
25
25
  },
26
+ "app": {
27
+ "juno/no-juno-sdk-import": "error",
28
+ "juno/no-credential-leak": "error",
29
+ "juno/no-process-exit": "error",
30
+ "juno/no-module-state": "warn"
31
+ },
26
32
  "bundle": {
27
33
  "juno/no-juno-sdk-import": "error"
28
34
  }