@mionjs/devtools 0.8.10 → 0.13.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 (388) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +34 -0
  3. package/dist/core/apply-edits.d.ts +8 -0
  4. package/dist/core/apply-edits.js +24 -0
  5. package/dist/core/apply-edits.js.map +1 -0
  6. package/dist/core/bundledApiStub.d.ts +4 -0
  7. package/dist/core/bundledApiStub.js +4 -0
  8. package/dist/core/bundledApiStub.js.map +1 -0
  9. package/dist/core/devReporter.d.ts +19 -0
  10. package/dist/core/devReporter.js +91 -0
  11. package/dist/core/devReporter.js.map +1 -0
  12. package/dist/core/diagnosticCatalog.d.ts +5 -0
  13. package/dist/core/diagnosticCatalog.js +18 -0
  14. package/dist/core/diagnosticCatalog.js.map +1 -0
  15. package/dist/core/downgradeErrors.d.ts +11 -0
  16. package/dist/core/downgradeErrors.js +34 -0
  17. package/dist/core/downgradeErrors.js.map +1 -0
  18. package/dist/core/edit-buffer.d.ts +26 -0
  19. package/dist/core/edit-buffer.js +209 -0
  20. package/dist/core/edit-buffer.js.map +1 -0
  21. package/dist/core/go-generated/diagnosticCatalog.generated.d.ts +9 -0
  22. package/dist/core/go-generated/diagnosticCatalog.generated.js +1008 -0
  23. package/dist/core/go-generated/diagnosticCatalog.generated.js.map +1 -0
  24. package/dist/core/go-generated/reflectionKind.generated.d.ts +60 -0
  25. package/dist/core/go-generated/reflectionKind.generated.js +60 -0
  26. package/dist/core/go-generated/reflectionKind.generated.js.map +1 -0
  27. package/dist/core/go-generated/runtypes-constants.generated.d.ts +197 -0
  28. package/dist/core/go-generated/runtypes-constants.generated.js +110 -0
  29. package/dist/core/go-generated/runtypes-constants.generated.js.map +1 -0
  30. package/dist/core/go-generated/tsconfig-plugin-keys.generated.d.ts +3 -0
  31. package/dist/core/go-generated/tsconfig-plugin-keys.generated.js +23 -0
  32. package/dist/core/go-generated/tsconfig-plugin-keys.generated.js.map +1 -0
  33. package/dist/core/groupedLog.d.ts +6 -0
  34. package/dist/core/groupedLog.js +163 -0
  35. package/dist/core/groupedLog.js.map +1 -0
  36. package/dist/core/levels.d.ts +6 -0
  37. package/dist/core/levels.js +22 -0
  38. package/dist/core/levels.js.map +1 -0
  39. package/dist/core/markerImports.d.ts +8 -0
  40. package/dist/core/markerImports.js +149 -0
  41. package/dist/core/markerImports.js.map +1 -0
  42. package/dist/core/option-guards.d.ts +4 -0
  43. package/dist/core/option-guards.js +12 -0
  44. package/dist/core/option-guards.js.map +1 -0
  45. package/dist/core/plugin-option-keys.d.ts +3 -0
  46. package/dist/core/plugin-option-keys.js +35 -0
  47. package/dist/core/plugin-option-keys.js.map +1 -0
  48. package/dist/core/protocol.d.ts +244 -0
  49. package/dist/core/protocol.js +23 -0
  50. package/dist/core/protocol.js.map +1 -0
  51. package/dist/core/resolver-client.d.ts +160 -0
  52. package/dist/core/resolver-client.js +354 -0
  53. package/dist/core/resolver-client.js.map +1 -0
  54. package/dist/core/scan-batcher.d.ts +6 -0
  55. package/dist/core/scan-batcher.js +36 -0
  56. package/dist/core/scan-batcher.js.map +1 -0
  57. package/dist/core/surface.d.ts +23 -0
  58. package/dist/core/surface.js +77 -0
  59. package/dist/core/surface.js.map +1 -0
  60. package/dist/core/type-deps.d.ts +11 -0
  61. package/dist/core/type-deps.js +72 -0
  62. package/dist/core/type-deps.js.map +1 -0
  63. package/dist/core/types.d.ts +13 -0
  64. package/dist/core/types.js +2 -0
  65. package/dist/core/types.js.map +1 -0
  66. package/dist/core/typescript-floor.d.ts +5 -0
  67. package/dist/core/typescript-floor.js +33 -0
  68. package/dist/core/typescript-floor.js.map +1 -0
  69. package/dist/core/unplugin.d.ts +67 -0
  70. package/dist/core/unplugin.js +636 -0
  71. package/dist/core/unplugin.js.map +1 -0
  72. package/dist/index.d.ts +3 -0
  73. package/dist/index.js +3 -0
  74. package/dist/index.js.map +1 -0
  75. package/dist/lint/diagnosticRouting.d.ts +28 -0
  76. package/dist/lint/diagnosticRouting.js +74 -0
  77. package/dist/lint/diagnosticRouting.js.map +1 -0
  78. package/dist/lint/index.d.ts +49 -0
  79. package/dist/lint/index.js +96 -0
  80. package/dist/lint/index.js.map +1 -0
  81. package/dist/lint/lint-worker.d.ts +2 -0
  82. package/dist/lint/lint-worker.js +116 -0
  83. package/dist/lint/lint-worker.js.map +1 -0
  84. package/dist/lint/prefilter.d.ts +7 -0
  85. package/dist/lint/prefilter.js +31 -0
  86. package/dist/lint/prefilter.js.map +1 -0
  87. package/dist/lint/session-protocol.d.ts +38 -0
  88. package/dist/lint/session-protocol.js +11 -0
  89. package/dist/lint/session-protocol.js.map +1 -0
  90. package/dist/lint/session.d.ts +27 -0
  91. package/dist/lint/session.js +149 -0
  92. package/dist/lint/session.js.map +1 -0
  93. package/dist/lint/spawn-shim.d.ts +2 -0
  94. package/dist/lint/spawn-shim.js +23 -0
  95. package/dist/lint/spawn-shim.js.map +1 -0
  96. package/dist/next/index.d.ts +11 -0
  97. package/dist/next/index.js +17 -0
  98. package/dist/next/index.js.map +1 -0
  99. package/dist/options.d.ts +29 -0
  100. package/dist/options.js +36 -0
  101. package/dist/options.js.map +1 -0
  102. package/dist/runtypes/bun.d.ts +25 -0
  103. package/dist/runtypes/bun.js +62 -0
  104. package/dist/runtypes/bun.js.map +1 -0
  105. package/dist/runtypes/esbuild.d.ts +4 -0
  106. package/dist/runtypes/esbuild.js +4 -0
  107. package/dist/runtypes/esbuild.js.map +1 -0
  108. package/dist/runtypes/next/broker.d.ts +15 -0
  109. package/dist/runtypes/next/broker.js +316 -0
  110. package/dist/runtypes/next/broker.js.map +1 -0
  111. package/dist/runtypes/next/index.d.ts +30 -0
  112. package/dist/runtypes/next/index.js +57 -0
  113. package/dist/runtypes/next/index.js.map +1 -0
  114. package/dist/runtypes/next/loader.d.ts +13 -0
  115. package/dist/runtypes/next/loader.js +64 -0
  116. package/dist/runtypes/next/loader.js.map +1 -0
  117. package/dist/runtypes/next/wire.d.ts +17 -0
  118. package/dist/runtypes/next/wire.js +15 -0
  119. package/dist/runtypes/next/wire.js.map +1 -0
  120. package/dist/runtypes/rolldown.d.ts +4 -0
  121. package/dist/runtypes/rolldown.js +4 -0
  122. package/dist/runtypes/rolldown.js.map +1 -0
  123. package/dist/runtypes/rollup.d.ts +4 -0
  124. package/dist/runtypes/rollup.js +4 -0
  125. package/dist/runtypes/rollup.js.map +1 -0
  126. package/dist/runtypes/rspack.d.ts +4 -0
  127. package/dist/runtypes/rspack.js +4 -0
  128. package/dist/runtypes/rspack.js.map +1 -0
  129. package/dist/runtypes/vite.d.ts +4 -0
  130. package/dist/runtypes/vite.js +4 -0
  131. package/dist/runtypes/vite.js.map +1 -0
  132. package/dist/runtypes/webpack.d.ts +4 -0
  133. package/dist/runtypes/webpack.js +4 -0
  134. package/dist/runtypes/webpack.js.map +1 -0
  135. package/dist/vite/buildEntries.d.ts +2 -0
  136. package/dist/vite/buildEntries.js +28 -0
  137. package/dist/vite/buildEntries.js.map +1 -0
  138. package/dist/vite/cjsPackageJsonPlugin.d.ts +3 -0
  139. package/dist/vite/cjsPackageJsonPlugin.js +12 -0
  140. package/dist/vite/cjsPackageJsonPlugin.js.map +1 -0
  141. package/dist/vite/index.d.ts +6 -0
  142. package/dist/vite/index.js +5 -0
  143. package/dist/vite/index.js.map +1 -0
  144. package/dist/vite/middlewareMode.d.ts +10 -0
  145. package/dist/vite/middlewareMode.js +227 -0
  146. package/dist/vite/middlewareMode.js.map +1 -0
  147. package/dist/vite/mionVitePlugin.d.ts +23 -0
  148. package/dist/vite/mionVitePlugin.js +115 -0
  149. package/dist/vite/mionVitePlugin.js.map +1 -0
  150. package/dist/vite/nodeWebBridge.d.ts +5 -0
  151. package/dist/vite/nodeWebBridge.js +59 -0
  152. package/dist/vite/nodeWebBridge.js.map +1 -0
  153. package/dist/vite/sfcTransform.d.ts +8 -0
  154. package/dist/vite/sfcTransform.js +142 -0
  155. package/dist/vite/sfcTransform.js.map +1 -0
  156. package/oxlint-recommended.json +11 -0
  157. package/package.json +91 -56
  158. package/build/eslint/cjs/index.cjs +0 -41
  159. package/build/eslint/cjs/index.cjs.map +0 -1
  160. package/build/eslint/cjs/package.json +0 -1
  161. package/build/eslint/cjs/src/eslint/index.cjs +0 -13
  162. package/build/eslint/cjs/src/eslint/index.cjs.map +0 -1
  163. package/build/eslint/cjs/src/eslint/index.d.ts +0 -4
  164. package/build/eslint/cjs/src/eslint/index.d.ts.map +0 -1
  165. package/build/eslint/cjs/src/eslint/rules/enforce-type-imports.cjs +0 -121
  166. package/build/eslint/cjs/src/eslint/rules/enforce-type-imports.cjs.map +0 -1
  167. package/build/eslint/cjs/src/eslint/rules/enforce-type-imports.d.ts +0 -8
  168. package/build/eslint/cjs/src/eslint/rules/enforce-type-imports.d.ts.map +0 -1
  169. package/build/eslint/cjs/src/eslint/rules/formatTypeNames.cjs +0 -71
  170. package/build/eslint/cjs/src/eslint/rules/formatTypeNames.cjs.map +0 -1
  171. package/build/eslint/cjs/src/eslint/rules/formatTypeNames.d.ts +0 -4
  172. package/build/eslint/cjs/src/eslint/rules/formatTypeNames.d.ts.map +0 -1
  173. package/build/eslint/cjs/src/eslint/rules/no-mixed-union-properties.cjs +0 -220
  174. package/build/eslint/cjs/src/eslint/rules/no-mixed-union-properties.cjs.map +0 -1
  175. package/build/eslint/cjs/src/eslint/rules/no-mixed-union-properties.d.ts +0 -4
  176. package/build/eslint/cjs/src/eslint/rules/no-mixed-union-properties.d.ts.map +0 -1
  177. package/build/eslint/cjs/src/eslint/rules/no-type-imports.cjs +0 -251
  178. package/build/eslint/cjs/src/eslint/rules/no-type-imports.cjs.map +0 -1
  179. package/build/eslint/cjs/src/eslint/rules/no-type-imports.d.ts +0 -4
  180. package/build/eslint/cjs/src/eslint/rules/no-type-imports.d.ts.map +0 -1
  181. package/build/eslint/cjs/src/eslint/rules/no-typeof-runtype.cjs +0 -72
  182. package/build/eslint/cjs/src/eslint/rules/no-typeof-runtype.cjs.map +0 -1
  183. package/build/eslint/cjs/src/eslint/rules/no-typeof-runtype.d.ts +0 -4
  184. package/build/eslint/cjs/src/eslint/rules/no-typeof-runtype.d.ts.map +0 -1
  185. package/build/eslint/cjs/src/eslint/rules/no-unreachable-union-types.cjs +0 -220
  186. package/build/eslint/cjs/src/eslint/rules/no-unreachable-union-types.cjs.map +0 -1
  187. package/build/eslint/cjs/src/eslint/rules/no-unreachable-union-types.d.ts +0 -4
  188. package/build/eslint/cjs/src/eslint/rules/no-unreachable-union-types.d.ts.map +0 -1
  189. package/build/eslint/cjs/src/eslint/rules/no-vite-client.cjs +0 -71
  190. package/build/eslint/cjs/src/eslint/rules/no-vite-client.cjs.map +0 -1
  191. package/build/eslint/cjs/src/eslint/rules/no-vite-client.d.ts +0 -5
  192. package/build/eslint/cjs/src/eslint/rules/no-vite-client.d.ts.map +0 -1
  193. package/build/eslint/cjs/src/eslint/rules/pure-functions.cjs +0 -346
  194. package/build/eslint/cjs/src/eslint/rules/pure-functions.cjs.map +0 -1
  195. package/build/eslint/cjs/src/eslint/rules/pure-functions.d.ts +0 -5
  196. package/build/eslint/cjs/src/eslint/rules/pure-functions.d.ts.map +0 -1
  197. package/build/eslint/cjs/src/eslint/rules/strong-typed-routes.cjs +0 -328
  198. package/build/eslint/cjs/src/eslint/rules/strong-typed-routes.cjs.map +0 -1
  199. package/build/eslint/cjs/src/eslint/rules/strong-typed-routes.d.ts +0 -5
  200. package/build/eslint/cjs/src/eslint/rules/strong-typed-routes.d.ts.map +0 -1
  201. package/build/eslint/cjs/src/eslint/rules/type-formats-imports.cjs +0 -52
  202. package/build/eslint/cjs/src/eslint/rules/type-formats-imports.cjs.map +0 -1
  203. package/build/eslint/cjs/src/eslint/rules/type-formats-imports.d.ts +0 -4
  204. package/build/eslint/cjs/src/eslint/rules/type-formats-imports.d.ts.map +0 -1
  205. package/build/eslint/cjs/src/pureFns/purityRules.cjs +0 -67
  206. package/build/eslint/cjs/src/pureFns/purityRules.cjs.map +0 -1
  207. package/build/eslint/cjs/src/pureFns/purityRules.d.ts +0 -5
  208. package/build/eslint/cjs/src/pureFns/purityRules.d.ts.map +0 -1
  209. package/build/eslint/esm/index.js +0 -42
  210. package/build/eslint/esm/index.js.map +0 -1
  211. package/build/eslint/esm/src/eslint/index.d.ts +0 -4
  212. package/build/eslint/esm/src/eslint/index.d.ts.map +0 -1
  213. package/build/eslint/esm/src/eslint/index.js +0 -14
  214. package/build/eslint/esm/src/eslint/index.js.map +0 -1
  215. package/build/eslint/esm/src/eslint/rules/enforce-type-imports.d.ts +0 -8
  216. package/build/eslint/esm/src/eslint/rules/enforce-type-imports.d.ts.map +0 -1
  217. package/build/eslint/esm/src/eslint/rules/enforce-type-imports.js +0 -122
  218. package/build/eslint/esm/src/eslint/rules/enforce-type-imports.js.map +0 -1
  219. package/build/eslint/esm/src/eslint/rules/formatTypeNames.d.ts +0 -4
  220. package/build/eslint/esm/src/eslint/rules/formatTypeNames.d.ts.map +0 -1
  221. package/build/eslint/esm/src/eslint/rules/formatTypeNames.js +0 -71
  222. package/build/eslint/esm/src/eslint/rules/formatTypeNames.js.map +0 -1
  223. package/build/eslint/esm/src/eslint/rules/no-mixed-union-properties.d.ts +0 -4
  224. package/build/eslint/esm/src/eslint/rules/no-mixed-union-properties.d.ts.map +0 -1
  225. package/build/eslint/esm/src/eslint/rules/no-mixed-union-properties.js +0 -221
  226. package/build/eslint/esm/src/eslint/rules/no-mixed-union-properties.js.map +0 -1
  227. package/build/eslint/esm/src/eslint/rules/no-type-imports.d.ts +0 -4
  228. package/build/eslint/esm/src/eslint/rules/no-type-imports.d.ts.map +0 -1
  229. package/build/eslint/esm/src/eslint/rules/no-type-imports.js +0 -252
  230. package/build/eslint/esm/src/eslint/rules/no-type-imports.js.map +0 -1
  231. package/build/eslint/esm/src/eslint/rules/no-typeof-runtype.d.ts +0 -4
  232. package/build/eslint/esm/src/eslint/rules/no-typeof-runtype.d.ts.map +0 -1
  233. package/build/eslint/esm/src/eslint/rules/no-typeof-runtype.js +0 -73
  234. package/build/eslint/esm/src/eslint/rules/no-typeof-runtype.js.map +0 -1
  235. package/build/eslint/esm/src/eslint/rules/no-unreachable-union-types.d.ts +0 -4
  236. package/build/eslint/esm/src/eslint/rules/no-unreachable-union-types.d.ts.map +0 -1
  237. package/build/eslint/esm/src/eslint/rules/no-unreachable-union-types.js +0 -221
  238. package/build/eslint/esm/src/eslint/rules/no-unreachable-union-types.js.map +0 -1
  239. package/build/eslint/esm/src/eslint/rules/no-vite-client.d.ts +0 -5
  240. package/build/eslint/esm/src/eslint/rules/no-vite-client.d.ts.map +0 -1
  241. package/build/eslint/esm/src/eslint/rules/no-vite-client.js +0 -72
  242. package/build/eslint/esm/src/eslint/rules/no-vite-client.js.map +0 -1
  243. package/build/eslint/esm/src/eslint/rules/pure-functions.d.ts +0 -5
  244. package/build/eslint/esm/src/eslint/rules/pure-functions.d.ts.map +0 -1
  245. package/build/eslint/esm/src/eslint/rules/pure-functions.js +0 -347
  246. package/build/eslint/esm/src/eslint/rules/pure-functions.js.map +0 -1
  247. package/build/eslint/esm/src/eslint/rules/strong-typed-routes.d.ts +0 -5
  248. package/build/eslint/esm/src/eslint/rules/strong-typed-routes.d.ts.map +0 -1
  249. package/build/eslint/esm/src/eslint/rules/strong-typed-routes.js +0 -329
  250. package/build/eslint/esm/src/eslint/rules/strong-typed-routes.js.map +0 -1
  251. package/build/eslint/esm/src/eslint/rules/type-formats-imports.d.ts +0 -4
  252. package/build/eslint/esm/src/eslint/rules/type-formats-imports.d.ts.map +0 -1
  253. package/build/eslint/esm/src/eslint/rules/type-formats-imports.js +0 -53
  254. package/build/eslint/esm/src/eslint/rules/type-formats-imports.js.map +0 -1
  255. package/build/eslint/esm/src/pureFns/purityRules.d.ts +0 -5
  256. package/build/eslint/esm/src/pureFns/purityRules.d.ts.map +0 -1
  257. package/build/eslint/esm/src/pureFns/purityRules.js +0 -67
  258. package/build/eslint/esm/src/pureFns/purityRules.js.map +0 -1
  259. package/build/vite-plugin/cjs/index.cjs +0 -13
  260. package/build/vite-plugin/cjs/index.cjs.map +0 -1
  261. package/build/vite-plugin/cjs/package.json +0 -1
  262. package/build/vite-plugin/cjs/src/pureFns/purityRules.cjs +0 -65
  263. package/build/vite-plugin/cjs/src/pureFns/purityRules.cjs.map +0 -1
  264. package/build/vite-plugin/cjs/src/pureFns/purityRules.d.ts +0 -5
  265. package/build/vite-plugin/cjs/src/pureFns/purityRules.d.ts.map +0 -1
  266. package/build/vite-plugin/cjs/src/vite-plugin/aotCacheGenerator.cjs +0 -271
  267. package/build/vite-plugin/cjs/src/vite-plugin/aotCacheGenerator.cjs.map +0 -1
  268. package/build/vite-plugin/cjs/src/vite-plugin/aotCacheGenerator.d.ts +0 -32
  269. package/build/vite-plugin/cjs/src/vite-plugin/aotCacheGenerator.d.ts.map +0 -1
  270. package/build/vite-plugin/cjs/src/vite-plugin/aotDiskCache.cjs +0 -135
  271. package/build/vite-plugin/cjs/src/vite-plugin/aotDiskCache.cjs.map +0 -1
  272. package/build/vite-plugin/cjs/src/vite-plugin/aotDiskCache.d.ts +0 -7
  273. package/build/vite-plugin/cjs/src/vite-plugin/aotDiskCache.d.ts.map +0 -1
  274. package/build/vite-plugin/cjs/src/vite-plugin/cjsPackageJsonPlugin.cjs +0 -15
  275. package/build/vite-plugin/cjs/src/vite-plugin/cjsPackageJsonPlugin.cjs.map +0 -1
  276. package/build/vite-plugin/cjs/src/vite-plugin/cjsPackageJsonPlugin.d.ts +0 -3
  277. package/build/vite-plugin/cjs/src/vite-plugin/cjsPackageJsonPlugin.d.ts.map +0 -1
  278. package/build/vite-plugin/cjs/src/vite-plugin/constants.cjs +0 -29
  279. package/build/vite-plugin/cjs/src/vite-plugin/constants.cjs.map +0 -1
  280. package/build/vite-plugin/cjs/src/vite-plugin/constants.d.ts +0 -13
  281. package/build/vite-plugin/cjs/src/vite-plugin/constants.d.ts.map +0 -1
  282. package/build/vite-plugin/cjs/src/vite-plugin/extractPureFn.cjs +0 -628
  283. package/build/vite-plugin/cjs/src/vite-plugin/extractPureFn.cjs.map +0 -1
  284. package/build/vite-plugin/cjs/src/vite-plugin/extractPureFn.d.ts +0 -14
  285. package/build/vite-plugin/cjs/src/vite-plugin/extractPureFn.d.ts.map +0 -1
  286. package/build/vite-plugin/cjs/src/vite-plugin/index.cjs +0 -13
  287. package/build/vite-plugin/cjs/src/vite-plugin/index.cjs.map +0 -1
  288. package/build/vite-plugin/cjs/src/vite-plugin/index.d.ts +0 -6
  289. package/build/vite-plugin/cjs/src/vite-plugin/index.d.ts.map +0 -1
  290. package/build/vite-plugin/cjs/src/vite-plugin/mionVitePlugin.cjs +0 -511
  291. package/build/vite-plugin/cjs/src/vite-plugin/mionVitePlugin.cjs.map +0 -1
  292. package/build/vite-plugin/cjs/src/vite-plugin/mionVitePlugin.d.ts +0 -37
  293. package/build/vite-plugin/cjs/src/vite-plugin/mionVitePlugin.d.ts.map +0 -1
  294. package/build/vite-plugin/cjs/src/vite-plugin/resolveModule.cjs +0 -55
  295. package/build/vite-plugin/cjs/src/vite-plugin/resolveModule.cjs.map +0 -1
  296. package/build/vite-plugin/cjs/src/vite-plugin/resolveModule.d.ts +0 -2
  297. package/build/vite-plugin/cjs/src/vite-plugin/resolveModule.d.ts.map +0 -1
  298. package/build/vite-plugin/cjs/src/vite-plugin/transformers.cjs +0 -166
  299. package/build/vite-plugin/cjs/src/vite-plugin/transformers.cjs.map +0 -1
  300. package/build/vite-plugin/cjs/src/vite-plugin/transformers.d.ts +0 -11
  301. package/build/vite-plugin/cjs/src/vite-plugin/transformers.d.ts.map +0 -1
  302. package/build/vite-plugin/cjs/src/vite-plugin/types.cjs +0 -2
  303. package/build/vite-plugin/cjs/src/vite-plugin/types.cjs.map +0 -1
  304. package/build/vite-plugin/cjs/src/vite-plugin/types.d.ts +0 -60
  305. package/build/vite-plugin/cjs/src/vite-plugin/types.d.ts.map +0 -1
  306. package/build/vite-plugin/cjs/src/vite-plugin/virtual-modules.d.cjs +0 -2
  307. package/build/vite-plugin/cjs/src/vite-plugin/virtual-modules.d.cjs.map +0 -1
  308. package/build/vite-plugin/cjs/src/vite-plugin/virtualModule.cjs +0 -69
  309. package/build/vite-plugin/cjs/src/vite-plugin/virtualModule.cjs.map +0 -1
  310. package/build/vite-plugin/cjs/src/vite-plugin/virtualModule.d.ts +0 -3
  311. package/build/vite-plugin/cjs/src/vite-plugin/virtualModule.d.ts.map +0 -1
  312. package/build/vite-plugin/esm/index.js +0 -13
  313. package/build/vite-plugin/esm/index.js.map +0 -1
  314. package/build/vite-plugin/esm/src/pureFns/purityRules.d.ts +0 -5
  315. package/build/vite-plugin/esm/src/pureFns/purityRules.d.ts.map +0 -1
  316. package/build/vite-plugin/esm/src/pureFns/purityRules.js +0 -65
  317. package/build/vite-plugin/esm/src/pureFns/purityRules.js.map +0 -1
  318. package/build/vite-plugin/esm/src/vite-plugin/aotCacheGenerator.d.ts +0 -32
  319. package/build/vite-plugin/esm/src/vite-plugin/aotCacheGenerator.d.ts.map +0 -1
  320. package/build/vite-plugin/esm/src/vite-plugin/aotCacheGenerator.js +0 -271
  321. package/build/vite-plugin/esm/src/vite-plugin/aotCacheGenerator.js.map +0 -1
  322. package/build/vite-plugin/esm/src/vite-plugin/aotDiskCache.d.ts +0 -7
  323. package/build/vite-plugin/esm/src/vite-plugin/aotDiskCache.d.ts.map +0 -1
  324. package/build/vite-plugin/esm/src/vite-plugin/aotDiskCache.js +0 -134
  325. package/build/vite-plugin/esm/src/vite-plugin/aotDiskCache.js.map +0 -1
  326. package/build/vite-plugin/esm/src/vite-plugin/cjsPackageJsonPlugin.d.ts +0 -3
  327. package/build/vite-plugin/esm/src/vite-plugin/cjsPackageJsonPlugin.d.ts.map +0 -1
  328. package/build/vite-plugin/esm/src/vite-plugin/cjsPackageJsonPlugin.js +0 -15
  329. package/build/vite-plugin/esm/src/vite-plugin/cjsPackageJsonPlugin.js.map +0 -1
  330. package/build/vite-plugin/esm/src/vite-plugin/constants.d.ts +0 -13
  331. package/build/vite-plugin/esm/src/vite-plugin/constants.d.ts.map +0 -1
  332. package/build/vite-plugin/esm/src/vite-plugin/constants.js +0 -29
  333. package/build/vite-plugin/esm/src/vite-plugin/constants.js.map +0 -1
  334. package/build/vite-plugin/esm/src/vite-plugin/extractPureFn.d.ts +0 -14
  335. package/build/vite-plugin/esm/src/vite-plugin/extractPureFn.d.ts.map +0 -1
  336. package/build/vite-plugin/esm/src/vite-plugin/extractPureFn.js +0 -611
  337. package/build/vite-plugin/esm/src/vite-plugin/extractPureFn.js.map +0 -1
  338. package/build/vite-plugin/esm/src/vite-plugin/index.d.ts +0 -6
  339. package/build/vite-plugin/esm/src/vite-plugin/index.d.ts.map +0 -1
  340. package/build/vite-plugin/esm/src/vite-plugin/index.js +0 -13
  341. package/build/vite-plugin/esm/src/vite-plugin/index.js.map +0 -1
  342. package/build/vite-plugin/esm/src/vite-plugin/mionVitePlugin.d.ts +0 -37
  343. package/build/vite-plugin/esm/src/vite-plugin/mionVitePlugin.d.ts.map +0 -1
  344. package/build/vite-plugin/esm/src/vite-plugin/mionVitePlugin.js +0 -493
  345. package/build/vite-plugin/esm/src/vite-plugin/mionVitePlugin.js.map +0 -1
  346. package/build/vite-plugin/esm/src/vite-plugin/resolveModule.d.ts +0 -2
  347. package/build/vite-plugin/esm/src/vite-plugin/resolveModule.d.ts.map +0 -1
  348. package/build/vite-plugin/esm/src/vite-plugin/resolveModule.js +0 -33
  349. package/build/vite-plugin/esm/src/vite-plugin/resolveModule.js.map +0 -1
  350. package/build/vite-plugin/esm/src/vite-plugin/transformers.d.ts +0 -11
  351. package/build/vite-plugin/esm/src/vite-plugin/transformers.d.ts.map +0 -1
  352. package/build/vite-plugin/esm/src/vite-plugin/transformers.js +0 -149
  353. package/build/vite-plugin/esm/src/vite-plugin/transformers.js.map +0 -1
  354. package/build/vite-plugin/esm/src/vite-plugin/types.d.ts +0 -60
  355. package/build/vite-plugin/esm/src/vite-plugin/types.d.ts.map +0 -1
  356. package/build/vite-plugin/esm/src/vite-plugin/types.js +0 -2
  357. package/build/vite-plugin/esm/src/vite-plugin/types.js.map +0 -1
  358. package/build/vite-plugin/esm/src/vite-plugin/virtual-modules.d.js +0 -2
  359. package/build/vite-plugin/esm/src/vite-plugin/virtual-modules.d.js.map +0 -1
  360. package/build/vite-plugin/esm/src/vite-plugin/virtualModule.d.ts +0 -3
  361. package/build/vite-plugin/esm/src/vite-plugin/virtualModule.d.ts.map +0 -1
  362. package/build/vite-plugin/esm/src/vite-plugin/virtualModule.js +0 -69
  363. package/build/vite-plugin/esm/src/vite-plugin/virtualModule.js.map +0 -1
  364. package/src/eslint/index.ts +0 -53
  365. package/src/eslint/rules/enforce-type-imports.ts +0 -157
  366. package/src/eslint/rules/formatTypeNames.ts +0 -92
  367. package/src/eslint/rules/no-mixed-union-properties.ts +0 -276
  368. package/src/eslint/rules/no-type-imports.ts +0 -386
  369. package/src/eslint/rules/no-typeof-runtype.ts +0 -112
  370. package/src/eslint/rules/no-unreachable-union-types.ts +0 -357
  371. package/src/eslint/rules/no-vite-client.ts +0 -101
  372. package/src/eslint/rules/pure-functions.ts +0 -523
  373. package/src/eslint/rules/strong-typed-routes.ts +0 -537
  374. package/src/eslint/rules/type-formats-imports.ts +0 -73
  375. package/src/pureFns/purityRules.ts +0 -76
  376. package/src/vite-plugin/README.md +0 -399
  377. package/src/vite-plugin/aotCacheGenerator.ts +0 -397
  378. package/src/vite-plugin/aotDiskCache.ts +0 -193
  379. package/src/vite-plugin/cjsPackageJsonPlugin.ts +0 -21
  380. package/src/vite-plugin/constants.ts +0 -50
  381. package/src/vite-plugin/extractPureFn.ts +0 -845
  382. package/src/vite-plugin/index.ts +0 -27
  383. package/src/vite-plugin/mionVitePlugin.ts +0 -738
  384. package/src/vite-plugin/resolveModule.ts +0 -50
  385. package/src/vite-plugin/transformers.ts +0 -209
  386. package/src/vite-plugin/types.ts +0 -182
  387. package/src/vite-plugin/virtual-modules.d.ts +0 -48
  388. package/src/vite-plugin/virtualModule.ts +0 -94
@@ -1,386 +0,0 @@
1
- /* ########
2
- * 2024 mion
3
- * Author: Ma-jerez
4
- * License: MIT
5
- * The software is provided "as is", without warranty of any kind.
6
- * ######## */
7
-
8
- import {TSESTree, TSESLint, AST_NODE_TYPES} from '@typescript-eslint/utils';
9
-
10
- /** List of router functions that should have strongly typed handlers */
11
- const ROUTER_FUNCTIONS = ['route', 'middleFn', 'headersFn'] as const;
12
- /** List of handler types that can be used with type annotations */
13
- const HANDLER_TYPES = ['Handler', 'HeaderHandler'] as const;
14
-
15
- /** Cache for imports from @mionjs/router - computed once per file */
16
- interface MionRouterImports {
17
- /** Set of function names imported from @mionjs/router (route, middleFn, headersFn) */
18
- routerFunctions: Set<string>;
19
- /** Set of type names imported from @mionjs/router (Handler, HeaderHandler) */
20
- handlerTypes: Set<string>;
21
- }
22
-
23
- /** Cache for type-only imports - computed once per file */
24
- interface TypeOnlyImports {
25
- /** Map of type name to import declaration node */
26
- typeOnlyImports: Map<string, TSESTree.ImportDeclaration>;
27
- }
28
-
29
- /** Type reference with its node for precise error reporting */
30
- interface TypeRefWithNode {
31
- typeName: string;
32
- node: TSESTree.Node;
33
- }
34
-
35
- /** Builds a cache of all imports from @mionjs/router */
36
- function buildRouterImportCache(program: TSESTree.Program): MionRouterImports {
37
- const routerFunctions = new Set<string>();
38
- const handlerTypes = new Set<string>();
39
-
40
- for (const statement of program.body) {
41
- if (statement.type === AST_NODE_TYPES.ImportDeclaration) {
42
- const source = statement.source.value;
43
- if (source === '@mionjs/router' || source === '@mionjs/router/') {
44
- for (const specifier of statement.specifiers) {
45
- if (
46
- specifier.type === AST_NODE_TYPES.ImportSpecifier &&
47
- specifier.imported.type === AST_NODE_TYPES.Identifier
48
- ) {
49
- const name = specifier.imported.name;
50
- if (ROUTER_FUNCTIONS.includes(name as (typeof ROUTER_FUNCTIONS)[number])) {
51
- routerFunctions.add(name);
52
- }
53
- if (HANDLER_TYPES.includes(name as (typeof HANDLER_TYPES)[number])) {
54
- handlerTypes.add(name);
55
- }
56
- }
57
- }
58
- }
59
- }
60
- }
61
-
62
- return {routerFunctions, handlerTypes};
63
- }
64
-
65
- /** Builds a cache of all type-only imports */
66
- function buildTypeOnlyImportCache(program: TSESTree.Program): TypeOnlyImports {
67
- const typeOnlyImports = new Map<string, TSESTree.ImportDeclaration>();
68
-
69
- for (const statement of program.body) {
70
- if (statement.type === AST_NODE_TYPES.ImportDeclaration) {
71
- // Check if the entire import is type-only: import type { X } from '...'
72
- const isTypeOnlyImport = statement.importKind === 'type';
73
-
74
- for (const specifier of statement.specifiers) {
75
- if (specifier.type === AST_NODE_TYPES.ImportSpecifier) {
76
- // Check if individual specifier is type-only: import { type X } from '...'
77
- const isTypeOnlySpecifier = specifier.importKind === 'type';
78
-
79
- if (isTypeOnlyImport || isTypeOnlySpecifier) {
80
- const localName = specifier.local.name;
81
- typeOnlyImports.set(localName, statement);
82
- }
83
- }
84
- }
85
- }
86
- }
87
-
88
- return {typeOnlyImports};
89
- }
90
-
91
- /** Checks if a call expression is calling router functions from @mionjs/router */
92
- function getRouterFunctionName(node: TSESTree.CallExpression, importCache: MionRouterImports): string | null {
93
- if (node.callee.type !== AST_NODE_TYPES.Identifier) return null;
94
- const functionName = node.callee.name;
95
- if (importCache.routerFunctions.has(functionName)) return functionName;
96
- return null;
97
- }
98
-
99
- /** Extracts all type references with their nodes from a type node recursively */
100
- function extractTypeReferencesWithNodes(typeNode: TSESTree.TypeNode | null | undefined): TypeRefWithNode[] {
101
- if (!typeNode) return [];
102
-
103
- const references: TypeRefWithNode[] = [];
104
-
105
- switch (typeNode.type) {
106
- case AST_NODE_TYPES.TSTypeReference:
107
- if (typeNode.typeName.type === AST_NODE_TYPES.Identifier) {
108
- // Report on the type reference node itself (e.g., "User" in ": User")
109
- references.push({typeName: typeNode.typeName.name, node: typeNode});
110
- }
111
- // Also check type arguments (generics)
112
- if (typeNode.typeArguments) {
113
- for (const param of typeNode.typeArguments.params) {
114
- references.push(...extractTypeReferencesWithNodes(param));
115
- }
116
- }
117
- break;
118
-
119
- case AST_NODE_TYPES.TSUnionType:
120
- case AST_NODE_TYPES.TSIntersectionType:
121
- for (const member of typeNode.types) {
122
- references.push(...extractTypeReferencesWithNodes(member));
123
- }
124
- break;
125
-
126
- case AST_NODE_TYPES.TSArrayType:
127
- references.push(...extractTypeReferencesWithNodes(typeNode.elementType));
128
- break;
129
-
130
- case AST_NODE_TYPES.TSTupleType:
131
- for (const element of typeNode.elementTypes) {
132
- references.push(...extractTypeReferencesWithNodes(element));
133
- }
134
- break;
135
-
136
- case AST_NODE_TYPES.TSTypeLiteral:
137
- for (const member of typeNode.members) {
138
- if (member.type === AST_NODE_TYPES.TSPropertySignature && member.typeAnnotation) {
139
- references.push(...extractTypeReferencesWithNodes(member.typeAnnotation.typeAnnotation));
140
- }
141
- }
142
- break;
143
-
144
- case AST_NODE_TYPES.TSConditionalType:
145
- references.push(...extractTypeReferencesWithNodes(typeNode.checkType));
146
- references.push(...extractTypeReferencesWithNodes(typeNode.extendsType));
147
- references.push(...extractTypeReferencesWithNodes(typeNode.trueType));
148
- references.push(...extractTypeReferencesWithNodes(typeNode.falseType));
149
- break;
150
-
151
- case AST_NODE_TYPES.TSMappedType:
152
- references.push(...extractTypeReferencesWithNodes(typeNode.typeAnnotation));
153
- break;
154
-
155
- case AST_NODE_TYPES.TSIndexedAccessType:
156
- references.push(...extractTypeReferencesWithNodes(typeNode.objectType));
157
- references.push(...extractTypeReferencesWithNodes(typeNode.indexType));
158
- break;
159
-
160
- case AST_NODE_TYPES.TSTypeOperator:
161
- references.push(...extractTypeReferencesWithNodes(typeNode.typeAnnotation));
162
- break;
163
-
164
- case AST_NODE_TYPES.TSRestType:
165
- references.push(...extractTypeReferencesWithNodes(typeNode.typeAnnotation));
166
- break;
167
-
168
- case AST_NODE_TYPES.TSOptionalType:
169
- references.push(...extractTypeReferencesWithNodes(typeNode.typeAnnotation));
170
- break;
171
-
172
- case AST_NODE_TYPES.TSFunctionType:
173
- case AST_NODE_TYPES.TSConstructorType:
174
- // Check parameters
175
- for (const param of typeNode.params) {
176
- if ('typeAnnotation' in param && param.typeAnnotation) {
177
- references.push(...extractTypeReferencesWithNodes(param.typeAnnotation.typeAnnotation));
178
- }
179
- }
180
- // Check return type
181
- if (typeNode.returnType) {
182
- references.push(...extractTypeReferencesWithNodes(typeNode.returnType.typeAnnotation));
183
- }
184
- break;
185
- }
186
-
187
- return references;
188
- }
189
-
190
- /** Gets type annotation from a parameter if it exists */
191
- function getParamTypeAnnotation(param: TSESTree.Parameter): TSESTree.TypeNode | null {
192
- if (param.type === AST_NODE_TYPES.Identifier && param.typeAnnotation) {
193
- return param.typeAnnotation.typeAnnotation;
194
- }
195
- if (param.type === AST_NODE_TYPES.RestElement && param.typeAnnotation) {
196
- return param.typeAnnotation.typeAnnotation;
197
- }
198
- if (param.type === AST_NODE_TYPES.ArrayPattern && param.typeAnnotation) {
199
- return param.typeAnnotation.typeAnnotation;
200
- }
201
- if (param.type === AST_NODE_TYPES.ObjectPattern && param.typeAnnotation) {
202
- return param.typeAnnotation.typeAnnotation;
203
- }
204
- if (param.type === AST_NODE_TYPES.AssignmentPattern) {
205
- // Check if there's a type annotation on the pattern itself
206
- if (param.typeAnnotation) {
207
- return param.typeAnnotation.typeAnnotation;
208
- }
209
- // Check if there's a type annotation on the left side
210
- if (param.left.type === AST_NODE_TYPES.Identifier && param.left.typeAnnotation) {
211
- return param.left.typeAnnotation.typeAnnotation;
212
- }
213
- }
214
- return null;
215
- }
216
-
217
- /** Extracts type references with nodes from function parameters (excluding first ctx parameter) */
218
- function extractParamTypeReferencesWithNodes(params: TSESTree.Parameter[]): TypeRefWithNode[] {
219
- const references: TypeRefWithNode[] = [];
220
-
221
- // Skip first parameter (ctx)
222
- for (let i = 1; i < params.length; i++) {
223
- const param = params[i];
224
- if (param) {
225
- const typeAnnotation = getParamTypeAnnotation(param);
226
- if (typeAnnotation) {
227
- references.push(...extractTypeReferencesWithNodes(typeAnnotation));
228
- }
229
- }
230
- }
231
-
232
- return references;
233
- }
234
-
235
- /** Extracts type references with nodes from function return type */
236
- function extractReturnTypeReferencesWithNodes(
237
- node: TSESTree.ArrowFunctionExpression | TSESTree.FunctionExpression | TSESTree.FunctionDeclaration
238
- ): TypeRefWithNode[] {
239
- if (node.returnType) {
240
- return extractTypeReferencesWithNodes(node.returnType.typeAnnotation);
241
- }
242
- return [];
243
- }
244
-
245
- const rule: TSESLint.RuleModule<'noTypeImports', []> = {
246
- meta: {
247
- type: 'problem',
248
- docs: {
249
- description:
250
- 'Disallow type-only imports for types used in route/middleFn parameters or return types. Type-only imports are erased at runtime, preventing mion from generating validation and serialization functions.',
251
- },
252
- messages: {
253
- noTypeImports:
254
- 'Type "{{typeName}}" is imported as type-only but is used in a route/middleFn. Remove the "type" keyword from the import to allow runtime type reflection.',
255
- },
256
- schema: [],
257
- },
258
- defaultOptions: [],
259
- create(context) {
260
- let routerImportCache: MionRouterImports | null = null;
261
- let typeOnlyImportCache: TypeOnlyImports | null = null;
262
-
263
- /** Reports type-only imports used in handler, highlighting the specific type reference */
264
- function checkTypeReferencesWithNodes(typeRefs: TypeRefWithNode[]): void {
265
- if (!typeOnlyImportCache) return;
266
-
267
- // Track reported types to avoid duplicates
268
- const reportedTypes = new Set<string>();
269
-
270
- for (const {typeName, node} of typeRefs) {
271
- // Skip if already reported this type
272
- if (reportedTypes.has(typeName)) continue;
273
-
274
- const importDecl = typeOnlyImportCache.typeOnlyImports.get(typeName);
275
- if (importDecl) {
276
- reportedTypes.add(typeName);
277
- context.report({
278
- node,
279
- messageId: 'noTypeImports',
280
- data: {typeName},
281
- });
282
- }
283
- }
284
- }
285
-
286
- /** Checks a function node for type-only imports */
287
- function checkFunctionNode(
288
- funcNode: TSESTree.ArrowFunctionExpression | TSESTree.FunctionExpression | TSESTree.FunctionDeclaration
289
- ): void {
290
- const paramRefs = extractParamTypeReferencesWithNodes(funcNode.params);
291
- const returnRefs = extractReturnTypeReferencesWithNodes(funcNode);
292
- const allRefs = [...paramRefs, ...returnRefs];
293
-
294
- checkTypeReferencesWithNodes(allRefs);
295
- }
296
-
297
- return {
298
- Program(node) {
299
- routerImportCache = buildRouterImportCache(node);
300
- typeOnlyImportCache = buildTypeOnlyImportCache(node);
301
- },
302
-
303
- CallExpression(node: TSESTree.CallExpression) {
304
- if (!routerImportCache || !typeOnlyImportCache) return;
305
-
306
- const routerFunctionName = getRouterFunctionName(node, routerImportCache);
307
- if (!routerFunctionName) return;
308
-
309
- // Check the first argument (handler function)
310
- const handler = node.arguments[0];
311
- if (!handler) return;
312
-
313
- if (
314
- handler.type === AST_NODE_TYPES.ArrowFunctionExpression ||
315
- handler.type === AST_NODE_TYPES.FunctionExpression
316
- ) {
317
- checkFunctionNode(handler);
318
- } else if (handler.type === AST_NODE_TYPES.Identifier) {
319
- // Handler is a reference to a function - we need to find the function declaration
320
- // This is handled by checking function declarations with Handler/HeaderHandler type annotations
321
- }
322
- },
323
-
324
- // Check functions with Handler/HeaderHandler type annotations
325
- VariableDeclarator(node: TSESTree.VariableDeclarator) {
326
- if (!routerImportCache || !typeOnlyImportCache) return;
327
-
328
- // Check if the variable has a Handler or HeaderHandler type annotation
329
- if (node.id.type === AST_NODE_TYPES.Identifier && node.id.typeAnnotation) {
330
- const typeAnnotation = node.id.typeAnnotation.typeAnnotation;
331
- if (
332
- typeAnnotation.type === AST_NODE_TYPES.TSTypeReference &&
333
- typeAnnotation.typeName.type === AST_NODE_TYPES.Identifier &&
334
- routerImportCache.handlerTypes.has(typeAnnotation.typeName.name)
335
- ) {
336
- // This is a handler with type annotation
337
- if (
338
- node.init &&
339
- (node.init.type === AST_NODE_TYPES.ArrowFunctionExpression ||
340
- node.init.type === AST_NODE_TYPES.FunctionExpression)
341
- ) {
342
- checkFunctionNode(node.init);
343
- }
344
- }
345
- }
346
-
347
- // Check for satisfies expressions
348
- if (
349
- node.init &&
350
- node.init.type === AST_NODE_TYPES.TSSatisfiesExpression &&
351
- node.init.typeAnnotation.type === AST_NODE_TYPES.TSTypeReference &&
352
- node.init.typeAnnotation.typeName.type === AST_NODE_TYPES.Identifier &&
353
- routerImportCache.handlerTypes.has(node.init.typeAnnotation.typeName.name)
354
- ) {
355
- const expr = node.init.expression;
356
- if (expr.type === AST_NODE_TYPES.ArrowFunctionExpression || expr.type === AST_NODE_TYPES.FunctionExpression) {
357
- checkFunctionNode(expr);
358
- }
359
- }
360
- },
361
-
362
- // Check function declarations with JSDoc tags
363
- FunctionDeclaration(node: TSESTree.FunctionDeclaration) {
364
- if (!routerImportCache || !typeOnlyImportCache) return;
365
-
366
- // Check for JSDoc tags
367
- const sourceCode = context.sourceCode;
368
- const comments = sourceCode.getCommentsBefore(node);
369
-
370
- for (const comment of comments) {
371
- if (
372
- comment.type === 'Block' &&
373
- (comment.value.includes('@mion:route') ||
374
- comment.value.includes('@mion:middleFn') ||
375
- comment.value.includes('@mion:headersFn'))
376
- ) {
377
- checkFunctionNode(node);
378
- break;
379
- }
380
- }
381
- },
382
- };
383
- },
384
- };
385
-
386
- export default rule;
@@ -1,112 +0,0 @@
1
- /* ########
2
- * 2024 mion
3
- * Author: Ma-jerez
4
- * License: MIT
5
- * The software is provided "as is", without warranty of any kind.
6
- * ######## */
7
-
8
- import {TSESTree, TSESLint, AST_NODE_TYPES} from '@typescript-eslint/utils';
9
-
10
- /**
11
- * Recursively checks if a type node contains `typeof`.
12
- * @param typeNode The type node to check.
13
- * @returns True if `typeof` is found, otherwise false.
14
- */
15
- function containsTypeof(typeNode: TSESTree.Node | null): boolean {
16
- if (!typeNode) return false;
17
-
18
- switch (typeNode.type) {
19
- case AST_NODE_TYPES.TSTypeQuery:
20
- return true;
21
- case AST_NODE_TYPES.TSUnionType:
22
- case AST_NODE_TYPES.TSIntersectionType:
23
- return typeNode.types.some(containsTypeof);
24
- case AST_NODE_TYPES.TSTupleType:
25
- return typeNode.elementTypes.some(containsTypeof);
26
- default:
27
- return false;
28
- }
29
- }
30
-
31
- /**
32
- * Checks if a call expression is calling runType or related functions from @mionjs/run-types
33
- * @param node The call expression node
34
- * @param context The ESLint context
35
- * @returns True if it's a runType or related function call from @mionjs/run-types
36
- */
37
- function isRunTypeFromMionKit(node: TSESTree.CallExpression, context: TSESLint.RuleContext<any, any>): boolean {
38
- // List of functions that should not use typeof
39
- const runTypeFunctions = ['runType', 'isTypeFn', 'typeErrorsFn', 'mockTypeFn', 'toJavascriptFn'];
40
-
41
- // Check if the callee is an identifier with one of the runType function names
42
- if (node.callee.type !== AST_NODE_TYPES.Identifier || !runTypeFunctions.includes(node.callee.name)) {
43
- return false;
44
- }
45
-
46
- // Get the source code to check imports
47
- const sourceCode = context.sourceCode;
48
- const program = sourceCode.ast;
49
-
50
- // Look for import statements that import runType or related functions from @mionjs/run-types or relative paths
51
- for (const statement of program.body) {
52
- if (statement.type === AST_NODE_TYPES.ImportDeclaration) {
53
- const source = statement.source.value;
54
- // Check for @mionjs/run-types package or relative imports that end with runType or runTypeFunctions
55
- if (
56
- source === '@mionjs/run-types' ||
57
- source === '@mionjs/run-types/' ||
58
- (typeof source === 'string' && (source.endsWith('/runType') || source.endsWith('/runTypeFunctions')))
59
- ) {
60
- // Check if any of the runType functions are imported
61
- for (const specifier of statement.specifiers) {
62
- if (
63
- specifier.type === AST_NODE_TYPES.ImportSpecifier &&
64
- specifier.imported.type === AST_NODE_TYPES.Identifier &&
65
- runTypeFunctions.includes(specifier.imported.name)
66
- ) {
67
- return true;
68
- }
69
- }
70
- }
71
- }
72
- }
73
-
74
- return false;
75
- }
76
-
77
- const rule: TSESLint.RuleModule<'noTypeof', []> = {
78
- meta: {
79
- type: 'problem',
80
- docs: {
81
- description: 'Disallow using `typeof` with run-type functions from @mionjs/run-types',
82
- },
83
- messages: {
84
- noTypeof: 'Do not use `typeof` with `{{functionName}}()`. Use explicit type definitions instead.',
85
- },
86
- schema: [], // No options
87
- },
88
- defaultOptions: [],
89
- create(context) {
90
- return {
91
- CallExpression(node: TSESTree.CallExpression) {
92
- // Ensure the function being called is a run-type function from @mionjs/run-types
93
- if (isRunTypeFromMionKit(node, context)) {
94
- // Check if type arguments contain typeof
95
- const typeArguments = (node as any).typeArguments || (node as any).typeParameters;
96
- if (typeArguments?.params.some(containsTypeof)) {
97
- const functionName = (node.callee as TSESTree.Identifier).name;
98
- context.report({
99
- node,
100
- messageId: 'noTypeof',
101
- data: {
102
- functionName,
103
- },
104
- });
105
- }
106
- }
107
- },
108
- };
109
- },
110
- };
111
-
112
- export default rule;