@timmo001/oxlint-rules 0.6.0 → 0.6.1

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
@@ -137,8 +137,9 @@ they only run when the consumer enables `typeAware`.
137
137
 
138
138
  - `no-raw-gh`: reports the raw `execute`, `json` and `stream` methods called on
139
139
  a `yield* Gh` binding from `@timmo001/effect-gh`, `Api.raw` from that package,
140
- and any call whose first argument is `"gh"` or an array starting with `"gh"`,
141
- such as `executor.run("gh", ...)` or `Bun.spawn(["gh", ...])`. Use the
140
+ and calls that launch gh: `"gh"` followed by its arguments, such as
141
+ `executor.run("gh", ...)`, or an argument array starting with `"gh"`, such
142
+ as `Bun.spawn(["gh", ...])`. Use the
142
143
  package's typed operations, and add one to effect-gh when a command has none.
143
144
  effect-gh's own relative imports are not reported.
144
145
  - `no-try-catch-in-effect-generators`: diagnoses synchronous `try/catch` owned
package/dist/cli.js CHANGED
@@ -3004,12 +3004,13 @@ function isYieldGh(sourceCode, node) {
3004
3004
  function isGhBinding(sourceCode, identifier) {
3005
3005
  return resolveVariable(sourceCode, identifier)?.defs.some((definition) => definition.type === "Variable" && definition.node.type === "VariableDeclarator" && isYieldGh(sourceCode, definition.node.init)) ?? false;
3006
3006
  }
3007
- function isGhArgument(node) {
3008
- if (node?.type === "Literal")
3009
- return node.value === "gh";
3010
- if (node?.type !== "ArrayExpression")
3007
+ function launchesGh(args) {
3008
+ const [command, argv] = args;
3009
+ if (command?.type === "Literal")
3010
+ return command.value === "gh" && argv !== undefined;
3011
+ if (command?.type !== "ArrayExpression")
3011
3012
  return false;
3012
- const first = node.elements[0];
3013
+ const first = command.elements[0];
3013
3014
  return first?.type === "Literal" && first.value === "gh";
3014
3015
  }
3015
3016
  var noRawGhRule = defineRule24({
@@ -3040,7 +3041,7 @@ var noRawGhRule = defineRule24({
3040
3041
  return;
3041
3042
  }
3042
3043
  }
3043
- if (isGhArgument(node.arguments[0]))
3044
+ if (launchesGh(node.arguments))
3044
3045
  context.report({ node, messageId: "spawnGh" });
3045
3046
  }
3046
3047
  };
@@ -55,12 +55,13 @@ function isYieldGh(sourceCode, node) {
55
55
  function isGhBinding(sourceCode, identifier) {
56
56
  return resolveVariable(sourceCode, identifier)?.defs.some((definition) => definition.type === "Variable" && definition.node.type === "VariableDeclarator" && isYieldGh(sourceCode, definition.node.init)) ?? false;
57
57
  }
58
- function isGhArgument(node) {
59
- if (node?.type === "Literal")
60
- return node.value === "gh";
61
- if (node?.type !== "ArrayExpression")
58
+ function launchesGh(args) {
59
+ const [command, argv] = args;
60
+ if (command?.type === "Literal")
61
+ return command.value === "gh" && argv !== undefined;
62
+ if (command?.type !== "ArrayExpression")
62
63
  return false;
63
- const first = node.elements[0];
64
+ const first = command.elements[0];
64
65
  return first?.type === "Literal" && first.value === "gh";
65
66
  }
66
67
  var noRawGhRule = defineRule({
@@ -91,7 +92,7 @@ var noRawGhRule = defineRule({
91
92
  return;
92
93
  }
93
94
  }
94
- if (isGhArgument(node.arguments[0]))
95
+ if (launchesGh(node.arguments))
95
96
  context.report({ node, messageId: "spawnGh" });
96
97
  }
97
98
  };
@@ -50,12 +50,13 @@ function isYieldGh(sourceCode, node) {
50
50
  function isGhBinding(sourceCode, identifier) {
51
51
  return resolveVariable(sourceCode, identifier)?.defs.some((definition) => definition.type === "Variable" && definition.node.type === "VariableDeclarator" && isYieldGh(sourceCode, definition.node.init)) ?? false;
52
52
  }
53
- function isGhArgument(node) {
54
- if (node?.type === "Literal")
55
- return node.value === "gh";
56
- if (node?.type !== "ArrayExpression")
53
+ function launchesGh(args) {
54
+ const [command, argv] = args;
55
+ if (command?.type === "Literal")
56
+ return command.value === "gh" && argv !== undefined;
57
+ if (command?.type !== "ArrayExpression")
57
58
  return false;
58
- const first = node.elements[0];
59
+ const first = command.elements[0];
59
60
  return first?.type === "Literal" && first.value === "gh";
60
61
  }
61
62
  var noRawGhRule = defineRule({
@@ -86,7 +87,7 @@ var noRawGhRule = defineRule({
86
87
  return;
87
88
  }
88
89
  }
89
- if (isGhArgument(node.arguments[0]))
90
+ if (launchesGh(node.arguments))
90
91
  context.report({ node, messageId: "spawnGh" });
91
92
  }
92
93
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@timmo001/oxlint-rules",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "Shared Oxlint plugins and configs with optional Effect rules.",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -61,11 +61,18 @@ function isGhBinding(
61
61
  );
62
62
  }
63
63
 
64
- function isGhArgument(node: ESTree.Node | undefined): boolean {
65
- if (node?.type === "Literal") return node.value === "gh";
64
+ /**
65
+ * Whether call arguments launch gh: `"gh"` followed by its argv, as in
66
+ * `run("gh", args)`, or an argv array starting with `"gh"`.
67
+ */
68
+ function launchesGh(args: ESTree.CallExpression["arguments"]): boolean {
69
+ const [command, argv] = args;
66
70
 
67
- if (node?.type !== "ArrayExpression") return false;
68
- const first = node.elements[0];
71
+ if (command?.type === "Literal")
72
+ return command.value === "gh" && argv !== undefined;
73
+
74
+ if (command?.type !== "ArrayExpression") return false;
75
+ const first = command.elements[0];
69
76
 
70
77
  return first?.type === "Literal" && first.value === "gh";
71
78
  }
@@ -118,7 +125,7 @@ export const noRawGhRule = defineRule({
118
125
  }
119
126
  }
120
127
 
121
- if (isGhArgument(node.arguments[0]))
128
+ if (launchesGh(node.arguments))
122
129
  context.report({ node, messageId: "spawnGh" });
123
130
  },
124
131
  };