@kayjs/kay 1.108.0 → 1.109.0

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 (543) hide show
  1. package/dist/eslint.js +1790 -3751
  2. package/editors/zed/extension.toml +2 -2
  3. package/llms/action-protection.md +1 -1
  4. package/llms/actions-from-islands.md +4 -4
  5. package/llms/actions-refused-fields.md +4 -4
  6. package/llms/api-from-islands.md +6 -6
  7. package/llms/browser-only.md +2 -2
  8. package/llms/cdn-caching.md +1 -1
  9. package/llms/checks.md +1 -1
  10. package/llms/code-lints.md +1 -2
  11. package/llms/component-library-conventions.md +1 -1
  12. package/llms/components.md +4 -4
  13. package/llms/deprecated-lints.md +1 -6
  14. package/llms/effects.md +1 -1
  15. package/llms/errors.md +2 -2
  16. package/llms/events.md +1 -1
  17. package/llms/guards.md +1 -1
  18. package/llms/head.md +1 -1
  19. package/llms/hooks.md +2 -2
  20. package/llms/images.md +1 -1
  21. package/llms/island-and-form-lints.md +2 -1
  22. package/llms/island-sources.md +1 -1
  23. package/llms/islands-state-to-ids.md +2 -2
  24. package/llms/islands.md +4 -2
  25. package/llms/lints.md +1 -1
  26. package/llms/live-values.md +3 -3
  27. package/llms/local-collections.md +1 -1
  28. package/llms/locales.md +1 -1
  29. package/llms/mcp.md +2 -2
  30. package/llms/metrics.md +1 -1
  31. package/llms/navigation-from-code.md +6 -6
  32. package/llms/prerendering.md +1 -0
  33. package/llms/production.md +2 -2
  34. package/llms/project-new-and-add.md +1 -1
  35. package/llms/project.md +4 -4
  36. package/llms/proxy-and-security.md +1 -1
  37. package/llms/queues.md +1 -1
  38. package/llms/rate-limits.md +4 -4
  39. package/llms/rendering.md +1 -1
  40. package/llms/server-islands.md +2 -2
  41. package/llms/server.md +1 -1
  42. package/llms/stores.md +1 -1
  43. package/llms/styles-and-assets.md +1 -1
  44. package/llms/testing-mount.md +49 -0
  45. package/llms/testing.md +4 -45
  46. package/llms/upgrading-1-105-config.md +13 -13
  47. package/llms/upgrading-archive.md +42 -82
  48. package/llms/upgrading.md +91 -63
  49. package/llms/whats-new.md +9 -0
  50. package/llms.txt +5 -6
  51. package/package.json +6 -10
  52. package/src/build/route-sizes.ts +2 -3
  53. package/src/check/browser-global-reads.ts +2 -2
  54. package/src/check/config-objects.ts +1 -1
  55. package/src/check/diagnose.ts +0 -22
  56. package/src/check/export-homes.ts +1 -1
  57. package/src/check/guards.ts +3 -3
  58. package/src/check/index.ts +2 -7
  59. package/src/check/moved-keys.ts +1 -1
  60. package/src/check/project.ts +3 -8
  61. package/src/check/shadow-types.ts +0 -86
  62. package/src/commands/check.ts +2 -2
  63. package/src/commands/env.ts +25 -3
  64. package/src/compiler/ast.ts +18 -16
  65. package/src/compiler/browser.ts +2 -14
  66. package/src/compiler/class-items.ts +16 -0
  67. package/src/compiler/codegen.ts +8 -8
  68. package/src/compiler/deprecated-library.ts +0 -12
  69. package/src/compiler/deprecated-lints.ts +3 -495
  70. package/src/compiler/deprecated-ui-props.ts +5 -5
  71. package/src/compiler/errors.ts +2 -2
  72. package/src/compiler/fence-checks.ts +2 -121
  73. package/src/compiler/hand-parts.ts +55 -0
  74. package/src/compiler/helper-imports.ts +2 -2
  75. package/src/compiler/image-attributes.ts +1 -3
  76. package/src/compiler/index.ts +20 -21
  77. package/src/compiler/island-arguments.ts +8 -95
  78. package/src/compiler/island-cause.ts +7 -7
  79. package/src/compiler/island-declaration.ts +2 -8
  80. package/src/compiler/island-lints.ts +12 -0
  81. package/src/compiler/island-marker.ts +3 -3
  82. package/src/compiler/island-problems.ts +25 -0
  83. package/src/compiler/jsx-class.ts +1 -25
  84. package/src/compiler/jsx.ts +2 -2
  85. package/src/compiler/kay-exports.ts +0 -2
  86. package/src/compiler/link-flags.ts +9 -38
  87. package/src/compiler/lints.ts +7 -14
  88. package/src/compiler/markup.ts +23 -26
  89. package/src/compiler/module-signals.ts +2 -2
  90. package/src/compiler/names.ts +1 -1
  91. package/src/compiler/page-settings.ts +11 -0
  92. package/src/compiler/parser.ts +6 -8
  93. package/src/compiler/plan.ts +1 -3
  94. package/src/compiler/rewrite.ts +3 -18
  95. package/src/compiler/script-server.ts +8 -3
  96. package/src/compiler/validate.ts +3 -8
  97. package/src/config-loader.ts +14 -4
  98. package/src/config-resolve.ts +18 -142
  99. package/src/config-shape.ts +44 -34
  100. package/src/config.ts +10 -114
  101. package/src/dev/preload.ts +4 -1
  102. package/src/lsp/server.ts +4 -0
  103. package/src/migrate/markup.ts +4 -1
  104. package/src/runtime/action-call.ts +0 -8
  105. package/src/runtime/action-encode.ts +26 -0
  106. package/src/runtime/action-error.ts +3 -11
  107. package/src/runtime/action-protection.ts +2 -2
  108. package/src/runtime/action-run.ts +2 -27
  109. package/src/runtime/action-shared.ts +14 -37
  110. package/src/runtime/action-stream.ts +0 -1
  111. package/src/runtime/action.ts +1 -1
  112. package/src/runtime/call-result.ts +2 -10
  113. package/src/runtime/checks.ts +11 -11
  114. package/src/runtime/client.ts +2 -2
  115. package/src/runtime/core.ts +5 -23
  116. package/src/runtime/dom.ts +1 -1
  117. package/src/runtime/html.ts +1 -1
  118. package/src/runtime/i18n.client.ts +1 -4
  119. package/src/runtime/i18n.server.ts +1 -4
  120. package/src/runtime/i18n.ts +3 -3
  121. package/src/runtime/index.ts +2 -2
  122. package/src/runtime/island.server.ts +18 -5
  123. package/src/runtime/live-resource.server.ts +0 -1
  124. package/src/runtime/live-value.server.ts +2 -2
  125. package/src/runtime/live-value.shared.ts +7 -20
  126. package/src/runtime/live.ts +1 -12
  127. package/src/runtime/local-types.ts +1 -11
  128. package/src/runtime/local.ts +4 -14
  129. package/src/runtime/navigate-api.ts +2 -5
  130. package/src/runtime/navigation-state.ts +0 -12
  131. package/src/runtime/page-swap.ts +6 -6
  132. package/src/runtime/persist.ts +11 -3
  133. package/src/runtime/persisted.ts +4 -30
  134. package/src/runtime/presence.ts +6 -7
  135. package/src/runtime/query-param.ts +20 -12
  136. package/src/runtime/reactive.ts +3 -1
  137. package/src/runtime/refuse.ts +3 -17
  138. package/src/runtime/store-base.ts +4 -6
  139. package/src/runtime/swap-fetch.ts +1 -1
  140. package/src/runtime/values.ts +40 -23
  141. package/src/runtime/with-query.ts +9 -0
  142. package/src/server/action-hooks.ts +8 -8
  143. package/src/server/actions.ts +13 -14
  144. package/src/server/api-modules.ts +2 -3
  145. package/src/server/app-stages.ts +15 -33
  146. package/src/server/app.ts +10 -5
  147. package/src/server/auth-mails.ts +0 -2
  148. package/src/server/env-state.ts +40 -10
  149. package/src/server/flash.ts +1 -1
  150. package/src/server/guard-requirement.ts +4 -4
  151. package/src/server/image.ts +2 -2
  152. package/src/server/index.ts +0 -2
  153. package/src/server/job-context.ts +3 -3
  154. package/src/server/jobs-page.ts +1 -1
  155. package/src/server/jobs.ts +5 -9
  156. package/src/server/kept-exports.ts +0 -2
  157. package/src/server/kv.ts +11 -14
  158. package/src/server/library.ts +1 -3
  159. package/src/server/live.ts +2 -2
  160. package/src/server/mcp.ts +3 -9
  161. package/src/server/metrics.ts +2 -4
  162. package/src/server/page-settings.ts +10 -19
  163. package/src/server/prerender.ts +19 -2
  164. package/src/server/protection.ts +15 -18
  165. package/src/server/queue.ts +3 -6
  166. package/src/server/rate-limit.ts +0 -3
  167. package/src/server/render-document.ts +1 -1
  168. package/src/server/routes.ts +7 -3
  169. package/src/server/scope.ts +3 -2
  170. package/src/server/session.ts +5 -6
  171. package/src/server/setup.ts +1 -1
  172. package/src/server/signals.ts +17 -7
  173. package/src/server/signed.ts +1 -3
  174. package/src/server/source.ts +20 -4
  175. package/src/server/speculation.ts +1 -1
  176. package/src/server/storage.ts +3 -8
  177. package/src/server/validate.ts +1 -1
  178. package/src/server/vitals.ts +1 -3
  179. package/src/server/work-scope.ts +2 -4
  180. package/src/server/work.ts +1 -1
  181. package/src/server/workflow.ts +1 -1
  182. package/src/test/index.ts +2 -1
  183. package/src/test/site-actions.ts +16 -6
  184. package/src/test/site-keys.ts +10 -15
  185. package/src/test/site-socket.ts +1 -2
  186. package/src/test/site-types.ts +0 -8
  187. package/types/build/route-sizes.d.ts.map +1 -1
  188. package/types/check/diagnose.d.ts.map +1 -1
  189. package/types/check/index.d.ts +1 -2
  190. package/types/check/index.d.ts.map +1 -1
  191. package/types/check/project.d.ts.map +1 -1
  192. package/types/check/shadow-types.d.ts.map +1 -1
  193. package/types/commands/env.d.ts.map +1 -1
  194. package/types/compiler/ast.d.ts +1 -2
  195. package/types/compiler/ast.d.ts.map +1 -1
  196. package/types/compiler/browser.d.ts.map +1 -1
  197. package/types/compiler/class-items.d.ts +7 -0
  198. package/types/compiler/class-items.d.ts.map +1 -0
  199. package/types/compiler/deprecated-library.d.ts.map +1 -1
  200. package/types/compiler/deprecated-lints.d.ts +0 -551
  201. package/types/compiler/deprecated-lints.d.ts.map +1 -1
  202. package/types/compiler/deprecated-ui-props.d.ts +1 -8
  203. package/types/compiler/deprecated-ui-props.d.ts.map +1 -1
  204. package/types/compiler/errors.d.ts +2 -2
  205. package/types/compiler/errors.d.ts.map +1 -1
  206. package/types/compiler/fence-checks.d.ts +0 -1
  207. package/types/compiler/fence-checks.d.ts.map +1 -1
  208. package/types/compiler/hand-parts.d.ts +7 -0
  209. package/types/compiler/hand-parts.d.ts.map +1 -0
  210. package/types/compiler/image-attributes.d.ts +0 -1
  211. package/types/compiler/image-attributes.d.ts.map +1 -1
  212. package/types/compiler/index.d.ts.map +1 -1
  213. package/types/compiler/island-arguments.d.ts +2 -11
  214. package/types/compiler/island-arguments.d.ts.map +1 -1
  215. package/types/compiler/island-cause.d.ts +1 -1
  216. package/types/compiler/island-cause.d.ts.map +1 -1
  217. package/types/compiler/island-declaration.d.ts +1 -3
  218. package/types/compiler/island-declaration.d.ts.map +1 -1
  219. package/types/compiler/island-lints.d.ts +10 -0
  220. package/types/compiler/island-lints.d.ts.map +1 -0
  221. package/types/compiler/island-problems.d.ts +7 -0
  222. package/types/compiler/island-problems.d.ts.map +1 -0
  223. package/types/compiler/jsx-class.d.ts +1 -2
  224. package/types/compiler/jsx-class.d.ts.map +1 -1
  225. package/types/compiler/kay-exports.d.ts.map +1 -1
  226. package/types/compiler/link-flags.d.ts +0 -6
  227. package/types/compiler/link-flags.d.ts.map +1 -1
  228. package/types/compiler/lints.d.ts +11 -563
  229. package/types/compiler/lints.d.ts.map +1 -1
  230. package/types/compiler/markup.d.ts +1 -1
  231. package/types/compiler/markup.d.ts.map +1 -1
  232. package/types/compiler/module-signals.d.ts.map +1 -1
  233. package/types/compiler/names.d.ts.map +1 -1
  234. package/types/compiler/page-settings.d.ts +4 -0
  235. package/types/compiler/page-settings.d.ts.map +1 -1
  236. package/types/compiler/parser.d.ts.map +1 -1
  237. package/types/compiler/plan.d.ts.map +1 -1
  238. package/types/compiler/script-server.d.ts.map +1 -1
  239. package/types/compiler/validate.d.ts.map +1 -1
  240. package/types/config-loader.d.ts.map +1 -1
  241. package/types/config-resolve.d.ts.map +1 -1
  242. package/types/config-shape.d.ts +1 -1
  243. package/types/config-shape.d.ts.map +1 -1
  244. package/types/config.d.ts +5 -105
  245. package/types/config.d.ts.map +1 -1
  246. package/types/dev/preload.d.ts.map +1 -1
  247. package/types/lsp/server.d.ts.map +1 -1
  248. package/types/migrate/markup.d.ts.map +1 -1
  249. package/types/runtime/action-call.d.ts.map +1 -1
  250. package/types/runtime/action-encode.d.ts +1 -0
  251. package/types/runtime/action-encode.d.ts.map +1 -1
  252. package/types/runtime/action-error.d.ts +1 -2
  253. package/types/runtime/action-error.d.ts.map +1 -1
  254. package/types/runtime/action-run.d.ts.map +1 -1
  255. package/types/runtime/action-shared.d.ts +1 -27
  256. package/types/runtime/action-shared.d.ts.map +1 -1
  257. package/types/runtime/action-stream.d.ts.map +1 -1
  258. package/types/runtime/action.d.ts +1 -1
  259. package/types/runtime/action.d.ts.map +1 -1
  260. package/types/runtime/call-result.d.ts +0 -10
  261. package/types/runtime/call-result.d.ts.map +1 -1
  262. package/types/runtime/checks.d.ts +6 -9
  263. package/types/runtime/checks.d.ts.map +1 -1
  264. package/types/runtime/core.d.ts +2 -20
  265. package/types/runtime/core.d.ts.map +1 -1
  266. package/types/runtime/dom.d.ts +1 -1
  267. package/types/runtime/dom.d.ts.map +1 -1
  268. package/types/runtime/html.d.ts +1 -1
  269. package/types/runtime/html.d.ts.map +1 -1
  270. package/types/runtime/i18n.client.d.ts +0 -1
  271. package/types/runtime/i18n.client.d.ts.map +1 -1
  272. package/types/runtime/i18n.d.ts +1 -1
  273. package/types/runtime/i18n.d.ts.map +1 -1
  274. package/types/runtime/i18n.server.d.ts +0 -1
  275. package/types/runtime/i18n.server.d.ts.map +1 -1
  276. package/types/runtime/index.d.ts +2 -2
  277. package/types/runtime/index.d.ts.map +1 -1
  278. package/types/runtime/island.server.d.ts +1 -0
  279. package/types/runtime/island.server.d.ts.map +1 -1
  280. package/types/runtime/live-resource.server.d.ts.map +1 -1
  281. package/types/runtime/live-value.shared.d.ts +7 -15
  282. package/types/runtime/live-value.shared.d.ts.map +1 -1
  283. package/types/runtime/live.d.ts +0 -11
  284. package/types/runtime/live.d.ts.map +1 -1
  285. package/types/runtime/local-types.d.ts +0 -14
  286. package/types/runtime/local-types.d.ts.map +1 -1
  287. package/types/runtime/navigate-api.d.ts +0 -4
  288. package/types/runtime/navigate-api.d.ts.map +1 -1
  289. package/types/runtime/navigation-state.d.ts +0 -4
  290. package/types/runtime/navigation-state.d.ts.map +1 -1
  291. package/types/runtime/page-swap.d.ts.map +1 -1
  292. package/types/runtime/persist.d.ts +1 -0
  293. package/types/runtime/persist.d.ts.map +1 -1
  294. package/types/runtime/persisted.d.ts +0 -15
  295. package/types/runtime/persisted.d.ts.map +1 -1
  296. package/types/runtime/presence.d.ts +0 -2
  297. package/types/runtime/presence.d.ts.map +1 -1
  298. package/types/runtime/query-param.d.ts.map +1 -1
  299. package/types/runtime/reactive.d.ts +2 -1
  300. package/types/runtime/reactive.d.ts.map +1 -1
  301. package/types/runtime/refuse.d.ts +0 -7
  302. package/types/runtime/refuse.d.ts.map +1 -1
  303. package/types/runtime/store-base.d.ts +1 -2
  304. package/types/runtime/store-base.d.ts.map +1 -1
  305. package/types/runtime/values.d.ts +2 -1
  306. package/types/runtime/values.d.ts.map +1 -1
  307. package/types/runtime/with-query.d.ts +2 -0
  308. package/types/runtime/with-query.d.ts.map +1 -1
  309. package/types/server/action-hooks.d.ts +4 -4
  310. package/types/server/action-hooks.d.ts.map +1 -1
  311. package/types/server/actions.d.ts.map +1 -1
  312. package/types/server/api-modules.d.ts +0 -1
  313. package/types/server/api-modules.d.ts.map +1 -1
  314. package/types/server/app-stages.d.ts +5 -13
  315. package/types/server/app-stages.d.ts.map +1 -1
  316. package/types/server/app.d.ts +3 -8
  317. package/types/server/app.d.ts.map +1 -1
  318. package/types/server/auth-mails.d.ts +0 -5
  319. package/types/server/auth-mails.d.ts.map +1 -1
  320. package/types/server/env-state.d.ts +1 -0
  321. package/types/server/env-state.d.ts.map +1 -1
  322. package/types/server/guard-requirement.d.ts +0 -1
  323. package/types/server/guard-requirement.d.ts.map +1 -1
  324. package/types/server/image.d.ts +0 -1
  325. package/types/server/image.d.ts.map +1 -1
  326. package/types/server/index.d.ts +0 -2
  327. package/types/server/index.d.ts.map +1 -1
  328. package/types/server/job-context.d.ts +1 -1
  329. package/types/server/job-context.d.ts.map +1 -1
  330. package/types/server/jobs.d.ts +0 -4
  331. package/types/server/jobs.d.ts.map +1 -1
  332. package/types/server/kept-exports.d.ts.map +1 -1
  333. package/types/server/kv.d.ts +4 -4
  334. package/types/server/kv.d.ts.map +1 -1
  335. package/types/server/library.d.ts +1 -3
  336. package/types/server/library.d.ts.map +1 -1
  337. package/types/server/mcp.d.ts +0 -1
  338. package/types/server/mcp.d.ts.map +1 -1
  339. package/types/server/metrics.d.ts +0 -5
  340. package/types/server/metrics.d.ts.map +1 -1
  341. package/types/server/page-settings.d.ts +3 -3
  342. package/types/server/page-settings.d.ts.map +1 -1
  343. package/types/server/prerender.d.ts.map +1 -1
  344. package/types/server/protection.d.ts +6 -6
  345. package/types/server/protection.d.ts.map +1 -1
  346. package/types/server/queue.d.ts +1 -3
  347. package/types/server/queue.d.ts.map +1 -1
  348. package/types/server/rate-limit.d.ts +0 -2
  349. package/types/server/rate-limit.d.ts.map +1 -1
  350. package/types/server/routes.d.ts +1 -1
  351. package/types/server/routes.d.ts.map +1 -1
  352. package/types/server/scope.d.ts.map +1 -1
  353. package/types/server/session.d.ts +1 -1
  354. package/types/server/session.d.ts.map +1 -1
  355. package/types/server/signals.d.ts.map +1 -1
  356. package/types/server/signed.d.ts +0 -2
  357. package/types/server/signed.d.ts.map +1 -1
  358. package/types/server/source.d.ts +1 -1
  359. package/types/server/source.d.ts.map +1 -1
  360. package/types/server/storage.d.ts +0 -4
  361. package/types/server/storage.d.ts.map +1 -1
  362. package/types/server/vitals.d.ts +0 -1
  363. package/types/server/vitals.d.ts.map +1 -1
  364. package/types/server/work-scope.d.ts +0 -2
  365. package/types/server/work-scope.d.ts.map +1 -1
  366. package/types/server/workflow.d.ts +1 -1
  367. package/types/server/workflow.d.ts.map +1 -1
  368. package/types/test/index.d.ts.map +1 -1
  369. package/types/test/site-actions.d.ts +1 -1
  370. package/types/test/site-actions.d.ts.map +1 -1
  371. package/types/test/site-keys.d.ts +1 -1
  372. package/types/test/site-keys.d.ts.map +1 -1
  373. package/types/test/site-socket.d.ts +1 -1
  374. package/types/test/site-socket.d.ts.map +1 -1
  375. package/types/test/site-types.d.ts +0 -8
  376. package/types/test/site-types.d.ts.map +1 -1
  377. package/llms/deprecated-lints-1-105-libraries.md +0 -32
  378. package/llms/deprecated-lints-1-105.md +0 -58
  379. package/src/check/action-readers.ts +0 -115
  380. package/src/check/action-type.ts +0 -44
  381. package/src/check/ai-language.ts +0 -56
  382. package/src/check/app-hooks.ts +0 -90
  383. package/src/check/auth-methods.ts +0 -85
  384. package/src/check/auth-rate-limits.ts +0 -99
  385. package/src/check/call-result.ts +0 -242
  386. package/src/check/client-keys.ts +0 -10
  387. package/src/check/cms-options.ts +0 -81
  388. package/src/check/config-groups.ts +0 -22
  389. package/src/check/config-switches.ts +0 -38
  390. package/src/check/context-import.ts +0 -51
  391. package/src/check/env-files.ts +0 -31
  392. package/src/check/format-duration.ts +0 -75
  393. package/src/check/guard-options.ts +0 -58
  394. package/src/check/handler-events.ts +0 -149
  395. package/src/check/hook-context.ts +0 -94
  396. package/src/check/hook-names.ts +0 -104
  397. package/src/check/i18n-keys.ts +0 -50
  398. package/src/check/images-keys.ts +0 -54
  399. package/src/check/job-shapes.ts +0 -273
  400. package/src/check/link-flag-tests.ts +0 -130
  401. package/src/check/live-api.ts +0 -137
  402. package/src/check/mail-api.ts +0 -67
  403. package/src/check/one-state-api.ts +0 -357
  404. package/src/check/pages-options.ts +0 -35
  405. package/src/check/rate-enforce.ts +0 -53
  406. package/src/check/refusal-calls.ts +0 -185
  407. package/src/check/retired-lints.ts +0 -49
  408. package/src/check/route-keys.ts +0 -166
  409. package/src/check/secret-keys.ts +0 -83
  410. package/src/check/socket-frames.ts +0 -102
  411. package/src/check/source-readers.ts +0 -257
  412. package/src/check/store-ms.ts +0 -72
  413. package/src/check/store-names.ts +0 -88
  414. package/src/check/test-helpers.ts +0 -98
  415. package/src/check/ttl-names.ts +0 -142
  416. package/src/compiler/deprecated-ai-labels.ts +0 -97
  417. package/src/compiler/deprecated-ai-links.ts +0 -63
  418. package/src/compiler/deprecated-allow.ts +0 -50
  419. package/src/compiler/deprecated-auth-lints.ts +0 -14
  420. package/src/compiler/deprecated-auth-signed.ts +0 -29
  421. package/src/compiler/deprecated-children.ts +0 -66
  422. package/src/compiler/deprecated-image.ts +0 -116
  423. package/src/compiler/deprecated-island.ts +0 -155
  424. package/src/compiler/deprecated-lints-1-105.ts +0 -41
  425. package/src/compiler/deprecated-page.ts +0 -125
  426. package/src/compiler/deprecated-parts.ts +0 -22
  427. package/src/compiler/deprecated-typed-lints.ts +0 -23
  428. package/src/compiler/deprecated-ui-callbacks.ts +0 -66
  429. package/src/compiler/deprecated-ui-input.ts +0 -97
  430. package/src/compiler/deprecated-ui-items.ts +0 -47
  431. package/src/compiler/old-parts.ts +0 -84
  432. package/src/runtime/mount.compat.ts +0 -8
  433. package/src/server/moved-exports.ts +0 -17
  434. package/types/check/action-readers.d.ts +0 -3
  435. package/types/check/action-readers.d.ts.map +0 -1
  436. package/types/check/action-type.d.ts +0 -3
  437. package/types/check/action-type.d.ts.map +0 -1
  438. package/types/check/ai-language.d.ts +0 -3
  439. package/types/check/ai-language.d.ts.map +0 -1
  440. package/types/check/app-hooks.d.ts +0 -3
  441. package/types/check/app-hooks.d.ts.map +0 -1
  442. package/types/check/auth-methods.d.ts +0 -3
  443. package/types/check/auth-methods.d.ts.map +0 -1
  444. package/types/check/auth-rate-limits.d.ts +0 -3
  445. package/types/check/auth-rate-limits.d.ts.map +0 -1
  446. package/types/check/call-result.d.ts +0 -7
  447. package/types/check/call-result.d.ts.map +0 -1
  448. package/types/check/client-keys.d.ts +0 -3
  449. package/types/check/client-keys.d.ts.map +0 -1
  450. package/types/check/cms-options.d.ts +0 -3
  451. package/types/check/cms-options.d.ts.map +0 -1
  452. package/types/check/config-groups.d.ts +0 -3
  453. package/types/check/config-groups.d.ts.map +0 -1
  454. package/types/check/config-switches.d.ts +0 -3
  455. package/types/check/config-switches.d.ts.map +0 -1
  456. package/types/check/context-import.d.ts +0 -3
  457. package/types/check/context-import.d.ts.map +0 -1
  458. package/types/check/env-files.d.ts +0 -3
  459. package/types/check/env-files.d.ts.map +0 -1
  460. package/types/check/format-duration.d.ts +0 -5
  461. package/types/check/format-duration.d.ts.map +0 -1
  462. package/types/check/guard-options.d.ts +0 -3
  463. package/types/check/guard-options.d.ts.map +0 -1
  464. package/types/check/handler-events.d.ts +0 -9
  465. package/types/check/handler-events.d.ts.map +0 -1
  466. package/types/check/hook-context.d.ts +0 -3
  467. package/types/check/hook-context.d.ts.map +0 -1
  468. package/types/check/hook-names.d.ts +0 -3
  469. package/types/check/hook-names.d.ts.map +0 -1
  470. package/types/check/i18n-keys.d.ts +0 -3
  471. package/types/check/i18n-keys.d.ts.map +0 -1
  472. package/types/check/images-keys.d.ts +0 -3
  473. package/types/check/images-keys.d.ts.map +0 -1
  474. package/types/check/job-shapes.d.ts +0 -6
  475. package/types/check/job-shapes.d.ts.map +0 -1
  476. package/types/check/link-flag-tests.d.ts +0 -4
  477. package/types/check/link-flag-tests.d.ts.map +0 -1
  478. package/types/check/live-api.d.ts +0 -3
  479. package/types/check/live-api.d.ts.map +0 -1
  480. package/types/check/mail-api.d.ts +0 -3
  481. package/types/check/mail-api.d.ts.map +0 -1
  482. package/types/check/one-state-api.d.ts +0 -9
  483. package/types/check/one-state-api.d.ts.map +0 -1
  484. package/types/check/pages-options.d.ts +0 -3
  485. package/types/check/pages-options.d.ts.map +0 -1
  486. package/types/check/rate-enforce.d.ts +0 -3
  487. package/types/check/rate-enforce.d.ts.map +0 -1
  488. package/types/check/refusal-calls.d.ts +0 -3
  489. package/types/check/refusal-calls.d.ts.map +0 -1
  490. package/types/check/retired-lints.d.ts +0 -3
  491. package/types/check/retired-lints.d.ts.map +0 -1
  492. package/types/check/route-keys.d.ts +0 -3
  493. package/types/check/route-keys.d.ts.map +0 -1
  494. package/types/check/secret-keys.d.ts +0 -3
  495. package/types/check/secret-keys.d.ts.map +0 -1
  496. package/types/check/socket-frames.d.ts +0 -3
  497. package/types/check/socket-frames.d.ts.map +0 -1
  498. package/types/check/source-readers.d.ts +0 -3
  499. package/types/check/source-readers.d.ts.map +0 -1
  500. package/types/check/store-ms.d.ts +0 -3
  501. package/types/check/store-ms.d.ts.map +0 -1
  502. package/types/check/store-names.d.ts +0 -3
  503. package/types/check/store-names.d.ts.map +0 -1
  504. package/types/check/test-helpers.d.ts +0 -3
  505. package/types/check/test-helpers.d.ts.map +0 -1
  506. package/types/check/ttl-names.d.ts +0 -3
  507. package/types/check/ttl-names.d.ts.map +0 -1
  508. package/types/compiler/deprecated-ai-labels.d.ts +0 -5
  509. package/types/compiler/deprecated-ai-labels.d.ts.map +0 -1
  510. package/types/compiler/deprecated-ai-links.d.ts +0 -5
  511. package/types/compiler/deprecated-ai-links.d.ts.map +0 -1
  512. package/types/compiler/deprecated-allow.d.ts +0 -5
  513. package/types/compiler/deprecated-allow.d.ts.map +0 -1
  514. package/types/compiler/deprecated-auth-lints.d.ts +0 -12
  515. package/types/compiler/deprecated-auth-lints.d.ts.map +0 -1
  516. package/types/compiler/deprecated-auth-signed.d.ts +0 -5
  517. package/types/compiler/deprecated-auth-signed.d.ts.map +0 -1
  518. package/types/compiler/deprecated-children.d.ts +0 -4
  519. package/types/compiler/deprecated-children.d.ts.map +0 -1
  520. package/types/compiler/deprecated-image.d.ts +0 -5
  521. package/types/compiler/deprecated-image.d.ts.map +0 -1
  522. package/types/compiler/deprecated-island.d.ts +0 -9
  523. package/types/compiler/deprecated-island.d.ts.map +0 -1
  524. package/types/compiler/deprecated-lints-1-105.d.ts +0 -39
  525. package/types/compiler/deprecated-lints-1-105.d.ts.map +0 -1
  526. package/types/compiler/deprecated-page.d.ts +0 -4
  527. package/types/compiler/deprecated-page.d.ts.map +0 -1
  528. package/types/compiler/deprecated-parts.d.ts +0 -3
  529. package/types/compiler/deprecated-parts.d.ts.map +0 -1
  530. package/types/compiler/deprecated-typed-lints.d.ts +0 -21
  531. package/types/compiler/deprecated-typed-lints.d.ts.map +0 -1
  532. package/types/compiler/deprecated-ui-callbacks.d.ts +0 -5
  533. package/types/compiler/deprecated-ui-callbacks.d.ts.map +0 -1
  534. package/types/compiler/deprecated-ui-input.d.ts +0 -5
  535. package/types/compiler/deprecated-ui-input.d.ts.map +0 -1
  536. package/types/compiler/deprecated-ui-items.d.ts +0 -5
  537. package/types/compiler/deprecated-ui-items.d.ts.map +0 -1
  538. package/types/compiler/old-parts.d.ts +0 -9
  539. package/types/compiler/old-parts.d.ts.map +0 -1
  540. package/types/runtime/mount.compat.d.ts +0 -7
  541. package/types/runtime/mount.compat.d.ts.map +0 -1
  542. package/types/server/moved-exports.d.ts +0 -12
  543. package/types/server/moved-exports.d.ts.map +0 -1
@@ -1,99 +0,0 @@
1
- import type { CheckDiagnostic, CheckOptions } from '.'
2
- import type { Property } from './regroup'
3
- import { lintLevel } from '../compiler/lints'
4
- import { keyName } from '../compiler/object-literal'
5
- import { renamePackages } from '../package-names'
6
- import { importsOf, walk } from './ast'
7
- import { nameOf, regrouped } from './regroup'
8
- import { scan } from './renamed-exports'
9
-
10
- const NEEDLE = /\brateLimit\b/
11
- const FROM_AUTH = (source: string) => renamePackages(source) === '@kayjs/auth'
12
- const CALLS = ['auth', 'authCore']
13
- const HELP = 'group the limit under its feature, `signIn: { ip, account }`'
14
-
15
- // The parts of each feature, the first being what a bare limit on the feature was.
16
- const GROUPS: Record<string, string[]> = {
17
- signIn: ['ip', 'account', 'accountAll'],
18
- resend: ['ip', 'account'],
19
- forgot: ['ip', 'account'],
20
- magicLink: ['ip', 'account'],
21
- emailChange: ['ip', 'account'],
22
- twoFactor: ['ip', 'account'],
23
- emailCode: ['ip', 'account'],
24
- invite: ['sender', 'address'],
25
- oauth: ['register', 'registerAll', 'document', 'token'],
26
- }
27
-
28
- // The flat keys of before 1.105 that are not a feature's first part, and the part they became.
29
- const FLAT: Record<string, [string, string]> = {
30
- signInAccount: ['signIn', 'account'],
31
- signInAccountAll: ['signIn', 'accountAll'],
32
- resendAccount: ['resend', 'account'],
33
- forgotAccount: ['forgot', 'account'],
34
- magicLinkAccount: ['magicLink', 'account'],
35
- emailChangeAccount: ['emailChange', 'account'],
36
- twoFactorAccount: ['twoFactor', 'account'],
37
- emailCodeAccount: ['emailCode', 'account'],
38
- inviteAddress: ['invite', 'address'],
39
- oauthRegister: ['oauth', 'register'],
40
- oauthRegisterAll: ['oauth', 'registerAll'],
41
- oauthDocument: ['oauth', 'document'],
42
- oauthToken: ['oauth', 'token'],
43
- }
44
-
45
- // The limits of kayjs-auth's `rateLimit` as 26 flat keys, grouped by feature since 1.105: `signIn: { ip, account, accountAll }`, `forgot: { ip, account }`, `invite: { sender, address }`, `oauth: { register, registerAll, document, token }`.
46
- // Found in the `rateLimit` object written in a call of `auth` or `authCore` imported from `@kayjs/auth`; the fix, from the first report, rewrites only the keys it moves and offers none where the object spreads, holds a computed or shorthand key, names a part twice or writes a feature both ways.
47
- export async function authRateLimits(root: string, options: CheckOptions): Promise<CheckDiagnostic[]> {
48
- if (lintLevel('deprecated-auth-rate-limits', options.lints) === 'allow')
49
- return []
50
-
51
- return scan(root, options, 'deprecated-auth-rate-limits', NEEDLE, ({ parsed, report }) => {
52
- for (const { ast, base, text } of parsed) {
53
- const found = CALLS.map(name => importsOf(ast, FROM_AUTH, name))
54
-
55
- if (found.every(({ locals, namespaces }) => locals.size === 0 && namespaces.size === 0))
56
- continue
57
-
58
- walk(ast, (node) => {
59
- if (node.type !== 'CallExpression' || !found.some(({ locals, namespaces }) => node.callee.type === 'Identifier' ? locals.has(node.callee.name) : node.callee.type === 'MemberExpression' && node.callee.object.type === 'Identifier' && namespaces.has(node.callee.object.name)))
60
- return
61
-
62
- const first = node.arguments[0]
63
- const argument = first?.type === 'TSAsExpression' || first?.type === 'TSSatisfiesExpression' ? first.expression : first
64
- const limits = argument?.type === 'ObjectExpression' ? argument.properties.find((property): property is Property => property.type === 'Property' && !property.computed && keyName(property) === 'rateLimit') : undefined
65
-
66
- if (limits?.value.type !== 'ObjectExpression')
67
- return
68
-
69
- const old = limits.value.properties.filter((property): property is Property => property.type === 'Property' && !property.computed && isOld(property))
70
-
71
- if (old.length === 0)
72
- return
73
-
74
- const fixed = regrouped(limits.value, text, movedTo)
75
-
76
- for (const [index, property] of old.entries())
77
- report(base + property.start, base + property.end, `\`${nameOf(property)}\` of kayjs-auth's \`rateLimit\` is grouped by feature since 1.105`, HELP, index === 0 && fixed !== undefined ? fixed.map(edit => ({ ...edit, start: base + edit.start, end: base + edit.end })) : null)
78
- })
79
- }
80
- })
81
- }
82
-
83
- // A flat key that is a part of a feature, or a feature written as a bare limit or a list.
84
- function isOld(property: Property): boolean {
85
- const name = nameOf(property)
86
-
87
- if (Object.hasOwn(FLAT, name))
88
- return true
89
-
90
- return Object.hasOwn(GROUPS, name) && (property.value.type === 'ArrayExpression' || (property.value.type === 'ObjectExpression' && property.value.properties.some(inner => inner.type === 'Property' && nameOf(inner) === 'max')))
91
- }
92
-
93
- // Where an old property goes, as its feature and part.
94
- function movedTo(name: string, property: Property): [string, string] | undefined {
95
- if (Object.hasOwn(FLAT, name))
96
- return FLAT[name]
97
-
98
- return isOld(property) ? [name, GROUPS[name]![0]!] : undefined
99
- }
@@ -1,242 +0,0 @@
1
- import type { CheckDiagnostic } from '.'
2
- import type { Span } from '../compiler/ast'
3
- import type { Node, Program } from '../compiler/estree'
4
- import type { LintLevels } from '../compiler/lints'
5
- import type { OldFormLint } from './handler-events'
6
- import { parseProgram } from '../compiler/estree'
7
- import { lintLevels } from '../compiler/lints'
8
- import { offsetAt } from '../compiler/mapping'
9
- import { parseKay } from '../compiler/parser'
10
- import { childrenOf } from './ast'
11
-
12
- // A result narrowed by a read of `ok` is named by its members, `{ ok: true; data: ... }`.
13
- const MISSING = /^Property '[^']+' does not exist on type '(?:CallResult<|\{ ok: (?:true|false); )/
14
- const MODULE = /\.[cm]?tsx?$/
15
- const MISMATCH = /^(?:Type|Argument of type) 'CallResult</
16
- // What a result has of its own: a use of one of these means the code already reads a `CallResult`.
17
- const RESULT_KEYS = new Set(['ok', 'data', 'error', 'errors', 'status', 'message', 'orThrow'])
18
-
19
- // The spans of a `.kay` file's script, server and module fences, or the whole file for a module.
20
- function codeSpans(source: string, kay: boolean): Span[] {
21
- if (!kay)
22
- return [{ start: 0, end: source.length }]
23
-
24
- const file = parseKay(source)
25
-
26
- return [file.script, file.server, file.module].filter(span => span !== undefined)
27
- }
28
-
29
- function parsed(source: string, kay: boolean, at: number): Program | undefined {
30
- const span = codeSpans(source, kay).find(({ start, end }) => at >= start && at <= end)
31
-
32
- return span === undefined ? undefined : parseProgram(source.slice(span.start, span.end), { lang: kay ? 'tsx' : 'ts', recover: true, offset: span.start }).program
33
- }
34
-
35
- interface Walked {
36
- node: Node
37
- parent: Node | undefined
38
- }
39
-
40
- function nodes(program: Program): Walked[] {
41
- const found: Walked[] = []
42
- const visit = (node: Node, parent: Node | undefined): void => {
43
- found.push({ node, parent })
44
-
45
- for (const child of childrenOf(node))
46
- visit(child, node)
47
- }
48
-
49
- visit(program, undefined)
50
-
51
- return found
52
- }
53
-
54
- // The names the program imports, which a call written on one of them is a kay call.
55
- function importedNames(program: Program): Set<string> {
56
- const names = new Set<string>()
57
-
58
- for (const statement of program.body) {
59
- if (statement.type === 'ImportDeclaration') {
60
- for (const specifier of statement.specifiers) {
61
- names.add(specifier.local.name)
62
- }
63
- }
64
- }
65
-
66
- return names
67
- }
68
-
69
- function rootName(callee: Node): string | undefined {
70
- let node = callee
71
-
72
- while (node.type === 'MemberExpression')
73
- node = node.object
74
-
75
- return node.type === 'Identifier' ? node.name : undefined
76
- }
77
-
78
- // The `await` a read of the result is made on: written there, or in a `const` the name was bound by.
79
- function awaitedBy(all: Walked[], subject: Node, at: number): Node | undefined {
80
- if (subject.type === 'AwaitExpression')
81
- return subject
82
-
83
- if (subject.type !== 'Identifier')
84
- return undefined
85
-
86
- const declarations = all.filter(({ node }) => node.type === 'VariableDeclarator' && node.id.type === 'Identifier' && node.id.name === subject.name && node.end <= at).map(({ node }) => node)
87
- const declarator = declarations.at(-1)
88
-
89
- return declarator?.type === 'VariableDeclarator' && declarator.init?.type === 'AwaitExpression' ? declarator.init : undefined
90
- }
91
-
92
- // The nodes that bind a name: a declaration, a parameter, a destructured name or a catch parameter.
93
- function bindingNodes(all: Walked[]): Set<Node> {
94
- const found = new Set<Node>()
95
- const add = (node: Node | null | undefined): void => {
96
- if (node)
97
- found.add(node)
98
- }
99
-
100
- for (const { node } of all) {
101
- const holder = node as unknown as { params?: Node[], param?: Node, left?: Node, argument?: Node, elements?: (Node | null)[], properties?: Node[] }
102
-
103
- if (node.type === 'VariableDeclarator') {
104
- add(node.id)
105
- }
106
- else if (node.type === 'ObjectPattern') {
107
- for (const property of holder.properties ?? [])
108
- add(property.type === 'Property' ? property.value : property)
109
- }
110
- else if (node.type === 'ArrayPattern') {
111
- for (const element of holder.elements ?? [])
112
- add(element)
113
- }
114
- else if (node.type === 'AssignmentPattern') {
115
- add(holder.left)
116
- }
117
- else if (node.type === 'RestElement') {
118
- add(holder.argument)
119
- }
120
- else if (node.type === 'CatchClause') {
121
- add(holder.param)
122
- }
123
- else {
124
- for (const param of holder.params ?? [])
125
- add(param)
126
- }
127
- }
128
-
129
- return found
130
- }
131
-
132
- // Whether the name is bound more than once in the file, so a read of it may be of another binding than the nearest declaration.
133
- function boundTwice(all: Walked[], name: string): boolean {
134
- const bindings = bindingNodes(all)
135
-
136
- return all.filter(({ node }) => node.type === 'Identifier' && node.name === name && bindings.has(node)).length > 1
137
- }
138
-
139
- // Whether the code uses the name the `await` is bound to in any way but reading a field a result has no key of (`list.items`), or the pattern it is destructured by names a result's key: `list.ok`, `list['ok']`, `list[key]`, `const { ok } = list` or `list` handed on, so `.orThrow()` could take away what is read.
140
- function readsResult(all: Walked[], bound: Node | undefined): boolean {
141
- if (bound === undefined)
142
- return false
143
-
144
- if (bound.type === 'Identifier') {
145
- const bindings = bindingNodes(all)
146
-
147
- return all.some(({ node, parent }) => {
148
- if (node.type !== 'Identifier' || node.name !== bound.name || node === bound || bindings.has(node))
149
- return false
150
-
151
- if (parent?.type === 'MemberExpression' && parent.property === node && !parent.computed)
152
- return false
153
-
154
- if (parent?.type === 'Property' && parent.key === node && !parent.computed && !parent.shorthand)
155
- return false
156
-
157
- return !(parent?.type === 'MemberExpression' && parent.object === node && !parent.computed && parent.property.type === 'Identifier' && !RESULT_KEYS.has(parent.property.name))
158
- })
159
- }
160
-
161
- return bound.type === 'ObjectPattern' && bound.properties.some(property => property.type !== 'Property' || property.computed || (property.key.type === 'Identifier' && RESULT_KEYS.has(property.key.name)))
162
- }
163
-
164
- // A read on a call's answer that is no field of a `CallResult`, an island call awaited as data as it was before 1.105: the answer is `{ ok: true, data }` or `{ ok: false, error }` since, so `.orThrow()` after the call gives the data and throws a refusal as it did.
165
- // Fixed where the call is written on a name the file imports and nothing reads `ok`, `data` or `error` of the answer; offered, not applied, otherwise.
166
- export function callResultLint(message: string, source: string, span: Span | undefined, kay: boolean): OldFormLint | undefined {
167
- const missing = MISSING.test(message)
168
-
169
- if (span === undefined || (!missing && !MISMATCH.test(message)))
170
- return undefined
171
-
172
- const program = parsed(source, kay, span.start)
173
-
174
- if (program === undefined)
175
- return undefined
176
-
177
- const all = nodes(program)
178
- let subject: Node | undefined
179
- let bound: Node | undefined
180
-
181
- for (const { node, parent } of all) {
182
- if (missing && node.type === 'MemberExpression' && !node.computed && node.property.start === span.start) {
183
- subject = node.object
184
- bound = node.object
185
- }
186
- else if (missing && node.type === 'Property' && parent?.type === 'ObjectPattern' && node.key.start === span.start) {
187
- const declarator = all.find(({ node: other }) => other.type === 'VariableDeclarator' && other.id === parent)?.node
188
-
189
- subject = declarator?.type === 'VariableDeclarator' ? declarator.init ?? undefined : undefined
190
- bound = parent
191
- }
192
- else if (!missing && (node.type === 'AwaitExpression' || node.type === 'Identifier') && node.start === span.start) {
193
- subject = node
194
- bound = node
195
- }
196
-
197
- if (subject !== undefined)
198
- break
199
- }
200
-
201
- const awaited = subject === undefined ? undefined : awaitedBy(all, subject, span.start)
202
- const call = awaited?.type === 'AwaitExpression' && awaited.argument.type === 'CallExpression' ? awaited.argument : undefined
203
- const report = {
204
- message: 'An island\'s call answers a `CallResult` since 1.105, `{ ok: true, data }` or `{ ok: false, error }`, not its data',
205
- help: 'read `data` after checking `ok`, or write `.orThrow()` after the call: it resolves with the data and throws a refusal as the call did before 1.105',
206
- span,
207
- }
208
-
209
- if (call === undefined)
210
- return report
211
-
212
- const known = importedNames(program)
213
- const name = rootName(call.callee)
214
- const safe = name !== undefined && known.has(name) && !readsResult(all, bound) && !(bound?.type === 'Identifier' && boundTwice(all, bound.name))
215
-
216
- return { ...report, fixes: [{ title: 'Write `.orThrow()` after the call', safe, edits: [{ start: call.end, end: call.end, text: '.orThrow()' }] }] }
217
- }
218
-
219
- // The same for a type error in a module of the project, which has no shadow file: the message tells what it is, and the file is read for the call it names.
220
- export async function moduleCallResult(diagnostic: CheckDiagnostic, levels: LintLevels | undefined): Promise<Pick<CheckDiagnostic, 'code' | 'severity' | 'message' | 'help' | 'fixes'> | undefined> {
221
- if (!(MISSING.test(diagnostic.message) || MISMATCH.test(diagnostic.message)) || !MODULE.test(diagnostic.file))
222
- return undefined
223
-
224
- let source: string
225
-
226
- try {
227
- source = await Bun.file(diagnostic.file).text()
228
- }
229
- catch {
230
- return undefined
231
- }
232
-
233
- const start = offsetAt(source, diagnostic)
234
- const found = callResultLint(diagnostic.message, source, { start, end: start + 1 }, false)
235
-
236
- if (found === undefined)
237
- return undefined
238
-
239
- const level = lintLevels(source, levels)('deprecated-call-result', start)
240
-
241
- return level === 'allow' ? undefined : { code: 'deprecated-call-result', severity: level === 'warn' ? 'warning' : 'error', message: found.message, help: found.help, ...found.fixes && { fixes: found.fixes } }
242
- }
@@ -1,10 +0,0 @@
1
- import type { CheckDiagnostic, CheckOptions } from '.'
2
- import { movedKeys } from './moved-keys'
3
-
4
- const MOVED = new Set(['links', 'offline', 'search'])
5
- const NEEDLE = /\b(?:links|offline|search)\b/
6
-
7
- // The keys `links`, `offline` and `search` of the config, which belong to `client` since 1.105, with the rest of what the browser is given.
8
- export async function clientKeys(root: string, options: CheckOptions): Promise<CheckDiagnostic[]> {
9
- return movedKeys(root, options, { lint: 'deprecated-client-keys', needle: NEEDLE, group: name => MOVED.has(name) ? 'client' : undefined, help: 'write the key in `client`, `client: { links, offline, search }`' })
10
- }
@@ -1,81 +0,0 @@
1
- import type { CheckDiagnostic, CheckOptions } from '.'
2
- import type { NodeOfType } from '../compiler/estree'
3
- import type { Edit } from './renamed-exports'
4
- import { lintLevel } from '../compiler/lints'
5
- import { keyName } from '../compiler/object-literal'
6
- import { importsOf, walk } from './ast'
7
- import { scan } from './renamed-exports'
8
-
9
- const CMS = /\bcms\b/
10
- const FROM_CMS = (source: string) => source === '@kayjs/cms' || source === '@kaynooo/kayjs-cms'
11
- const COMMENT = /\/[*/]/
12
- const TRAILING_COMMA = /,$/
13
-
14
- type ObjectNode = NodeOfType<'ObjectExpression'>
15
- type Property = Extract<ObjectNode['properties'][number], { type: 'Property' }>
16
-
17
- // `role`, `guard: passwordGuard(...)` and an `uploads` list of `cms()`, which `access` and `uploads: { types }` took over in 1.105: `cms({ role: 'editor' })` is `cms({ access: 'editor' })`, `cms({ guard: passwordGuard(password, options) })` is `cms({ access: { password, ...options } })` and `uploads: ['image/*']` is `uploads: { types: ['image/*'] }`; `member` beside a custom guard is one `access` function, reported with no fix.
18
- // Found on a call of `cms` imported from `@kayjs/cms`, in the options object written in the call, in the project's TypeScript files and `.kay` files.
19
- export async function cmsOptions(root: string, options: CheckOptions): Promise<CheckDiagnostic[]> {
20
- if (lintLevel('deprecated-cms-options', options.lints) === 'allow')
21
- return []
22
-
23
- return scan(root, options, 'deprecated-cms-options', CMS, ({ source, parsed, report }) => {
24
- for (const { ast, base } of parsed) {
25
- const { locals, namespaces } = importsOf(ast, FROM_CMS, 'cms')
26
- const passwordGuards = importsOf(ast, FROM_CMS, 'passwordGuard').locals
27
-
28
- if (locals.size === 0 && namespaces.size === 0)
29
- continue
30
-
31
- const isCms = (callee: NodeOfType<'CallExpression'>['callee']): boolean => callee.type === 'Identifier'
32
- ? locals.has(callee.name)
33
- : callee.type === 'MemberExpression' && !callee.computed && callee.object.type === 'Identifier' && namespaces.has(callee.object.name) && callee.property.type === 'Identifier' && callee.property.name === 'cms'
34
-
35
- walk(ast, (node) => {
36
- const argument = node.type === 'CallExpression' && isCms(node.callee) ? node.arguments[0] : undefined
37
-
38
- if (argument?.type !== 'ObjectExpression')
39
- return
40
-
41
- const property = (name: string) => argument.properties.find((one): one is Property => one.type === 'Property' && keyName(one) === name)
42
- const spread = argument.properties.some(one => one.type === 'SpreadElement')
43
- const present = (name: string) => property(name) !== undefined
44
- const found: { property: Property, message: string, help: string, edits: Edit[] | null }[] = []
45
-
46
- const role = property('role')
47
-
48
- if (role)
49
- found.push({ property: role, message: '`role` of `cms()` is deprecated since 1.105: `access` says who is let in', help: 'write `access` for `role`', edits: role.shorthand || spread || present('access') || present('member') ? null : [{ start: base + role.key.start, end: base + role.key.end, text: 'access' }] })
50
-
51
- const guard = property('guard')
52
-
53
- if (guard?.value.type === 'CallExpression' && guard.value.callee.type === 'Identifier' && passwordGuards.has(guard.value.callee.name)) {
54
- const [password, given] = guard.value.arguments
55
- const inner = given?.type === 'ObjectExpression' && given.properties.length > 0 ? source.slice(base + given.start + 1, base + given.end - 1).trim().replace(TRAILING_COMMA, '') : ''
56
- const simple = password !== undefined && password.type !== 'SpreadElement' && (given === undefined || (given.type === 'ObjectExpression' && !given.properties.some(one => one.type === 'SpreadElement')))
57
- const edits = simple && !spread && !present('access') && !present('member') && !guard.shorthand ? [{ start: base + guard.start, end: base + guard.end, text: `access: { password: ${source.slice(base + password.start, base + password.end)}${inner === '' ? '' : `, ${inner}`} }` }] : null
58
-
59
- found.push({ property: guard, message: '`guard: passwordGuard()` of `cms()` is deprecated since 1.105: `access: { password }` takes the passwords and their options', help: 'write `access: { password }` for the `passwordGuard()`; the import it leaves unused can go', edits })
60
- }
61
-
62
- const uploads = property('uploads')
63
-
64
- if (uploads?.value.type === 'ArrayExpression')
65
- found.push({ property: uploads, message: '`uploads` of `cms()` as a list is deprecated since 1.105: `uploads: { types }` names the types beside `maxSize`', help: 'write `{ types: [...] }` for the list', edits: uploads.shorthand ? null : [{ start: base + uploads.value.start, end: base + uploads.value.start, text: '{ types: ' }, { start: base + uploads.value.end, end: base + uploads.value.end, text: ' }' }] })
66
-
67
- const member = property('member')
68
-
69
- if (member)
70
- found.push({ property: member, message: '`member` of `cms()` is deprecated since 1.105: `access` as a function says who is let in and who they are in one', help: 'move `member` and the guard into one `access` function returning the person, or nothing for a visitor', edits: null })
71
-
72
- for (const { property: where, message, help, edits } of found) {
73
- // A comment in a range the fix replaces would be lost with it.
74
- const lost = edits?.some(edit => COMMENT.test(source.slice(edit.start, edit.end)))
75
-
76
- report(base + where.start, base + where.end, message, help, lost ? null : edits)
77
- }
78
- })
79
- }
80
- })
81
- }
@@ -1,22 +0,0 @@
1
- import type { CheckDiagnostic, CheckOptions } from '.'
2
- import { movedKeys } from './moved-keys'
3
-
4
- // Each key of the config that lives in a group since 1.105: the files a site serves in `assets`, what runs the server in `ops`.
5
- const GROUPS: Record<string, string> = {
6
- images: 'assets',
7
- fonts: 'assets',
8
- favicon: 'assets',
9
- manifest: 'assets',
10
- publicCache: 'assets',
11
- observe: 'ops',
12
- health: 'ops',
13
- metrics: 'ops',
14
- jobs: 'ops',
15
- }
16
-
17
- const NEEDLE = /\b(?:images|fonts|favicon|manifest|publicCache|observe|health|metrics|jobs)\b/
18
-
19
- // The keys `images`, `fonts`, `favicon`, `manifest` and `publicCache` of the config, which belong to `assets` since 1.105, and `observe`, `health`, `metrics` and `jobs`, which belong to `ops`.
20
- export async function configGroups(root: string, options: CheckOptions): Promise<CheckDiagnostic[]> {
21
- return movedKeys(root, options, { lint: 'deprecated-config-groups', needle: NEEDLE, group: name => Object.hasOwn(GROUPS, name) ? GROUPS[name] : undefined, help: 'write the key in its group, `assets: { images, fonts, favicon, manifest, publicCache }` or `ops: { observe, health, metrics, jobs }`' })
22
- }
@@ -1,38 +0,0 @@
1
- import type { CheckDiagnostic, CheckOptions } from '.'
2
- import type { Edit } from './renamed-exports'
3
- import { basename } from 'node:path'
4
- import { lintLevel } from '../compiler/lints'
5
- import { constBindings, exportedObject, keyName } from '../compiler/object-literal'
6
- import { scan } from './renamed-exports'
7
-
8
- const PROXY = /\bproxy\b/
9
-
10
- // `proxy: 2` in kay.config.ts, `proxy: { hops: 2 }` since 1.105 and `proxy: true` for one: every feature key takes `false`, `true` or its bag, and a number was a third form of the same switch.
11
- export async function configSwitches(root: string, options: CheckOptions): Promise<CheckDiagnostic[]> {
12
- if (lintLevel('deprecated-config-switch', options.lints) === 'allow')
13
- return []
14
-
15
- return scan(root, options, 'deprecated-config-switch', PROXY, ({ file, parsed, report }) => {
16
- if (basename(file) !== 'kay.config.ts')
17
- return
18
-
19
- for (const { ast, base } of parsed) {
20
- const exported = exportedObject(ast, constBindings(ast))
21
-
22
- for (const property of exported?.properties ?? []) {
23
- if (property.type !== 'Property' || keyName(property) !== 'proxy' || property.computed || property.shorthand)
24
- continue
25
-
26
- const { value } = property
27
-
28
- if (value.type !== 'Literal' || typeof value.value !== 'number')
29
- continue
30
-
31
- const text = value.value === 1 ? 'true' : `{ hops: ${value.raw} }`
32
- const edits: Edit[] = Number.isInteger(value.value) && value.value >= 1 ? [{ start: base + value.start, end: base + value.end, text }] : []
33
-
34
- report(base + value.start, base + value.end, `\`proxy: ${value.raw}\` is deprecated since 1.105: a feature key is \`false\`, \`true\` or its options, and the number of proxies is \`hops\``, 'write `true` for one proxy and `{ hops: n }` for more', edits)
35
- }
36
- }
37
- })
38
- }
@@ -1,51 +0,0 @@
1
- import type { CheckDiagnostic, CheckOptions } from '.'
2
- import { lintLevel } from '../compiler/lints'
3
- import { scan } from './renamed-exports'
4
-
5
- const NEEDLE = /\bdefineContext\b/
6
- const LIBRARY_END = /library$/
7
- const FROM_LIBRARY = (source: string) => source === 'kay/library' || source === '@kayjs/kay/library'
8
-
9
- // `defineContext` imported from `kay/library`, `kay/server` since 1.105, where `defineEnv` and the rest of what an app imports live.
10
- // The fix moves the specifier: the import's source when it names `defineContext` alone, else a new import beside it.
11
- export async function contextImport(root: string, options: CheckOptions): Promise<CheckDiagnostic[]> {
12
- if (lintLevel('deprecated-context-import', options.lints) === 'allow')
13
- return []
14
-
15
- return scan(root, options, 'deprecated-context-import', NEEDLE, ({ parsed, source, report }) => {
16
- for (const { ast, base } of parsed) {
17
- for (const statement of ast.body) {
18
- if (statement.type !== 'ImportDeclaration' || !FROM_LIBRARY(statement.source.value) || statement.importKind === 'type')
19
- continue
20
-
21
- const index = statement.specifiers.findIndex(specifier => specifier.type === 'ImportSpecifier' && specifier.imported.type === 'Identifier' && specifier.imported.name === 'defineContext' && specifier.importKind !== 'type')
22
-
23
- if (index < 0)
24
- continue
25
-
26
- const specifier = statement.specifiers[index]!
27
- const text = source.slice(base + specifier.start, base + specifier.end)
28
- const target = statement.source.value.replace(LIBRARY_END, 'server')
29
- const alone = statement.specifiers.length === 1
30
- const edits = alone
31
- ? [{ start: base + statement.source.start, end: base + statement.source.end, text: `${source[base + statement.source.start]}${target}${source[base + statement.source.start]}` }]
32
- : [{ start: base + statement.end, end: base + statement.end, text: `\nimport { ${text} } from '${target}'` }, ...removal(base, statement.specifiers, index)]
33
-
34
- report(base + specifier.start, base + specifier.end, '`defineContext` from `kay/library` is deprecated since 1.105: it is imported from `kay/server`, as `defineEnv` is', 'import it from `kay/server`', edits)
35
- }
36
- }
37
- })
38
- }
39
-
40
- // Takes one specifier out of a list with its comma.
41
- function removal(base: number, specifiers: { start: number, end: number }[], index: number): { start: number, end: number, text: string }[] {
42
- const specifier = specifiers[index]!
43
- const next = specifiers[index + 1]
44
-
45
- if (next !== undefined)
46
- return [{ start: base + specifier.start, end: base + next.start, text: '' }]
47
-
48
- const before = specifiers[index - 1]!
49
-
50
- return [{ start: base + before.end, end: base + specifier.end, text: '' }]
51
- }
@@ -1,31 +0,0 @@
1
- import type { CheckDiagnostic, CheckOptions } from '.'
2
- import { basename } from 'node:path'
3
- import { lintLevel } from '../compiler/lints'
4
- import { constBindings, exportedObject, keyName } from '../compiler/object-literal'
5
- import { scan } from './renamed-exports'
6
-
7
- const ENV = /\benv\b/
8
-
9
- // `env` in kay.config.ts, `envFiles` since 1.105: the key names the compose and example files the declared variables are compared with, where `env` read as the variables themselves. The fix renames the key; a config that already has an `envFiles`, or a computed key, is reported with no fix.
10
- export async function envFiles(root: string, options: CheckOptions): Promise<CheckDiagnostic[]> {
11
- if (lintLevel('deprecated-env-files', options.lints) === 'allow')
12
- return []
13
-
14
- return scan(root, options, 'deprecated-env-files', ENV, ({ file, parsed, report }) => {
15
- if (basename(file) !== 'kay.config.ts')
16
- return
17
-
18
- for (const { ast, base } of parsed) {
19
- const properties = exportedObject(ast, constBindings(ast))?.properties.filter(property => property.type === 'Property') ?? []
20
- const old = properties.find(property => keyName(property) === 'env')
21
-
22
- if (old === undefined)
23
- continue
24
-
25
- const fixable = !old.computed && !properties.some(property => keyName(property) === 'envFiles')
26
- const edits = fixable ? [old.shorthand ? { start: base + old.start, end: base + old.end, text: 'envFiles: env' } : { start: base + old.key.start, end: base + old.key.end, text: 'envFiles' }] : []
27
-
28
- report(base + old.start, base + old.end, '`env` in kay.config.ts is deprecated since 1.105: it names the compose and example files the declared variables are compared with, `envFiles`', 'write `envFiles`', edits)
29
- }
30
- })
31
- }
@@ -1,75 +0,0 @@
1
- import type { CheckDiagnostic, CheckOptions } from '.'
2
- import { lintLevel } from '../compiler/lints'
3
- import { importsOf } from './ast'
4
- import { scan } from './renamed-exports'
5
-
6
- const FORMAT = /\bformatDuration\b/
7
- const FROM_I18N = (source: string) => source === 'kay/i18n'
8
- const HELP = 'write the length with its unit, `formatDuration(\'125m\')`'
9
-
10
- export const EXPRESSION = /^\d[\d_]*(?:\.\d+)?(?:\s*[*+\-/]\s*\d[\d_]*(?:\.\d+)?)*$/
11
- const TERMS = /\s*([*+\-/])\s*/
12
-
13
- // The value of numbers written with `+`, `-`, `*` and `/` between them, as the language reads them; the caller checked there is nothing else.
14
- export function evaluate(text: string): number {
15
- const parts = text.replaceAll('_', '').split(TERMS)
16
- const terms = [Number(parts[0])]
17
- const signs: string[] = []
18
-
19
- for (let at = 1; at < parts.length; at += 2) {
20
- const sign = parts[at]!
21
- const value = Number(parts[at + 1])
22
-
23
- if (sign === '*') {
24
- terms[terms.length - 1]! *= value
25
- }
26
- else if (sign === '/') {
27
- terms[terms.length - 1]! /= value
28
- }
29
- else {
30
- signs.push(sign)
31
- terms.push(value)
32
- }
33
- }
34
-
35
- return terms.slice(1).reduce((sum, term, at) => signs[at] === '+' ? sum + term : sum - term, terms[0]!)
36
- }
37
-
38
- // A call of `formatDuration` from `kay/i18n` with a bare number, milliseconds until 1.105 and a `Duration` since: `formatDuration(7_500_000)` is `formatDuration('7500000ms')`.
39
- // Found on a number written as a literal or as arithmetic of literals, in a fence, a module or a template; a number held in a variable is a type error the editor shows, as `kay check` reads no types here. The fix writes the value in milliseconds.
40
- export async function formatDurationNumbers(root: string, options: CheckOptions): Promise<CheckDiagnostic[]> {
41
- if (lintLevel('deprecated-format-duration', options.lints) === 'allow')
42
- return []
43
-
44
- return scan(root, options, 'deprecated-format-duration', FORMAT, ({ source, parsed, report }) => {
45
- const names = new Set<string>()
46
-
47
- for (const { ast } of parsed) {
48
- const { locals, namespaces } = importsOf(ast, FROM_I18N, 'formatDuration')
49
-
50
- for (const name of locals)
51
- names.add(name)
52
-
53
- for (const name of namespaces)
54
- names.add(`${name}\\.formatDuration`)
55
- }
56
-
57
- if (names.size === 0)
58
- return
59
-
60
- // eslint-disable-next-line regexp/no-empty-group -- the names alternation is filled in at run time
61
- const calls = new RegExp(String.raw`(?<![\w$.])(?:${[...names].join('|')})\(([^,()]*)(?=[,)])`, 'g')
62
-
63
- for (const call of source.matchAll(calls)) {
64
- const text = call[1]!.trim()
65
-
66
- if (!EXPRESSION.test(text))
67
- continue
68
-
69
- const start = call.index + call[0].length - call[1]!.length + call[1]!.indexOf(text)
70
- const milliseconds = evaluate(text)
71
-
72
- report(start, start + text.length, '`formatDuration` takes a duration with its unit since 1.105, not milliseconds', HELP, Number.isFinite(milliseconds) ? [{ start, end: start + text.length, text: `'${milliseconds}ms'` }] : null)
73
- }
74
- })
75
- }