oxlint-plugin-effect 0.1.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 -37
  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 -89
  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 -50
  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.ts +0 -18
  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 -528
  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 -85
  254. package/tests/context-rules.test.ts +0 -198
  255. package/tests/pattern-rules.test.ts +0 -247
  256. package/tsconfig.json +0 -15
@@ -1,198 +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
- } from "../src/rules/index.js"
11
-
12
- // Helper: simulate entering and exiting Effect.gen context
13
- const effectGenNode = Testing.callOfMember("Effect", "gen", [])
14
-
15
- // --- Global Effect-enforcing rules (fire everywhere) ---
16
-
17
- describe("noThrowStatement", () => {
18
- test("reports throw", () => {
19
- const result = Testing.runRule(noThrowStatement, "ThrowStatement", Testing.throwStmt())
20
- expect(result.length).toBe(1)
21
- })
22
- })
23
-
24
- describe("noTryCatch", () => {
25
- test("reports try/catch", () => {
26
- const result = Testing.runRule(noTryCatch, "TryStatement", Testing.tryStmt())
27
- expect(result.length).toBe(1)
28
- })
29
- })
30
-
31
- describe("noNewPromise", () => {
32
- test("reports new Promise()", () => {
33
- const result = Testing.runRule(noNewPromise, "NewExpression", Testing.newExpr("Promise"))
34
- expect(result.length).toBe(1)
35
- })
36
- })
37
-
38
- describe("noNewError", () => {
39
- test("reports new Error()", () => {
40
- const result = Testing.runRule(noNewError, "NewExpression", Testing.newExpr("Error"))
41
- expect(result.length).toBe(1)
42
- })
43
-
44
- test("reports new TypeError()", () => {
45
- const result = Testing.runRule(noNewError, "NewExpression", Testing.newExpr("TypeError"))
46
- expect(result.length).toBe(1)
47
- })
48
-
49
- test("ignores new MyError()", () => {
50
- const result = Testing.runRule(noNewError, "NewExpression", Testing.newExpr("MyError"))
51
- Testing.expectNoDiagnostics(result)
52
- })
53
- })
54
-
55
- describe("noReturnNullish", () => {
56
- test("reports return null", () => {
57
- const node = {
58
- type: "ReturnStatement",
59
- argument: { type: "Literal", value: null },
60
- } as never
61
- const result = Testing.runRule(noReturnNullish, "ReturnStatement", node)
62
- expect(result.length).toBe(1)
63
- })
64
-
65
- test("reports return undefined", () => {
66
- const node = {
67
- type: "ReturnStatement",
68
- argument: { type: "Identifier", name: "undefined" },
69
- } as never
70
- const result = Testing.runRule(noReturnNullish, "ReturnStatement", node)
71
- expect(result.length).toBe(1)
72
- })
73
- })
74
-
75
- // --- Effect-context rules (inside Effect.gen/fn only) ---
76
-
77
- describe("noGlobals", () => {
78
- test("reports console.log inside Effect.gen", () => {
79
- const result = Testing.runRuleMulti(noGlobals, [
80
- ["CallExpression", effectGenNode],
81
- ["MemberExpression", Testing.memberExpr("console", "log")],
82
- ["CallExpression:exit", effectGenNode],
83
- ])
84
- expect(result.length).toBe(1)
85
- })
86
-
87
- test("reports fetch() inside Effect.gen", () => {
88
- const result = Testing.runRuleMulti(noGlobals, [
89
- ["CallExpression", effectGenNode],
90
- ["CallExpression", Testing.callExpr("fetch")],
91
- ["CallExpression:exit", effectGenNode],
92
- ])
93
- expect(result.length).toBe(1)
94
- })
95
-
96
- test("reports Date.now inside Effect.gen", () => {
97
- const result = Testing.runRuleMulti(noGlobals, [
98
- ["CallExpression", effectGenNode],
99
- ["MemberExpression", Testing.memberExpr("Date", "now")],
100
- ["CallExpression:exit", effectGenNode],
101
- ])
102
- expect(result.length).toBe(1)
103
- })
104
-
105
- test("reports new Date() inside Effect.gen", () => {
106
- const result = Testing.runRuleMulti(noGlobals, [
107
- ["CallExpression", effectGenNode],
108
- ["NewExpression", Testing.newExpr("Date")],
109
- ["CallExpression:exit", effectGenNode],
110
- ])
111
- expect(result.length).toBe(1)
112
- })
113
-
114
- test("reports Math.random inside Effect.gen", () => {
115
- const result = Testing.runRuleMulti(noGlobals, [
116
- ["CallExpression", effectGenNode],
117
- ["MemberExpression", Testing.memberExpr("Math", "random")],
118
- ["CallExpression:exit", effectGenNode],
119
- ])
120
- expect(result.length).toBe(1)
121
- })
122
-
123
- test("reports setTimeout inside Effect.gen", () => {
124
- const result = Testing.runRuleMulti(noGlobals, [
125
- ["CallExpression", effectGenNode],
126
- ["CallExpression", Testing.callExpr("setTimeout")],
127
- ["CallExpression:exit", effectGenNode],
128
- ])
129
- expect(result.length).toBe(1)
130
- })
131
-
132
- test("reports JSON.parse inside Effect.gen", () => {
133
- const result = Testing.runRuleMulti(noGlobals, [
134
- ["CallExpression", effectGenNode],
135
- ["MemberExpression", Testing.memberExpr("JSON", "parse")],
136
- ["CallExpression:exit", effectGenNode],
137
- ])
138
- expect(result.length).toBe(1)
139
- })
140
-
141
- test("reports process.env inside Effect.gen", () => {
142
- const result = Testing.runRuleMulti(noGlobals, [
143
- ["CallExpression", effectGenNode],
144
- ["MemberExpression", Testing.memberExpr("process", "env")],
145
- ["CallExpression:exit", effectGenNode],
146
- ])
147
- expect(result.length).toBe(1)
148
- })
149
-
150
- test("reports process.exit with hint", () => {
151
- const result = Testing.runRuleMulti(noGlobals, [
152
- ["CallExpression", effectGenNode],
153
- ["MemberExpression", Testing.memberExpr("process", "exit")],
154
- ["CallExpression:exit", effectGenNode],
155
- ])
156
- Testing.expectDiagnostics(result, [{
157
- message: "Avoid process.exit inside Effect context. Use Effect.fail or Effect.die.",
158
- }])
159
- })
160
-
161
- test("reports Bun.file with FileSystem hint", () => {
162
- const result = Testing.runRuleMulti(noGlobals, [
163
- ["CallExpression", effectGenNode],
164
- ["MemberExpression", Testing.memberExpr("Bun", "file")],
165
- ["CallExpression:exit", effectGenNode],
166
- ])
167
- Testing.expectDiagnostics(result, [{
168
- message: "Avoid Bun.file inside Effect context. Use FileSystem from 'effect'.",
169
- }])
170
- })
171
-
172
- test("reports Deno.readFile with FileSystem hint", () => {
173
- const result = Testing.runRuleMulti(noGlobals, [
174
- ["CallExpression", effectGenNode],
175
- ["MemberExpression", Testing.memberExpr("Deno", "readFile")],
176
- ["CallExpression:exit", effectGenNode],
177
- ])
178
- Testing.expectDiagnostics(result, [{
179
- message: "Avoid Deno.readFile inside Effect context. Use FileSystem from 'effect'.",
180
- }])
181
- })
182
-
183
- test("ignores console.log outside Effect.gen", () => {
184
- const result = Testing.runRuleMulti(noGlobals, [
185
- ["MemberExpression", Testing.memberExpr("console", "log")],
186
- ])
187
- Testing.expectNoDiagnostics(result)
188
- })
189
-
190
- test("ignores Effect.succeed inside Effect.gen", () => {
191
- const result = Testing.runRuleMulti(noGlobals, [
192
- ["CallExpression", effectGenNode],
193
- ["MemberExpression", Testing.memberExpr("Effect", "succeed")],
194
- ["CallExpression:exit", effectGenNode],
195
- ])
196
- Testing.expectNoDiagnostics(result)
197
- })
198
- })
@@ -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
- }