oxlint-plugin-effect 0.2.0 → 0.2.2

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 (258) 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 +14 -0
  15. package/dist/presets/index.js +20 -0
  16. package/dist/presets/strict.d.ts +64 -0
  17. package/dist/presets/strict.js +64 -0
  18. package/dist/presets/v3-strict.d.ts +16 -0
  19. package/dist/presets/v3-strict.js +16 -0
  20. package/dist/presets/v3.d.ts +18 -0
  21. package/dist/presets/v3.js +18 -0
  22. package/dist/rules/_effect-context.d.ts +19 -0
  23. package/dist/rules/_effect-context.js +22 -0
  24. package/dist/rules/index.d.ts +66 -0
  25. package/dist/rules/index.js +124 -0
  26. package/dist/rules/no-arrow-ladder.d.ts +6 -0
  27. package/dist/rules/no-arrow-ladder.js +61 -0
  28. package/dist/rules/no-async-function.d.ts +6 -0
  29. package/dist/rules/no-async-function.js +46 -0
  30. package/dist/rules/no-catch-all-to-map-error.d.ts +6 -0
  31. package/dist/rules/no-catch-all-to-map-error.js +67 -0
  32. package/dist/rules/no-effect-as.d.ts +6 -0
  33. package/dist/rules/no-effect-as.js +16 -0
  34. package/dist/rules/no-effect-async.d.ts +6 -0
  35. package/dist/rules/no-effect-async.js +16 -0
  36. package/dist/rules/no-effect-bind.d.ts +6 -0
  37. package/dist/rules/no-effect-bind.js +16 -0
  38. package/dist/rules/no-effect-do.d.ts +6 -0
  39. package/dist/rules/no-effect-do.js +16 -0
  40. package/dist/rules/no-effect-fn-generator.d.ts +6 -0
  41. package/dist/rules/no-effect-fn-generator.js +30 -0
  42. package/dist/rules/no-effect-gen-adapter.d.ts +6 -0
  43. package/dist/rules/no-effect-gen-adapter.js +30 -0
  44. package/dist/rules/no-effect-map-flatten.d.ts +6 -0
  45. package/dist/rules/no-effect-map-flatten.js +53 -0
  46. package/dist/rules/no-effect-map-void.d.ts +6 -0
  47. package/dist/rules/no-effect-map-void.js +40 -0
  48. package/dist/rules/no-effect-never.d.ts +6 -0
  49. package/dist/rules/no-effect-never.js +16 -0
  50. package/dist/rules/no-effect-orElse-ladder.d.ts +6 -0
  51. package/dist/rules/no-effect-orElse-ladder.js +53 -0
  52. package/dist/rules/no-effect-succeed-string.d.ts +6 -0
  53. package/dist/rules/no-effect-succeed-string.js +30 -0
  54. package/dist/rules/no-effect-succeed-variable.d.ts +6 -0
  55. package/dist/rules/no-effect-succeed-variable.js +30 -0
  56. package/dist/rules/no-effect-succeed-void.d.ts +6 -0
  57. package/dist/rules/no-effect-succeed-void.js +33 -0
  58. package/dist/rules/no-effect-sync-console.d.ts +6 -0
  59. package/dist/rules/no-effect-sync-console.js +63 -0
  60. package/dist/rules/no-effect-sync-wrapper.d.ts +6 -0
  61. package/dist/rules/no-effect-sync-wrapper.js +37 -0
  62. package/dist/rules/no-effect-type-alias.d.ts +6 -0
  63. package/dist/rules/no-effect-type-alias.js +52 -0
  64. package/dist/rules/no-effect-wrapper-alias.d.ts +6 -0
  65. package/dist/rules/no-effect-wrapper-alias.js +69 -0
  66. package/dist/rules/no-extends-native-error.d.ts +6 -0
  67. package/dist/rules/no-extends-native-error.js +41 -0
  68. package/dist/rules/no-flatmap-ladder.d.ts +6 -0
  69. package/dist/rules/no-flatmap-ladder.js +48 -0
  70. package/dist/rules/no-fromnullable-coalesce.d.ts +6 -0
  71. package/dist/rules/no-fromnullable-coalesce.js +36 -0
  72. package/dist/rules/no-global-error-in-catch.d.ts +6 -0
  73. package/dist/rules/no-global-error-in-catch.js +75 -0
  74. package/dist/rules/no-global-error-in-failure.d.ts +6 -0
  75. package/dist/rules/no-global-error-in-failure.js +54 -0
  76. package/dist/rules/no-globals.d.ts +6 -0
  77. package/dist/rules/no-globals.js +164 -0
  78. package/dist/rules/no-if-statement.d.ts +6 -0
  79. package/dist/rules/no-if-statement.js +18 -0
  80. package/dist/rules/no-iife-wrapper.d.ts +6 -0
  81. package/dist/rules/no-iife-wrapper.js +37 -0
  82. package/dist/rules/no-inline-provide.d.ts +6 -0
  83. package/dist/rules/no-inline-provide.js +31 -0
  84. package/dist/rules/no-instanceof-schema.d.ts +6 -0
  85. package/dist/rules/no-instanceof-schema.js +35 -0
  86. package/dist/rules/no-manual-effect-channels.d.ts +6 -0
  87. package/dist/rules/no-manual-effect-channels.js +40 -0
  88. package/dist/rules/no-match-effect-branch.d.ts +6 -0
  89. package/dist/rules/no-match-effect-branch.js +64 -0
  90. package/dist/rules/no-match-void-branch.d.ts +6 -0
  91. package/dist/rules/no-match-void-branch.js +50 -0
  92. package/dist/rules/no-multiple-effect-provide.d.ts +6 -0
  93. package/dist/rules/no-multiple-effect-provide.js +45 -0
  94. package/dist/rules/no-nested-effect-call.d.ts +6 -0
  95. package/dist/rules/no-nested-effect-call.js +97 -0
  96. package/dist/rules/no-nested-effect-gen.d.ts +6 -0
  97. package/dist/rules/no-nested-effect-gen.js +46 -0
  98. package/dist/rules/no-nested-pipe.d.ts +6 -0
  99. package/dist/rules/no-nested-pipe.js +38 -0
  100. package/dist/rules/no-new-error.d.ts +6 -0
  101. package/dist/rules/no-new-error.js +39 -0
  102. package/dist/rules/no-new-promise.d.ts +6 -0
  103. package/dist/rules/no-new-promise.js +38 -0
  104. package/dist/rules/no-node-builtin-import.d.ts +6 -0
  105. package/dist/rules/no-node-builtin-import.js +61 -0
  106. package/dist/rules/no-option-as.d.ts +6 -0
  107. package/dist/rules/no-option-as.js +16 -0
  108. package/dist/rules/no-option-boolean-normalization.d.ts +6 -0
  109. package/dist/rules/no-option-boolean-normalization.js +50 -0
  110. package/dist/rules/no-positional-log-error.d.ts +6 -0
  111. package/dist/rules/no-positional-log-error.js +52 -0
  112. package/dist/rules/no-redundant-schema-tag-identifier.d.ts +6 -0
  113. package/dist/rules/no-redundant-schema-tag-identifier.js +46 -0
  114. package/dist/rules/no-return-in-arrow.d.ts +6 -0
  115. package/dist/rules/no-return-in-arrow.js +41 -0
  116. package/dist/rules/no-return-nullish.d.ts +6 -0
  117. package/dist/rules/no-return-nullish.js +47 -0
  118. package/dist/rules/no-run-in-effect-gen.d.ts +6 -0
  119. package/dist/rules/no-run-in-effect-gen.js +48 -0
  120. package/dist/rules/no-runtime-run-fork.d.ts +6 -0
  121. package/dist/rules/no-runtime-run-fork.js +19 -0
  122. package/dist/rules/no-schema-struct-with-tag.d.ts +6 -0
  123. package/dist/rules/no-schema-struct-with-tag.js +48 -0
  124. package/dist/rules/no-schema-union-of-literals.d.ts +6 -0
  125. package/dist/rules/no-schema-union-of-literals.js +35 -0
  126. package/dist/rules/no-string-sentinel-const.d.ts +6 -0
  127. package/dist/rules/no-string-sentinel-const.js +38 -0
  128. package/dist/rules/no-switch-statement.d.ts +6 -0
  129. package/dist/rules/no-switch-statement.js +16 -0
  130. package/dist/rules/no-ternary.d.ts +6 -0
  131. package/dist/rules/no-ternary.js +30 -0
  132. package/dist/rules/no-throw-statement.d.ts +6 -0
  133. package/dist/rules/no-throw-statement.js +34 -0
  134. package/dist/rules/no-try-catch.d.ts +6 -0
  135. package/dist/rules/no-try-catch.js +34 -0
  136. package/dist/rules/no-unnecessary-arrow-block.d.ts +6 -0
  137. package/dist/rules/no-unnecessary-arrow-block.js +34 -0
  138. package/dist/rules/no-unnecessary-effect-gen.d.ts +6 -0
  139. package/dist/rules/no-unnecessary-effect-gen.js +35 -0
  140. package/dist/rules/no-unnecessary-pipe-chain.d.ts +6 -0
  141. package/dist/rules/no-unnecessary-pipe-chain.js +36 -0
  142. package/dist/rules/no-unnecessary-pipe.d.ts +6 -0
  143. package/dist/rules/no-unnecessary-pipe.js +29 -0
  144. package/dist/vendor/effect-oxlint/AST.d.ts +199 -0
  145. package/dist/vendor/effect-oxlint/AST.js +214 -0
  146. package/dist/vendor/effect-oxlint/Comment.d.ts +55 -0
  147. package/dist/vendor/effect-oxlint/Comment.js +67 -0
  148. package/dist/vendor/effect-oxlint/Diagnostic.d.ts +86 -0
  149. package/dist/vendor/effect-oxlint/Diagnostic.js +115 -0
  150. package/dist/vendor/effect-oxlint/Plugin.d.ts +38 -0
  151. package/dist/vendor/effect-oxlint/Plugin.js +45 -0
  152. package/dist/vendor/effect-oxlint/Rule.d.ts +218 -0
  153. package/dist/vendor/effect-oxlint/Rule.js +309 -0
  154. package/dist/vendor/effect-oxlint/RuleContext.d.ts +77 -0
  155. package/dist/vendor/effect-oxlint/RuleContext.js +74 -0
  156. package/dist/vendor/effect-oxlint/Scope.d.ts +100 -0
  157. package/dist/vendor/effect-oxlint/Scope.js +110 -0
  158. package/dist/vendor/effect-oxlint/SourceCode.d.ts +180 -0
  159. package/dist/vendor/effect-oxlint/SourceCode.js +203 -0
  160. package/dist/vendor/effect-oxlint/Testing.d.ts +510 -0
  161. package/dist/vendor/effect-oxlint/Testing.js +963 -0
  162. package/dist/vendor/effect-oxlint/Token.d.ts +98 -0
  163. package/dist/vendor/effect-oxlint/Token.js +103 -0
  164. package/dist/vendor/effect-oxlint/Visitor.d.ts +166 -0
  165. package/dist/vendor/effect-oxlint/Visitor.js +138 -0
  166. package/dist/vendor/effect-oxlint/index.d.ts +13 -0
  167. package/dist/vendor/effect-oxlint/index.js +12 -0
  168. package/package.json +24 -5
  169. package/.effect-lsp.json +0 -60
  170. package/.oxlintrc.json +0 -33
  171. package/CHANGELOG.md +0 -55
  172. package/scripts/add-rule.ts +0 -87
  173. package/scripts/codegen.ts +0 -108
  174. package/src/index.ts +0 -9
  175. package/src/plugin.ts +0 -16
  176. package/src/presets/core.ts +0 -47
  177. package/src/presets/effect-native.ts +0 -34
  178. package/src/presets/full.ts +0 -70
  179. package/src/presets/functional.ts +0 -18
  180. package/src/presets/index.ts +0 -5
  181. package/src/presets/strict.ts +0 -77
  182. package/src/rules/_effect-context.ts +0 -28
  183. package/src/rules/index.ts +0 -72
  184. package/src/rules/no-arrow-ladder.ts +0 -70
  185. package/src/rules/no-async-function.ts +0 -47
  186. package/src/rules/no-catch-all-to-map-error.ts +0 -90
  187. package/src/rules/no-effect-as.ts +0 -14
  188. package/src/rules/no-effect-async.ts +0 -14
  189. package/src/rules/no-effect-bind.ts +0 -13
  190. package/src/rules/no-effect-do.ts +0 -14
  191. package/src/rules/no-effect-fn-generator.ts +0 -58
  192. package/src/rules/no-effect-gen-adapter.ts +0 -51
  193. package/src/rules/no-effect-map-flatten.ts +0 -82
  194. package/src/rules/no-effect-map-void.ts +0 -80
  195. package/src/rules/no-effect-never.ts +0 -14
  196. package/src/rules/no-effect-orElse-ladder.ts +0 -79
  197. package/src/rules/no-effect-succeed-string.ts +0 -52
  198. package/src/rules/no-effect-succeed-variable.ts +0 -50
  199. package/src/rules/no-effect-succeed-void.ts +0 -63
  200. package/src/rules/no-effect-sync-console.ts +0 -91
  201. package/src/rules/no-effect-sync-wrapper.ts +0 -67
  202. package/src/rules/no-effect-type-alias.ts +0 -71
  203. package/src/rules/no-effect-wrapper-alias.ts +0 -95
  204. package/src/rules/no-extends-native-error.ts +0 -54
  205. package/src/rules/no-flatmap-ladder.ts +0 -77
  206. package/src/rules/no-fromnullable-coalesce.ts +0 -62
  207. package/src/rules/no-global-error-in-catch.ts +0 -104
  208. package/src/rules/no-global-error-in-failure.ts +0 -83
  209. package/src/rules/no-globals.ts +0 -178
  210. package/src/rules/no-if-statement.ts +0 -16
  211. package/src/rules/no-iife-wrapper.ts +0 -51
  212. package/src/rules/no-inline-provide.ts +0 -41
  213. package/src/rules/no-instanceof-schema.ts +0 -42
  214. package/src/rules/no-manual-effect-channels.ts +0 -58
  215. package/src/rules/no-match-effect-branch.ts +0 -82
  216. package/src/rules/no-match-void-branch.ts +0 -72
  217. package/src/rules/no-multiple-effect-provide.ts +0 -75
  218. package/src/rules/no-nested-effect-call.ts +0 -57
  219. package/src/rules/no-nested-effect-gen.ts +0 -43
  220. package/src/rules/no-nested-pipe.ts +0 -73
  221. package/src/rules/no-new-error.ts +0 -53
  222. package/src/rules/no-new-promise.ts +0 -50
  223. package/src/rules/no-node-builtin-import.ts +0 -68
  224. package/src/rules/no-option-as.ts +0 -13
  225. package/src/rules/no-option-boolean-normalization.ts +0 -88
  226. package/src/rules/no-positional-log-error.ts +0 -76
  227. package/src/rules/no-redundant-schema-tag-identifier.ts +0 -62
  228. package/src/rules/no-return-in-arrow.ts +0 -76
  229. package/src/rules/no-return-nullish.ts +0 -80
  230. package/src/rules/no-run-in-effect-gen.ts +0 -66
  231. package/src/rules/no-runtime-run-fork.ts +0 -14
  232. package/src/rules/no-schema-struct-with-tag.ts +0 -64
  233. package/src/rules/no-schema-union-of-literals.ts +0 -48
  234. package/src/rules/no-string-sentinel-const.ts +0 -49
  235. package/src/rules/no-switch-statement.ts +0 -13
  236. package/src/rules/no-ternary.ts +0 -30
  237. package/src/rules/no-throw-statement.ts +0 -39
  238. package/src/rules/no-try-catch.ts +0 -39
  239. package/src/rules/no-unnecessary-arrow-block.ts +0 -51
  240. package/src/rules/no-unnecessary-effect-gen.ts +0 -83
  241. package/src/rules/no-unnecessary-pipe-chain.ts +0 -47
  242. package/src/rules/no-unnecessary-pipe.ts +0 -45
  243. package/src/vendor/effect-oxlint/AST.ts +0 -516
  244. package/src/vendor/effect-oxlint/Comment.ts +0 -86
  245. package/src/vendor/effect-oxlint/Diagnostic.ts +0 -199
  246. package/src/vendor/effect-oxlint/Plugin.ts +0 -71
  247. package/src/vendor/effect-oxlint/Rule.ts +0 -548
  248. package/src/vendor/effect-oxlint/RuleContext.ts +0 -144
  249. package/src/vendor/effect-oxlint/Scope.ts +0 -177
  250. package/src/vendor/effect-oxlint/SourceCode.ts +0 -377
  251. package/src/vendor/effect-oxlint/Testing.ts +0 -1227
  252. package/src/vendor/effect-oxlint/Token.ts +0 -131
  253. package/src/vendor/effect-oxlint/Visitor.ts +0 -287
  254. package/src/vendor/effect-oxlint/index.ts +0 -88
  255. package/tests/ban-rules.test.ts +0 -68
  256. package/tests/context-rules.test.ts +0 -263
  257. package/tests/pattern-rules.test.ts +0 -247
  258. package/tsconfig.json +0 -15
@@ -1,263 +0,0 @@
1
- import { describe, test, expect } from "bun:test"
2
- import { Testing } from "../src/vendor/effect-oxlint/index.js"
3
- import {
4
- noGlobals,
5
- noThrowStatement,
6
- noTryCatch,
7
- noNewPromise,
8
- noNewError,
9
- noReturnNullish,
10
- noRunInEffectGen,
11
- } from "../src/rules/index.js"
12
-
13
- // Helper: simulate entering and exiting Effect.gen context
14
- const effectGenNode = Testing.callOfMember("Effect", "gen", [])
15
-
16
- // --- Global Effect-enforcing rules (fire everywhere) ---
17
-
18
- describe("noThrowStatement", () => {
19
- test("reports throw", () => {
20
- const result = Testing.runRule(noThrowStatement, "ThrowStatement", Testing.throwStmt())
21
- expect(result.length).toBe(1)
22
- })
23
- })
24
-
25
- describe("noTryCatch", () => {
26
- test("reports try/catch", () => {
27
- const result = Testing.runRule(noTryCatch, "TryStatement", Testing.tryStmt())
28
- expect(result.length).toBe(1)
29
- })
30
- })
31
-
32
- describe("noNewPromise", () => {
33
- test("reports new Promise()", () => {
34
- const result = Testing.runRule(noNewPromise, "NewExpression", Testing.newExpr("Promise"))
35
- expect(result.length).toBe(1)
36
- })
37
- })
38
-
39
- describe("noNewError", () => {
40
- test("reports new Error()", () => {
41
- const result = Testing.runRule(noNewError, "NewExpression", Testing.newExpr("Error"))
42
- expect(result.length).toBe(1)
43
- })
44
-
45
- test("reports new TypeError()", () => {
46
- const result = Testing.runRule(noNewError, "NewExpression", Testing.newExpr("TypeError"))
47
- expect(result.length).toBe(1)
48
- })
49
-
50
- test("ignores new MyError()", () => {
51
- const result = Testing.runRule(noNewError, "NewExpression", Testing.newExpr("MyError"))
52
- Testing.expectNoDiagnostics(result)
53
- })
54
- })
55
-
56
- describe("noReturnNullish", () => {
57
- test("reports return null", () => {
58
- const node = {
59
- type: "ReturnStatement",
60
- argument: { type: "Literal", value: null },
61
- } as never
62
- const result = Testing.runRule(noReturnNullish, "ReturnStatement", node)
63
- expect(result.length).toBe(1)
64
- })
65
-
66
- test("reports return undefined", () => {
67
- const node = {
68
- type: "ReturnStatement",
69
- argument: { type: "Identifier", name: "undefined" },
70
- } as never
71
- const result = Testing.runRule(noReturnNullish, "ReturnStatement", node)
72
- expect(result.length).toBe(1)
73
- })
74
- })
75
-
76
- // --- Effect-context rules (inside Effect.gen/fn only) ---
77
-
78
- describe("noGlobals", () => {
79
- test("reports console.log inside Effect.gen", () => {
80
- const result = Testing.runRuleMulti(noGlobals, [
81
- ["CallExpression", effectGenNode],
82
- ["MemberExpression", Testing.memberExpr("console", "log")],
83
- ["CallExpression:exit", effectGenNode],
84
- ])
85
- expect(result.length).toBe(1)
86
- })
87
-
88
- test("reports fetch() inside Effect.gen", () => {
89
- const result = Testing.runRuleMulti(noGlobals, [
90
- ["CallExpression", effectGenNode],
91
- ["CallExpression", Testing.callExpr("fetch")],
92
- ["CallExpression:exit", effectGenNode],
93
- ])
94
- expect(result.length).toBe(1)
95
- })
96
-
97
- test("reports Date.now inside Effect.gen", () => {
98
- const result = Testing.runRuleMulti(noGlobals, [
99
- ["CallExpression", effectGenNode],
100
- ["MemberExpression", Testing.memberExpr("Date", "now")],
101
- ["CallExpression:exit", effectGenNode],
102
- ])
103
- expect(result.length).toBe(1)
104
- })
105
-
106
- test("reports new Date() inside Effect.gen", () => {
107
- const result = Testing.runRuleMulti(noGlobals, [
108
- ["CallExpression", effectGenNode],
109
- ["NewExpression", Testing.newExpr("Date")],
110
- ["CallExpression:exit", effectGenNode],
111
- ])
112
- expect(result.length).toBe(1)
113
- })
114
-
115
- test("reports Math.random inside Effect.gen", () => {
116
- const result = Testing.runRuleMulti(noGlobals, [
117
- ["CallExpression", effectGenNode],
118
- ["MemberExpression", Testing.memberExpr("Math", "random")],
119
- ["CallExpression:exit", effectGenNode],
120
- ])
121
- expect(result.length).toBe(1)
122
- })
123
-
124
- test("reports setTimeout inside Effect.gen", () => {
125
- const result = Testing.runRuleMulti(noGlobals, [
126
- ["CallExpression", effectGenNode],
127
- ["CallExpression", Testing.callExpr("setTimeout")],
128
- ["CallExpression:exit", effectGenNode],
129
- ])
130
- expect(result.length).toBe(1)
131
- })
132
-
133
- test("reports JSON.parse inside Effect.gen", () => {
134
- const result = Testing.runRuleMulti(noGlobals, [
135
- ["CallExpression", effectGenNode],
136
- ["MemberExpression", Testing.memberExpr("JSON", "parse")],
137
- ["CallExpression:exit", effectGenNode],
138
- ])
139
- expect(result.length).toBe(1)
140
- })
141
-
142
- test("reports process.env inside Effect.gen", () => {
143
- const result = Testing.runRuleMulti(noGlobals, [
144
- ["CallExpression", effectGenNode],
145
- ["MemberExpression", Testing.memberExpr("process", "env")],
146
- ["CallExpression:exit", effectGenNode],
147
- ])
148
- expect(result.length).toBe(1)
149
- })
150
-
151
- test("reports process.exit with hint", () => {
152
- const result = Testing.runRuleMulti(noGlobals, [
153
- ["CallExpression", effectGenNode],
154
- ["MemberExpression", Testing.memberExpr("process", "exit")],
155
- ["CallExpression:exit", effectGenNode],
156
- ])
157
- Testing.expectDiagnostics(result, [{
158
- message: "Avoid process.exit inside Effect context. Use Effect.fail or Effect.die.",
159
- }])
160
- })
161
-
162
- test("reports Bun.file with FileSystem hint", () => {
163
- const result = Testing.runRuleMulti(noGlobals, [
164
- ["CallExpression", effectGenNode],
165
- ["MemberExpression", Testing.memberExpr("Bun", "file")],
166
- ["CallExpression:exit", effectGenNode],
167
- ])
168
- Testing.expectDiagnostics(result, [{
169
- message: "Avoid Bun.file inside Effect context. Use FileSystem from 'effect'.",
170
- }])
171
- })
172
-
173
- test("reports Deno.readFile with FileSystem hint", () => {
174
- const result = Testing.runRuleMulti(noGlobals, [
175
- ["CallExpression", effectGenNode],
176
- ["MemberExpression", Testing.memberExpr("Deno", "readFile")],
177
- ["CallExpression:exit", effectGenNode],
178
- ])
179
- Testing.expectDiagnostics(result, [{
180
- message: "Avoid Deno.readFile inside Effect context. Use FileSystem from 'effect'.",
181
- }])
182
- })
183
-
184
- test("ignores console.log outside Effect.gen", () => {
185
- const result = Testing.runRuleMulti(noGlobals, [
186
- ["MemberExpression", Testing.memberExpr("console", "log")],
187
- ])
188
- Testing.expectNoDiagnostics(result)
189
- })
190
-
191
- test("ignores Effect.succeed inside Effect.gen", () => {
192
- const result = Testing.runRuleMulti(noGlobals, [
193
- ["CallExpression", effectGenNode],
194
- ["MemberExpression", Testing.memberExpr("Effect", "succeed")],
195
- ["CallExpression:exit", effectGenNode],
196
- ])
197
- Testing.expectNoDiagnostics(result)
198
- })
199
- })
200
-
201
- describe("noRunInEffectGen", () => {
202
- test("reports Effect.runPromise inside Effect.gen", () => {
203
- const result = Testing.runRuleMulti(noRunInEffectGen, [
204
- ["CallExpression", effectGenNode],
205
- ["CallExpression", Testing.callOfMember("Effect", "runPromise", [Testing.id("x")])],
206
- ["CallExpression:exit", effectGenNode],
207
- ])
208
- expect(result.length).toBe(1)
209
- })
210
-
211
- test("reports Effect.runFork inside Effect.fn", () => {
212
- const effectFnNode = Testing.callOfMember("Effect", "fn", [])
213
- const result = Testing.runRuleMulti(noRunInEffectGen, [
214
- ["CallExpression", effectFnNode],
215
- ["CallExpression", Testing.callOfMember("Effect", "runFork", [Testing.id("x")])],
216
- ["CallExpression:exit", effectFnNode],
217
- ])
218
- expect(result.length).toBe(1)
219
- })
220
-
221
- test("reports Runtime.runFork inside Effect.gen", () => {
222
- const result = Testing.runRuleMulti(noRunInEffectGen, [
223
- ["CallExpression", effectGenNode],
224
- ["CallExpression", Testing.callOfMember("Runtime", "runFork", [Testing.id("x")])],
225
- ["CallExpression:exit", effectGenNode],
226
- ])
227
- expect(result.length).toBe(1)
228
- })
229
-
230
- test("ignores Effect.runForkWith inside Effect.gen (legit v4 callback boundary)", () => {
231
- const result = Testing.runRuleMulti(noRunInEffectGen, [
232
- ["CallExpression", effectGenNode],
233
- ["CallExpression", Testing.callOfMember("Effect", "runForkWith", [Testing.id("services")])],
234
- ["CallExpression:exit", effectGenNode],
235
- ])
236
- Testing.expectNoDiagnostics(result)
237
- })
238
-
239
- test("ignores managedRuntime.runFork on identifier callee", () => {
240
- const result = Testing.runRuleMulti(noRunInEffectGen, [
241
- ["CallExpression", effectGenNode],
242
- ["CallExpression", Testing.callOfMember("managedRuntime", "runFork", [Testing.id("x")])],
243
- ["CallExpression:exit", effectGenNode],
244
- ])
245
- Testing.expectNoDiagnostics(result)
246
- })
247
-
248
- test("ignores Effect.runPromise outside Effect.gen", () => {
249
- const result = Testing.runRuleMulti(noRunInEffectGen, [
250
- ["CallExpression", Testing.callOfMember("Effect", "runPromise", [Testing.id("x")])],
251
- ])
252
- Testing.expectNoDiagnostics(result)
253
- })
254
-
255
- test("ignores yield* child effect inside Effect.gen", () => {
256
- const result = Testing.runRuleMulti(noRunInEffectGen, [
257
- ["CallExpression", effectGenNode],
258
- ["CallExpression", Testing.callOfMember("Effect", "succeed", [Testing.id("x")])],
259
- ["CallExpression:exit", effectGenNode],
260
- ])
261
- Testing.expectNoDiagnostics(result)
262
- })
263
- })
@@ -1,247 +0,0 @@
1
- import { describe, test, expect } from "bun:test"
2
- import { Testing } from "../src/vendor/effect-oxlint/index.js"
3
- import {
4
- noUnnecessaryPipe,
5
- noEffectSucceedVoid,
6
- noEffectMapVoid,
7
- noEffectFnGenerator,
8
- noExtendsNativeError,
9
- noIifeWrapper,
10
- noEffectSucceedString,
11
- noFromNullableCoalesce,
12
- noInstanceofSchema,
13
- noNestedPipe,
14
- noNestedEffectCall,
15
- noPositionalLogError,
16
- } from "../src/rules/index.js"
17
-
18
- describe("noUnnecessaryPipe", () => {
19
- test("reports pipe(x) with single arg", () => {
20
- const node = Testing.callExpr("pipe", [Testing.id("myEffect")])
21
- const result = Testing.runRule(noUnnecessaryPipe, "CallExpression", node)
22
- expect(result.length).toBe(1)
23
- })
24
-
25
- test("ignores pipe(x, f)", () => {
26
- const node = Testing.callExpr("pipe", [Testing.id("myEffect"), Testing.id("mapFn")])
27
- const result = Testing.runRule(noUnnecessaryPipe, "CallExpression", node)
28
- Testing.expectNoDiagnostics(result)
29
- })
30
- })
31
-
32
- describe("noEffectSucceedVoid", () => {
33
- test("reports Effect.succeed(undefined)", () => {
34
- const node = Testing.callOfMember("Effect", "succeed", [Testing.id("undefined")])
35
- const result = Testing.runRule(noEffectSucceedVoid, "CallExpression", node)
36
- expect(result.length).toBe(1)
37
- })
38
-
39
- test("ignores Effect.succeed(42)", () => {
40
- const node = Testing.callOfMember("Effect", "succeed", [Testing.numLiteral(42)])
41
- const result = Testing.runRule(noEffectSucceedVoid, "CallExpression", node)
42
- Testing.expectNoDiagnostics(result)
43
- })
44
- })
45
-
46
- describe("noEffectMapVoid", () => {
47
- test("reports Effect.map(() => undefined)", () => {
48
- const fn = Testing.arrowFn(Testing.id("undefined"))
49
- const node = Testing.callOfMember("Effect", "map", [fn])
50
- const result = Testing.runRule(noEffectMapVoid, "CallExpression", node)
51
- expect(result.length).toBe(1)
52
- })
53
-
54
- test("reports Effect.map(() => {})", () => {
55
- const fn = Testing.arrowFn(Testing.blockStmt([]))
56
- const node = Testing.callOfMember("Effect", "map", [fn])
57
- const result = Testing.runRule(noEffectMapVoid, "CallExpression", node)
58
- expect(result.length).toBe(1)
59
- })
60
- })
61
-
62
- describe("noEffectFnGenerator", () => {
63
- test("reports Effect.fn(function*() {})", () => {
64
- const gen = {
65
- type: "FunctionExpression",
66
- generator: true,
67
- params: [],
68
- body: Testing.blockStmt([]),
69
- }
70
- const node = Testing.callOfMember("Effect", "fn", [gen])
71
- const result = Testing.runRule(noEffectFnGenerator, "CallExpression", node)
72
- expect(result.length).toBe(1)
73
- })
74
-
75
- test("ignores Effect.fn('name')", () => {
76
- const node = Testing.callOfMember("Effect", "fn", [Testing.strLiteral("myFn")])
77
- const result = Testing.runRule(noEffectFnGenerator, "CallExpression", node)
78
- Testing.expectNoDiagnostics(result)
79
- })
80
- })
81
-
82
- describe("noExtendsNativeError", () => {
83
- test("reports class extends Error", () => {
84
- const node = {
85
- type: "ClassDeclaration",
86
- superClass: Testing.id("Error"),
87
- id: Testing.id("MyError"),
88
- body: { type: "ClassBody", body: [] },
89
- } as never
90
- const result = Testing.runRule(noExtendsNativeError, "ClassDeclaration", node)
91
- expect(result.length).toBe(1)
92
- })
93
-
94
- test("ignores class extends Schema.TaggedErrorClass", () => {
95
- const node = {
96
- type: "ClassDeclaration",
97
- superClass: Testing.memberExpr("Schema", "TaggedErrorClass"),
98
- id: Testing.id("MyError"),
99
- body: { type: "ClassBody", body: [] },
100
- } as never
101
- const result = Testing.runRule(noExtendsNativeError, "ClassDeclaration", node)
102
- Testing.expectNoDiagnostics(result)
103
- })
104
- })
105
-
106
- describe("noIifeWrapper", () => {
107
- test("reports (() => expr)()", () => {
108
- const node = {
109
- type: "CallExpression",
110
- callee: Testing.arrowFn(Testing.id("x")),
111
- arguments: [],
112
- } as never
113
- const result = Testing.runRule(noIifeWrapper, "CallExpression", node)
114
- expect(result.length).toBe(1)
115
- })
116
-
117
- test("ignores normal calls", () => {
118
- const result = Testing.runRule(noIifeWrapper, "CallExpression", Testing.callExpr("myFn"))
119
- Testing.expectNoDiagnostics(result)
120
- })
121
- })
122
-
123
- describe("noEffectSucceedString", () => {
124
- test("reports Effect.succeed('done')", () => {
125
- const node = Testing.callOfMember("Effect", "succeed", [Testing.strLiteral("done")])
126
- const result = Testing.runRule(noEffectSucceedString, "CallExpression", node)
127
- expect(result.length).toBe(1)
128
- })
129
-
130
- test("ignores Effect.succeed(42)", () => {
131
- const node = Testing.callOfMember("Effect", "succeed", [Testing.numLiteral(42)])
132
- const result = Testing.runRule(noEffectSucceedString, "CallExpression", node)
133
- Testing.expectNoDiagnostics(result)
134
- })
135
- })
136
-
137
- describe("noFromNullableCoalesce", () => {
138
- test("reports Option.fromNullable(x ?? null)", () => {
139
- const coalesce = {
140
- type: "LogicalExpression",
141
- operator: "??",
142
- left: Testing.id("x"),
143
- right: { type: "Literal", value: null },
144
- }
145
- const node = Testing.callOfMember("Option", "fromNullable", [coalesce])
146
- const result = Testing.runRule(noFromNullableCoalesce, "CallExpression", node)
147
- expect(result.length).toBe(1)
148
- })
149
-
150
- test("ignores Option.fromNullable(x)", () => {
151
- const node = Testing.callOfMember("Option", "fromNullable", [Testing.id("x")])
152
- const result = Testing.runRule(noFromNullableCoalesce, "CallExpression", node)
153
- Testing.expectNoDiagnostics(result)
154
- })
155
- })
156
-
157
- describe("noInstanceofSchema", () => {
158
- test("reports instanceof check", () => {
159
- const node = {
160
- type: "BinaryExpression",
161
- operator: "instanceof",
162
- left: Testing.id("x"),
163
- right: Testing.id("MySchema"),
164
- } as never
165
- const result = Testing.runRule(noInstanceofSchema, "BinaryExpression", node)
166
- expect(result.length).toBe(1)
167
- })
168
-
169
- test("ignores === check", () => {
170
- const node = {
171
- type: "BinaryExpression",
172
- operator: "===",
173
- left: Testing.id("x"),
174
- right: Testing.id("y"),
175
- } as never
176
- const result = Testing.runRule(noInstanceofSchema, "BinaryExpression", node)
177
- Testing.expectNoDiagnostics(result)
178
- })
179
- })
180
-
181
- describe("noNestedPipe", () => {
182
- test("reports pipe(pipe(x, f), g)", () => {
183
- const innerPipe = Testing.callExpr("pipe", [Testing.id("x"), Testing.id("f")])
184
- const outerPipe = Testing.callExpr("pipe", [innerPipe, Testing.id("g")])
185
- const result = Testing.runRule(noNestedPipe, "CallExpression", outerPipe)
186
- expect(result.length).toBe(1)
187
- })
188
-
189
- test("ignores flat pipe(x, f, g)", () => {
190
- const node = Testing.callExpr("pipe", [Testing.id("x"), Testing.id("f"), Testing.id("g")])
191
- const result = Testing.runRule(noNestedPipe, "CallExpression", node)
192
- Testing.expectNoDiagnostics(result)
193
- })
194
- })
195
-
196
- describe("noNestedEffectCall", () => {
197
- test("reports Effect.map(Effect.flatMap(...))", () => {
198
- const inner = Testing.callOfMember("Effect", "flatMap", [Testing.id("x")])
199
- const outer = Testing.callOfMember("Effect", "map", [inner])
200
- const result = Testing.runRule(noNestedEffectCall, "CallExpression", outer)
201
- expect(result.length).toBe(1)
202
- })
203
-
204
- test("ignores flat Effect.map(x)", () => {
205
- const node = Testing.callOfMember("Effect", "map", [Testing.id("x")])
206
- const result = Testing.runRule(noNestedEffectCall, "CallExpression", node)
207
- Testing.expectNoDiagnostics(result)
208
- })
209
- })
210
-
211
- describe("noPositionalLogError", () => {
212
- test("reports Effect.logWarning with two args", () => {
213
- const node = Testing.callOfMember("Effect", "logWarning", [
214
- Testing.strLiteral("something failed"),
215
- Testing.id("error"),
216
- ])
217
- const result = Testing.runRule(noPositionalLogError, "CallExpression", node)
218
- expect(result.length).toBe(1)
219
- })
220
-
221
- test("reports Effect.logError with two args", () => {
222
- const node = Testing.callOfMember("Effect", "logError", [
223
- Testing.strLiteral("fatal"),
224
- Testing.id("err"),
225
- ])
226
- const result = Testing.runRule(noPositionalLogError, "CallExpression", node)
227
- expect(result.length).toBe(1)
228
- })
229
-
230
- test("ignores Effect.log with single arg", () => {
231
- const node = Testing.callOfMember("Effect", "log", [
232
- Testing.strLiteral("hello"),
233
- ])
234
- const result = Testing.runRule(noPositionalLogError, "CallExpression", node)
235
- Testing.expectNoDiagnostics(result)
236
- })
237
-
238
- test("allows Cause as second arg", () => {
239
- const causeArg = Testing.callOfMember("Cause", "fail", [Testing.id("error")])
240
- const node = Testing.callOfMember("Effect", "logWarning", [
241
- Testing.strLiteral("something failed"),
242
- causeArg,
243
- ])
244
- const result = Testing.runRule(noPositionalLogError, "CallExpression", node)
245
- Testing.expectNoDiagnostics(result)
246
- })
247
- })
package/tsconfig.json DELETED
@@ -1,15 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "noUncheckedIndexedAccess": true,
4
- "noFallthroughCasesInSwitch": true,
5
- "noImplicitOverride": true,
6
- "noPropertyAccessFromIndexSignature": true,
7
- "allowImportingTsExtensions": true,
8
- "moduleDetection": "force",
9
- "skipLibCheck": true,
10
- "types": ["bun"],
11
- "noEmit": true
12
- },
13
- "include": ["src/**/*.ts", "tests/**/*.ts"],
14
- "exclude": ["node_modules"]
15
- }