oxlint-plugin-effect 0.2.0 → 0.2.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.
Files changed (256) hide show
  1. package/dist/_virtual/_rolldown/runtime.js +13 -0
  2. package/dist/index.d.ts +4 -0
  3. package/dist/index.js +4 -0
  4. package/dist/plugin.d.ts +5 -0
  5. package/dist/plugin.js +18 -0
  6. package/dist/presets/core.d.ts +43 -0
  7. package/dist/presets/core.js +43 -0
  8. package/dist/presets/effect-native.d.ts +28 -0
  9. package/dist/presets/effect-native.js +28 -0
  10. package/dist/presets/full.d.ts +60 -0
  11. package/dist/presets/full.js +60 -0
  12. package/dist/presets/functional.d.ts +21 -0
  13. package/dist/presets/functional.js +21 -0
  14. package/dist/presets/index.d.ts +13 -0
  15. package/dist/presets/index.js +18 -0
  16. package/dist/presets/strict.d.ts +69 -0
  17. package/dist/presets/strict.js +69 -0
  18. package/dist/presets/v3.d.ts +15 -0
  19. package/dist/presets/v3.js +15 -0
  20. package/dist/rules/_effect-context.d.ts +19 -0
  21. package/dist/rules/_effect-context.js +22 -0
  22. package/dist/rules/index.d.ts +66 -0
  23. package/dist/rules/index.js +124 -0
  24. package/dist/rules/no-arrow-ladder.d.ts +6 -0
  25. package/dist/rules/no-arrow-ladder.js +61 -0
  26. package/dist/rules/no-async-function.d.ts +6 -0
  27. package/dist/rules/no-async-function.js +46 -0
  28. package/dist/rules/no-catch-all-to-map-error.d.ts +6 -0
  29. package/dist/rules/no-catch-all-to-map-error.js +67 -0
  30. package/dist/rules/no-effect-as.d.ts +6 -0
  31. package/dist/rules/no-effect-as.js +16 -0
  32. package/dist/rules/no-effect-async.d.ts +6 -0
  33. package/dist/rules/no-effect-async.js +16 -0
  34. package/dist/rules/no-effect-bind.d.ts +6 -0
  35. package/dist/rules/no-effect-bind.js +16 -0
  36. package/dist/rules/no-effect-do.d.ts +6 -0
  37. package/dist/rules/no-effect-do.js +16 -0
  38. package/dist/rules/no-effect-fn-generator.d.ts +6 -0
  39. package/dist/rules/no-effect-fn-generator.js +30 -0
  40. package/dist/rules/no-effect-gen-adapter.d.ts +6 -0
  41. package/dist/rules/no-effect-gen-adapter.js +30 -0
  42. package/dist/rules/no-effect-map-flatten.d.ts +6 -0
  43. package/dist/rules/no-effect-map-flatten.js +53 -0
  44. package/dist/rules/no-effect-map-void.d.ts +6 -0
  45. package/dist/rules/no-effect-map-void.js +40 -0
  46. package/dist/rules/no-effect-never.d.ts +6 -0
  47. package/dist/rules/no-effect-never.js +16 -0
  48. package/dist/rules/no-effect-orElse-ladder.d.ts +6 -0
  49. package/dist/rules/no-effect-orElse-ladder.js +53 -0
  50. package/dist/rules/no-effect-succeed-string.d.ts +6 -0
  51. package/dist/rules/no-effect-succeed-string.js +30 -0
  52. package/dist/rules/no-effect-succeed-variable.d.ts +6 -0
  53. package/dist/rules/no-effect-succeed-variable.js +30 -0
  54. package/dist/rules/no-effect-succeed-void.d.ts +6 -0
  55. package/dist/rules/no-effect-succeed-void.js +33 -0
  56. package/dist/rules/no-effect-sync-console.d.ts +6 -0
  57. package/dist/rules/no-effect-sync-console.js +63 -0
  58. package/dist/rules/no-effect-sync-wrapper.d.ts +6 -0
  59. package/dist/rules/no-effect-sync-wrapper.js +37 -0
  60. package/dist/rules/no-effect-type-alias.d.ts +6 -0
  61. package/dist/rules/no-effect-type-alias.js +52 -0
  62. package/dist/rules/no-effect-wrapper-alias.d.ts +6 -0
  63. package/dist/rules/no-effect-wrapper-alias.js +69 -0
  64. package/dist/rules/no-extends-native-error.d.ts +6 -0
  65. package/dist/rules/no-extends-native-error.js +41 -0
  66. package/dist/rules/no-flatmap-ladder.d.ts +6 -0
  67. package/dist/rules/no-flatmap-ladder.js +48 -0
  68. package/dist/rules/no-fromnullable-coalesce.d.ts +6 -0
  69. package/dist/rules/no-fromnullable-coalesce.js +36 -0
  70. package/dist/rules/no-global-error-in-catch.d.ts +6 -0
  71. package/dist/rules/no-global-error-in-catch.js +75 -0
  72. package/dist/rules/no-global-error-in-failure.d.ts +6 -0
  73. package/dist/rules/no-global-error-in-failure.js +54 -0
  74. package/dist/rules/no-globals.d.ts +6 -0
  75. package/dist/rules/no-globals.js +164 -0
  76. package/dist/rules/no-if-statement.d.ts +6 -0
  77. package/dist/rules/no-if-statement.js +18 -0
  78. package/dist/rules/no-iife-wrapper.d.ts +6 -0
  79. package/dist/rules/no-iife-wrapper.js +37 -0
  80. package/dist/rules/no-inline-provide.d.ts +6 -0
  81. package/dist/rules/no-inline-provide.js +31 -0
  82. package/dist/rules/no-instanceof-schema.d.ts +6 -0
  83. package/dist/rules/no-instanceof-schema.js +35 -0
  84. package/dist/rules/no-manual-effect-channels.d.ts +6 -0
  85. package/dist/rules/no-manual-effect-channels.js +40 -0
  86. package/dist/rules/no-match-effect-branch.d.ts +6 -0
  87. package/dist/rules/no-match-effect-branch.js +64 -0
  88. package/dist/rules/no-match-void-branch.d.ts +6 -0
  89. package/dist/rules/no-match-void-branch.js +50 -0
  90. package/dist/rules/no-multiple-effect-provide.d.ts +6 -0
  91. package/dist/rules/no-multiple-effect-provide.js +45 -0
  92. package/dist/rules/no-nested-effect-call.d.ts +6 -0
  93. package/dist/rules/no-nested-effect-call.js +97 -0
  94. package/dist/rules/no-nested-effect-gen.d.ts +6 -0
  95. package/dist/rules/no-nested-effect-gen.js +46 -0
  96. package/dist/rules/no-nested-pipe.d.ts +6 -0
  97. package/dist/rules/no-nested-pipe.js +38 -0
  98. package/dist/rules/no-new-error.d.ts +6 -0
  99. package/dist/rules/no-new-error.js +39 -0
  100. package/dist/rules/no-new-promise.d.ts +6 -0
  101. package/dist/rules/no-new-promise.js +38 -0
  102. package/dist/rules/no-node-builtin-import.d.ts +6 -0
  103. package/dist/rules/no-node-builtin-import.js +61 -0
  104. package/dist/rules/no-option-as.d.ts +6 -0
  105. package/dist/rules/no-option-as.js +16 -0
  106. package/dist/rules/no-option-boolean-normalization.d.ts +6 -0
  107. package/dist/rules/no-option-boolean-normalization.js +50 -0
  108. package/dist/rules/no-positional-log-error.d.ts +6 -0
  109. package/dist/rules/no-positional-log-error.js +52 -0
  110. package/dist/rules/no-redundant-schema-tag-identifier.d.ts +6 -0
  111. package/dist/rules/no-redundant-schema-tag-identifier.js +46 -0
  112. package/dist/rules/no-return-in-arrow.d.ts +6 -0
  113. package/dist/rules/no-return-in-arrow.js +41 -0
  114. package/dist/rules/no-return-nullish.d.ts +6 -0
  115. package/dist/rules/no-return-nullish.js +47 -0
  116. package/dist/rules/no-run-in-effect-gen.d.ts +6 -0
  117. package/dist/rules/no-run-in-effect-gen.js +48 -0
  118. package/dist/rules/no-runtime-run-fork.d.ts +6 -0
  119. package/dist/rules/no-runtime-run-fork.js +19 -0
  120. package/dist/rules/no-schema-struct-with-tag.d.ts +6 -0
  121. package/dist/rules/no-schema-struct-with-tag.js +48 -0
  122. package/dist/rules/no-schema-union-of-literals.d.ts +6 -0
  123. package/dist/rules/no-schema-union-of-literals.js +35 -0
  124. package/dist/rules/no-string-sentinel-const.d.ts +6 -0
  125. package/dist/rules/no-string-sentinel-const.js +38 -0
  126. package/dist/rules/no-switch-statement.d.ts +6 -0
  127. package/dist/rules/no-switch-statement.js +16 -0
  128. package/dist/rules/no-ternary.d.ts +6 -0
  129. package/dist/rules/no-ternary.js +30 -0
  130. package/dist/rules/no-throw-statement.d.ts +6 -0
  131. package/dist/rules/no-throw-statement.js +34 -0
  132. package/dist/rules/no-try-catch.d.ts +6 -0
  133. package/dist/rules/no-try-catch.js +34 -0
  134. package/dist/rules/no-unnecessary-arrow-block.d.ts +6 -0
  135. package/dist/rules/no-unnecessary-arrow-block.js +34 -0
  136. package/dist/rules/no-unnecessary-effect-gen.d.ts +6 -0
  137. package/dist/rules/no-unnecessary-effect-gen.js +35 -0
  138. package/dist/rules/no-unnecessary-pipe-chain.d.ts +6 -0
  139. package/dist/rules/no-unnecessary-pipe-chain.js +36 -0
  140. package/dist/rules/no-unnecessary-pipe.d.ts +6 -0
  141. package/dist/rules/no-unnecessary-pipe.js +29 -0
  142. package/dist/vendor/effect-oxlint/AST.d.ts +199 -0
  143. package/dist/vendor/effect-oxlint/AST.js +214 -0
  144. package/dist/vendor/effect-oxlint/Comment.d.ts +55 -0
  145. package/dist/vendor/effect-oxlint/Comment.js +67 -0
  146. package/dist/vendor/effect-oxlint/Diagnostic.d.ts +86 -0
  147. package/dist/vendor/effect-oxlint/Diagnostic.js +115 -0
  148. package/dist/vendor/effect-oxlint/Plugin.d.ts +38 -0
  149. package/dist/vendor/effect-oxlint/Plugin.js +45 -0
  150. package/dist/vendor/effect-oxlint/Rule.d.ts +218 -0
  151. package/dist/vendor/effect-oxlint/Rule.js +309 -0
  152. package/dist/vendor/effect-oxlint/RuleContext.d.ts +77 -0
  153. package/dist/vendor/effect-oxlint/RuleContext.js +74 -0
  154. package/dist/vendor/effect-oxlint/Scope.d.ts +100 -0
  155. package/dist/vendor/effect-oxlint/Scope.js +110 -0
  156. package/dist/vendor/effect-oxlint/SourceCode.d.ts +180 -0
  157. package/dist/vendor/effect-oxlint/SourceCode.js +203 -0
  158. package/dist/vendor/effect-oxlint/Testing.d.ts +510 -0
  159. package/dist/vendor/effect-oxlint/Testing.js +963 -0
  160. package/dist/vendor/effect-oxlint/Token.d.ts +98 -0
  161. package/dist/vendor/effect-oxlint/Token.js +103 -0
  162. package/dist/vendor/effect-oxlint/Visitor.d.ts +166 -0
  163. package/dist/vendor/effect-oxlint/Visitor.js +138 -0
  164. package/dist/vendor/effect-oxlint/index.d.ts +13 -0
  165. package/dist/vendor/effect-oxlint/index.js +12 -0
  166. package/package.json +24 -5
  167. package/.effect-lsp.json +0 -60
  168. package/.oxlintrc.json +0 -33
  169. package/CHANGELOG.md +0 -55
  170. package/scripts/add-rule.ts +0 -87
  171. package/scripts/codegen.ts +0 -108
  172. package/src/index.ts +0 -9
  173. package/src/plugin.ts +0 -16
  174. package/src/presets/core.ts +0 -47
  175. package/src/presets/effect-native.ts +0 -34
  176. package/src/presets/full.ts +0 -70
  177. package/src/presets/functional.ts +0 -18
  178. package/src/presets/index.ts +0 -5
  179. package/src/presets/strict.ts +0 -77
  180. package/src/rules/_effect-context.ts +0 -28
  181. package/src/rules/index.ts +0 -72
  182. package/src/rules/no-arrow-ladder.ts +0 -70
  183. package/src/rules/no-async-function.ts +0 -47
  184. package/src/rules/no-catch-all-to-map-error.ts +0 -90
  185. package/src/rules/no-effect-as.ts +0 -14
  186. package/src/rules/no-effect-async.ts +0 -14
  187. package/src/rules/no-effect-bind.ts +0 -13
  188. package/src/rules/no-effect-do.ts +0 -14
  189. package/src/rules/no-effect-fn-generator.ts +0 -58
  190. package/src/rules/no-effect-gen-adapter.ts +0 -51
  191. package/src/rules/no-effect-map-flatten.ts +0 -82
  192. package/src/rules/no-effect-map-void.ts +0 -80
  193. package/src/rules/no-effect-never.ts +0 -14
  194. package/src/rules/no-effect-orElse-ladder.ts +0 -79
  195. package/src/rules/no-effect-succeed-string.ts +0 -52
  196. package/src/rules/no-effect-succeed-variable.ts +0 -50
  197. package/src/rules/no-effect-succeed-void.ts +0 -63
  198. package/src/rules/no-effect-sync-console.ts +0 -91
  199. package/src/rules/no-effect-sync-wrapper.ts +0 -67
  200. package/src/rules/no-effect-type-alias.ts +0 -71
  201. package/src/rules/no-effect-wrapper-alias.ts +0 -95
  202. package/src/rules/no-extends-native-error.ts +0 -54
  203. package/src/rules/no-flatmap-ladder.ts +0 -77
  204. package/src/rules/no-fromnullable-coalesce.ts +0 -62
  205. package/src/rules/no-global-error-in-catch.ts +0 -104
  206. package/src/rules/no-global-error-in-failure.ts +0 -83
  207. package/src/rules/no-globals.ts +0 -178
  208. package/src/rules/no-if-statement.ts +0 -16
  209. package/src/rules/no-iife-wrapper.ts +0 -51
  210. package/src/rules/no-inline-provide.ts +0 -41
  211. package/src/rules/no-instanceof-schema.ts +0 -42
  212. package/src/rules/no-manual-effect-channels.ts +0 -58
  213. package/src/rules/no-match-effect-branch.ts +0 -82
  214. package/src/rules/no-match-void-branch.ts +0 -72
  215. package/src/rules/no-multiple-effect-provide.ts +0 -75
  216. package/src/rules/no-nested-effect-call.ts +0 -57
  217. package/src/rules/no-nested-effect-gen.ts +0 -43
  218. package/src/rules/no-nested-pipe.ts +0 -73
  219. package/src/rules/no-new-error.ts +0 -53
  220. package/src/rules/no-new-promise.ts +0 -50
  221. package/src/rules/no-node-builtin-import.ts +0 -68
  222. package/src/rules/no-option-as.ts +0 -13
  223. package/src/rules/no-option-boolean-normalization.ts +0 -88
  224. package/src/rules/no-positional-log-error.ts +0 -76
  225. package/src/rules/no-redundant-schema-tag-identifier.ts +0 -62
  226. package/src/rules/no-return-in-arrow.ts +0 -76
  227. package/src/rules/no-return-nullish.ts +0 -80
  228. package/src/rules/no-run-in-effect-gen.ts +0 -66
  229. package/src/rules/no-runtime-run-fork.ts +0 -14
  230. package/src/rules/no-schema-struct-with-tag.ts +0 -64
  231. package/src/rules/no-schema-union-of-literals.ts +0 -48
  232. package/src/rules/no-string-sentinel-const.ts +0 -49
  233. package/src/rules/no-switch-statement.ts +0 -13
  234. package/src/rules/no-ternary.ts +0 -30
  235. package/src/rules/no-throw-statement.ts +0 -39
  236. package/src/rules/no-try-catch.ts +0 -39
  237. package/src/rules/no-unnecessary-arrow-block.ts +0 -51
  238. package/src/rules/no-unnecessary-effect-gen.ts +0 -83
  239. package/src/rules/no-unnecessary-pipe-chain.ts +0 -47
  240. package/src/rules/no-unnecessary-pipe.ts +0 -45
  241. package/src/vendor/effect-oxlint/AST.ts +0 -516
  242. package/src/vendor/effect-oxlint/Comment.ts +0 -86
  243. package/src/vendor/effect-oxlint/Diagnostic.ts +0 -199
  244. package/src/vendor/effect-oxlint/Plugin.ts +0 -71
  245. package/src/vendor/effect-oxlint/Rule.ts +0 -548
  246. package/src/vendor/effect-oxlint/RuleContext.ts +0 -144
  247. package/src/vendor/effect-oxlint/Scope.ts +0 -177
  248. package/src/vendor/effect-oxlint/SourceCode.ts +0 -377
  249. package/src/vendor/effect-oxlint/Testing.ts +0 -1227
  250. package/src/vendor/effect-oxlint/Token.ts +0 -131
  251. package/src/vendor/effect-oxlint/Visitor.ts +0 -287
  252. package/src/vendor/effect-oxlint/index.ts +0 -88
  253. package/tests/ban-rules.test.ts +0 -68
  254. package/tests/context-rules.test.ts +0 -263
  255. package/tests/pattern-rules.test.ts +0 -247
  256. package/tsconfig.json +0 -15
@@ -0,0 +1,510 @@
1
+ import { RuleContext } from "./RuleContext.js";
2
+ import * as Option from "effect/Option";
3
+ import * as Effect from "effect/Effect";
4
+ import * as Layer from "effect/Layer";
5
+ import { Comment, Context, CreateRule, Diagnostic, ESTree, Scope, Token, Variable } from "@oxlint/plugins";
6
+
7
+ //#region src/vendor/effect-oxlint/Testing.d.ts
8
+ declare namespace Testing_d_exports {
9
+ export { MockContextOptions, ReportedDiagnostic, arrowFn, astNode, binaryExpr, blockStmt, boolLiteral, callExpr, callOfMember, chainedMemberExpr, classDecl, comment, computedMemberExpr, createMockContext, doWhileStmt, expectDiagnostics, expectNoDiagnostics, exportNamedDecl, exprStmt, forInStmt, forOfStmt, forStmt, id, ifStmt, importDecl, importDeclWithSpecifiers, importNamespaceSpecifier, importSpecifier, interfaceDecl, memberExpr, messageIds, messages, methodDef, mockRuleContextLayer, newExpr, numLiteral, objectExpr, objectExprLiteralKeys, objectExprWithSpread, program, propertyDef, returnStmt, runRule, runRuleMulti, scope, strLiteral, switchStmt, throwStmt, token, tryStmt, tsAsExpr, tsTypeLiteral, tsTypeRef, tsUnionType, typeAliasDecl, unaryExpr, varDecl, varDeclarator, variable, whileStmt, withMockRuleContext, withParentChain, yieldExpr };
10
+ }
11
+ /**
12
+ * Minimal AST node builders for tests.
13
+ *
14
+ * These produce mock objects satisfying the type shapes that AST/Visitor/Rule
15
+ * modules expect. They use boundary casts at the seam between test mock
16
+ * data and oxlint's strict branded types.
17
+ *
18
+ * @since 0.2.0
19
+ */
20
+ /**
21
+ * Identifier: `{ type: "Identifier", name }`
22
+ *
23
+ * @since 0.2.0
24
+ */
25
+ declare const id: (name: string) => ESTree.IdentifierName;
26
+ /**
27
+ * MemberExpression: `obj.prop` (non-computed)
28
+ *
29
+ * @since 0.2.0
30
+ */
31
+ declare const memberExpr: (obj: string, prop: string) => ESTree.MemberExpression;
32
+ /**
33
+ * MemberExpression: `obj[prop]` (computed)
34
+ *
35
+ * @since 0.2.0
36
+ */
37
+ declare const computedMemberExpr: (obj: string, prop: string) => ESTree.MemberExpression;
38
+ /**
39
+ * Chained MemberExpression: `a.b.c` (non-computed)
40
+ *
41
+ * @since 0.2.0
42
+ */
43
+ declare const chainedMemberExpr: (...names: readonly [string, string, ...ReadonlyArray<string>]) => ESTree.MemberExpression;
44
+ /**
45
+ * CallExpression with bare identifier callee: `name(args)`
46
+ *
47
+ * @since 0.2.0
48
+ */
49
+ declare const callExpr: (name: string, args?: ReadonlyArray<unknown>) => ESTree.CallExpression;
50
+ /**
51
+ * CallExpression with MemberExpression callee: `obj.prop(args)`
52
+ *
53
+ * @since 0.2.0
54
+ */
55
+ declare const callOfMember: (obj: string, prop: string, args?: ReadonlyArray<unknown>) => ESTree.CallExpression;
56
+ /**
57
+ * ImportDeclaration: `import ... from "source"`
58
+ *
59
+ * @since 0.2.0
60
+ */
61
+ declare const importDecl: (source: string) => ESTree.ImportDeclaration;
62
+ /**
63
+ * String literal: `{ type: "Literal", value }`
64
+ *
65
+ * @since 0.2.0
66
+ */
67
+ declare const strLiteral: (value: string) => ESTree.StringLiteral;
68
+ /**
69
+ * Numeric literal: `{ type: "Literal", value }`
70
+ *
71
+ * @since 0.2.0
72
+ */
73
+ declare const numLiteral: (value: number) => ESTree.NumericLiteral;
74
+ /**
75
+ * Boolean literal: `{ type: "Literal", value }`
76
+ *
77
+ * @since 0.2.0
78
+ */
79
+ declare const boolLiteral: (value: boolean) => ESTree.BooleanLiteral;
80
+ /**
81
+ * ObjectExpression with identifier-keyed properties.
82
+ *
83
+ * @since 0.2.0
84
+ */
85
+ declare const objectExpr: (properties: ReadonlyArray<{
86
+ readonly key: string;
87
+ readonly value?: unknown;
88
+ }>) => ESTree.ObjectExpression;
89
+ /**
90
+ * ObjectExpression with string literal keys.
91
+ *
92
+ * @since 0.2.0
93
+ */
94
+ declare const objectExprLiteralKeys: (properties: ReadonlyArray<{
95
+ readonly key: string;
96
+ readonly value?: unknown;
97
+ }>) => ESTree.ObjectExpression;
98
+ /**
99
+ * ObjectExpression with a SpreadElement.
100
+ *
101
+ * @since 0.2.0
102
+ */
103
+ declare const objectExprWithSpread: (spreadArg: unknown) => ESTree.ObjectExpression;
104
+ /**
105
+ * ThrowStatement.
106
+ *
107
+ * @since 0.2.0
108
+ */
109
+ declare const throwStmt: () => ESTree.ThrowStatement;
110
+ /**
111
+ * TryStatement.
112
+ *
113
+ * @since 0.2.0
114
+ */
115
+ declare const tryStmt: () => ESTree.Node;
116
+ /**
117
+ * ReturnStatement.
118
+ *
119
+ * @since 0.2.0
120
+ */
121
+ declare const returnStmt: (argument?: unknown) => ESTree.ReturnStatement;
122
+ /**
123
+ * BlockStatement.
124
+ *
125
+ * @since 0.2.0
126
+ */
127
+ declare const blockStmt: (body?: ReadonlyArray<unknown>) => ESTree.BlockStatement;
128
+ /**
129
+ * ArrowFunctionExpression.
130
+ *
131
+ * @since 0.2.0
132
+ */
133
+ declare const arrowFn: (body?: unknown, params?: ReadonlyArray<unknown>) => ESTree.ArrowFunctionExpression;
134
+ /**
135
+ * VariableDeclaration: `const/let/var name = init`
136
+ *
137
+ * @since 0.2.0
138
+ */
139
+ declare const varDecl: (kind: "const" | "let" | "var", name: string, init?: unknown) => ESTree.VariableDeclaration;
140
+ /**
141
+ * ExpressionStatement.
142
+ *
143
+ * @since 0.2.0
144
+ */
145
+ declare const exprStmt: (expression: unknown) => ESTree.ExpressionStatement;
146
+ /**
147
+ * Program node.
148
+ *
149
+ * @since 0.2.0
150
+ */
151
+ declare const program: (body?: ReadonlyArray<unknown>, comments?: ReadonlyArray<unknown>) => ESTree.Program;
152
+ /**
153
+ * IfStatement.
154
+ *
155
+ * All parameters are optional — `ifStmt()` produces a minimal
156
+ * `{ type: 'IfStatement' }` node suitable for enter/exit tracking.
157
+ *
158
+ * @since 0.2.0
159
+ */
160
+ declare const ifStmt: (test?: unknown, consequent?: unknown, alternate?: unknown) => ESTree.IfStatement;
161
+ /**
162
+ * BinaryExpression.
163
+ *
164
+ * @since 0.2.0
165
+ */
166
+ declare const binaryExpr: (operator: string, left: unknown, right: unknown) => ESTree.BinaryExpression;
167
+ /**
168
+ * NewExpression: `new callee(args)`
169
+ *
170
+ * When `callee` is a string it is auto-wrapped in `id()`, so
171
+ * `newExpr('Date')` is equivalent to `newExpr(id('Date'))`.
172
+ *
173
+ * @since 0.2.0
174
+ */
175
+ declare const newExpr: {
176
+ (callee: string, args?: ReadonlyArray<unknown>): ESTree.NewExpression;
177
+ (callee: unknown, args?: ReadonlyArray<unknown>): ESTree.NewExpression;
178
+ };
179
+ /**
180
+ * A generic AST node with type and optional parent pointer.
181
+ *
182
+ * @since 0.2.0
183
+ */
184
+ declare const astNode: (type: string, parent?: {
185
+ readonly type: string;
186
+ readonly parent?: unknown;
187
+ }) => {
188
+ readonly type: string;
189
+ readonly parent?: unknown;
190
+ };
191
+ /**
192
+ * Build a parent chain from outermost → innermost.
193
+ *
194
+ * Returns the innermost node with `.parent` links to each ancestor.
195
+ *
196
+ * @example
197
+ * ```ts
198
+ * // Creates: FunctionDeclaration → BlockStatement → ThrowStatement
199
+ * withParentChain('FunctionDeclaration', 'BlockStatement', 'ThrowStatement')
200
+ * ```
201
+ *
202
+ * @since 0.2.0
203
+ */
204
+ declare const withParentChain: (first: string, ...rest: ReadonlyArray<string>) => {
205
+ readonly type: string;
206
+ readonly parent?: unknown;
207
+ };
208
+ /**
209
+ * Mock Token.
210
+ *
211
+ * @since 0.2.0
212
+ */
213
+ declare const token: (type: Token["type"], value: string) => Token;
214
+ /**
215
+ * Mock Comment.
216
+ *
217
+ * @since 0.2.0
218
+ */
219
+ declare const comment: (type: Comment["type"], value: string) => Comment;
220
+ /**
221
+ * Mock Scope with minimal surface.
222
+ *
223
+ * @since 0.2.0
224
+ */
225
+ declare const scope: (opts?: {
226
+ readonly type?: Scope["type"];
227
+ readonly isStrict?: boolean;
228
+ readonly variables?: ReadonlyArray<Variable>;
229
+ readonly upper?: Scope | null;
230
+ }) => Scope;
231
+ /**
232
+ * Mock Variable.
233
+ *
234
+ * @since 0.2.0
235
+ */
236
+ declare const variable: (name: string, opts?: {
237
+ readonly references?: ReadonlyArray<{
238
+ readonly isRead: () => boolean;
239
+ readonly isWrite: () => boolean;
240
+ readonly isReadOnly: () => boolean;
241
+ readonly isWriteOnly: () => boolean;
242
+ readonly isReadWrite: () => boolean;
243
+ }>;
244
+ }) => Variable;
245
+ /**
246
+ * SwitchStatement.
247
+ *
248
+ * @since 0.2.0
249
+ */
250
+ declare const switchStmt: () => ESTree.SwitchStatement;
251
+ /**
252
+ * ForStatement.
253
+ *
254
+ * @since 0.2.0
255
+ */
256
+ declare const forStmt: () => ESTree.ForStatement;
257
+ /**
258
+ * ForInStatement.
259
+ *
260
+ * @since 0.2.0
261
+ */
262
+ declare const forInStmt: () => ESTree.ForInStatement;
263
+ /**
264
+ * ForOfStatement.
265
+ *
266
+ * @since 0.2.0
267
+ */
268
+ declare const forOfStmt: () => ESTree.ForOfStatement;
269
+ /**
270
+ * WhileStatement.
271
+ *
272
+ * @since 0.2.0
273
+ */
274
+ declare const whileStmt: () => ESTree.WhileStatement;
275
+ /**
276
+ * DoWhileStatement.
277
+ *
278
+ * @since 0.2.0
279
+ */
280
+ declare const doWhileStmt: () => ESTree.DoWhileStatement;
281
+ /**
282
+ * YieldExpression.
283
+ *
284
+ * @since 0.2.0
285
+ */
286
+ declare const yieldExpr: (argument?: unknown, delegate?: boolean) => ESTree.YieldExpression;
287
+ /**
288
+ * UnaryExpression: `operator argument`
289
+ *
290
+ * @since 0.2.0
291
+ */
292
+ declare const unaryExpr: (operator: string, argument: unknown) => ESTree.UnaryExpression;
293
+ /**
294
+ * VariableDeclarator (standalone, without wrapping VariableDeclaration).
295
+ *
296
+ * @since 0.2.0
297
+ */
298
+ declare const varDeclarator: (name: string, init?: unknown) => ESTree.VariableDeclarator;
299
+ /**
300
+ * ExportNamedDeclaration.
301
+ *
302
+ * @since 0.2.0
303
+ */
304
+ declare const exportNamedDecl: (declaration?: unknown) => ESTree.ExportNamedDeclaration;
305
+ /**
306
+ * ImportDeclaration with specifiers: `import { a, b } from "source"`
307
+ *
308
+ * @since 0.2.0
309
+ */
310
+ declare const importDeclWithSpecifiers: (source: string, specifiers: ReadonlyArray<unknown>, importKind?: string) => ESTree.ImportDeclaration;
311
+ /**
312
+ * ImportSpecifier: `{ imported as local }`
313
+ *
314
+ * @since 0.2.0
315
+ */
316
+ declare const importSpecifier: (imported: string, local?: string, importKind?: string) => ESTree.ImportSpecifier;
317
+ /**
318
+ * ImportNamespaceSpecifier: `* as local`
319
+ *
320
+ * @since 0.2.0
321
+ */
322
+ declare const importNamespaceSpecifier: (local: string) => ESTree.ImportNamespaceSpecifier;
323
+ /**
324
+ * TSAsExpression: `expr as Type`
325
+ *
326
+ * @since 0.2.0
327
+ */
328
+ declare const tsAsExpr: (typeKind: string, parent?: {
329
+ readonly type: string;
330
+ readonly parent?: unknown;
331
+ }) => ESTree.TSAsExpression;
332
+ /**
333
+ * TSUnionType: `A | B | C`
334
+ *
335
+ * @since 0.2.0
336
+ */
337
+ declare const tsUnionType: (typeKinds: ReadonlyArray<string>) => ESTree.TSUnionType;
338
+ /**
339
+ * TSTypeReference: `TypeName`
340
+ *
341
+ * @since 0.2.0
342
+ */
343
+ declare const tsTypeRef: (name: string) => ESTree.TSTypeReference;
344
+ /**
345
+ * TSTypeLiteral: `{ ... }` with N members.
346
+ *
347
+ * @since 0.2.0
348
+ */
349
+ declare const tsTypeLiteral: (memberCount: number) => ESTree.TSTypeLiteral;
350
+ /**
351
+ * TSInterfaceDeclaration: `interface Name { }`
352
+ *
353
+ * @since 0.2.0
354
+ */
355
+ declare const interfaceDecl: (name: string) => ESTree.TSInterfaceDeclaration;
356
+ /**
357
+ * TSTypeAliasDeclaration: `type Name = ...`
358
+ *
359
+ * @since 0.2.0
360
+ */
361
+ declare const typeAliasDecl: (name: string) => ESTree.TSTypeAliasDeclaration;
362
+ /**
363
+ * ClassDeclaration with optional superClass and body members.
364
+ *
365
+ * @example
366
+ * ```ts
367
+ * // Simple: class Foo {}
368
+ * classDecl('Foo')
369
+ *
370
+ * // With super: class Foo extends Bar {}
371
+ * classDecl('Foo', { superClass: Testing.id('Bar') })
372
+ *
373
+ * // With members: class Foo { x; static y() {} }
374
+ * classDecl('Foo', {
375
+ * members: [Testing.propertyDef('x'), Testing.methodDef('y', true)]
376
+ * })
377
+ * ```
378
+ *
379
+ * @since 0.2.0
380
+ */
381
+ declare const classDecl: (name: string, opts?: {
382
+ readonly superClass?: unknown;
383
+ readonly members?: ReadonlyArray<unknown>;
384
+ }) => ESTree.Class;
385
+ /**
386
+ * PropertyDefinition: class field.
387
+ *
388
+ * @since 0.2.0
389
+ */
390
+ declare const propertyDef: (name: string, isStatic?: boolean) => ESTree.PropertyDefinition;
391
+ /**
392
+ * MethodDefinition: class method.
393
+ *
394
+ * @since 0.2.0
395
+ */
396
+ declare const methodDef: (name: string, isStatic?: boolean) => ESTree.MethodDefinition;
397
+ /**
398
+ * A collected diagnostic from the mock context's `report`.
399
+ *
400
+ * @since 0.2.0
401
+ */
402
+ interface ReportedDiagnostic {
403
+ readonly diagnostic: Diagnostic;
404
+ }
405
+ /**
406
+ * Options for creating a mock oxlint Context.
407
+ *
408
+ * @since 0.2.0
409
+ */
410
+ interface MockContextOptions {
411
+ readonly filename?: string;
412
+ readonly cwd?: string;
413
+ readonly options?: ReadonlyArray<unknown>;
414
+ readonly sourceText?: string;
415
+ readonly comments?: ReadonlyArray<Comment>;
416
+ }
417
+ /**
418
+ * Create a mock oxlint `Context` and a diagnostics collector.
419
+ *
420
+ * The mock provides the minimal surface required by `RuleContext.fromOxlintContext`.
421
+ *
422
+ * @since 0.2.0
423
+ */
424
+ declare const createMockContext: (opts?: MockContextOptions) => {
425
+ readonly context: Context;
426
+ readonly diagnostics: ReportedDiagnostic[];
427
+ };
428
+ /**
429
+ * Create a `Layer` that provides a mock `RuleContext` service.
430
+ *
431
+ * Use in `it.effect` tests that need to `yield*` visitor handlers
432
+ * (which carry `RuleContext` in their context type).
433
+ *
434
+ * @since 0.2.0
435
+ */
436
+ declare const mockRuleContextLayer: (opts?: MockContextOptions) => Layer.Layer<RuleContext>;
437
+ /**
438
+ * Provide a mock `RuleContext` to an effect for testing.
439
+ *
440
+ * @since 0.2.0
441
+ */
442
+ declare const withMockRuleContext: <A, E>(effect: Effect.Effect<A, E, RuleContext>, opts?: MockContextOptions) => Effect.Effect<A, E>;
443
+ /**
444
+ * Run a rule with a single visitor event and collect diagnostics.
445
+ *
446
+ * @since 0.2.0
447
+ */
448
+ declare const runRule: (rule: CreateRule, visitor: string, visitorNode: unknown, opts?: MockContextOptions) => ReadonlyArray<ReportedDiagnostic>;
449
+ /**
450
+ * Run a rule with multiple visitor/node events sequentially.
451
+ *
452
+ * Same context is shared so `Ref` state persists across calls.
453
+ *
454
+ * @since 0.2.0
455
+ */
456
+ declare const runRuleMulti: (rule: CreateRule, pairs: ReadonlyArray<readonly [visitor: string, node: unknown]>, opts?: MockContextOptions) => ReadonlyArray<ReportedDiagnostic>;
457
+ /**
458
+ * Extract the diagnostic messages from a result array.
459
+ *
460
+ * Returns `Option.none()` when a diagnostic uses `messageId` instead
461
+ * of `message`, or when the message is `null`.
462
+ *
463
+ * @example
464
+ * ```ts
465
+ * import * as Option from 'effect/Option'
466
+ *
467
+ * const result = Testing.runRule(rule, 'ThrowStatement', Testing.throwStmt())
468
+ * expect(Testing.messages(result)).toEqual([Option.some('Use Effect.fail instead')])
469
+ * ```
470
+ *
471
+ * @since 0.2.0
472
+ */
473
+ declare const messages: (result: ReadonlyArray<ReportedDiagnostic>) => ReadonlyArray<Option.Option<string>>;
474
+ /**
475
+ * Extract the diagnostic messageIds from a result array.
476
+ *
477
+ * Returns `Option.none()` when a diagnostic uses `message` instead
478
+ * of `messageId`, or when the messageId is `null`.
479
+ *
480
+ * @since 0.2.0
481
+ */
482
+ declare const messageIds: (result: ReadonlyArray<ReportedDiagnostic>) => ReadonlyArray<Option.Option<string>>;
483
+ /**
484
+ * Assert that diagnostics match expected patterns.
485
+ *
486
+ * Each matcher is partially checked — only provided fields are compared.
487
+ * This allows flexible matching without specifying every field.
488
+ *
489
+ * @example
490
+ * ```ts
491
+ * Testing.expectDiagnostics(result, [
492
+ * { message: 'No throw in Effect.gen' },
493
+ * { messageId: 'noTryCatch' }
494
+ * ])
495
+ * ```
496
+ *
497
+ * @since 0.2.0
498
+ */
499
+ declare const expectDiagnostics: (result: ReadonlyArray<ReportedDiagnostic>, expected: ReadonlyArray<{
500
+ readonly message?: string;
501
+ readonly messageId?: string;
502
+ }>) => void;
503
+ /**
504
+ * Assert that no diagnostics were reported.
505
+ *
506
+ * @since 0.2.0
507
+ */
508
+ declare const expectNoDiagnostics: (result: ReadonlyArray<ReportedDiagnostic>) => void;
509
+ //#endregion
510
+ export { MockContextOptions, ReportedDiagnostic, Testing_d_exports, arrowFn, astNode, binaryExpr, blockStmt, boolLiteral, callExpr, callOfMember, chainedMemberExpr, classDecl, comment, computedMemberExpr, createMockContext, doWhileStmt, expectDiagnostics, expectNoDiagnostics, exportNamedDecl, exprStmt, forInStmt, forOfStmt, forStmt, id, ifStmt, importDecl, importDeclWithSpecifiers, importNamespaceSpecifier, importSpecifier, interfaceDecl, memberExpr, messageIds, messages, methodDef, mockRuleContextLayer, newExpr, numLiteral, objectExpr, objectExprLiteralKeys, objectExprWithSpread, program, propertyDef, returnStmt, runRule, runRuleMulti, scope, strLiteral, switchStmt, throwStmt, token, tryStmt, tsAsExpr, tsTypeLiteral, tsTypeRef, tsUnionType, typeAliasDecl, unaryExpr, varDecl, varDeclarator, variable, whileStmt, withMockRuleContext, withParentChain, yieldExpr };