toiljs 0.0.116 → 0.0.117

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 (325) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/README.md +16 -7
  3. package/build/backend/.tsbuildinfo +1 -1
  4. package/build/cli/.tsbuildinfo +1 -1
  5. package/build/cli/index.js +2375 -258
  6. package/build/client/.tsbuildinfo +1 -1
  7. package/build/client/dev/devtools.js +1 -1
  8. package/build/client/dev/error-overlay.js +1 -1
  9. package/build/client/routing/mount.js +1 -1
  10. package/build/compiler/.tsbuildinfo +1 -1
  11. package/build/compiler/auth-emails.js +7 -3
  12. package/build/compiler/emails.js +1 -1
  13. package/build/compiler/index.d.ts +1 -0
  14. package/build/compiler/index.js +25 -4
  15. package/build/compiler/pages.js +2 -3
  16. package/build/compiler/prerender.d.ts +3 -8
  17. package/build/compiler/prerender.js +88 -127
  18. package/build/compiler/ssg.js +3 -4
  19. package/build/compiler/template-build.js +3 -4
  20. package/build/compiler/toil-docs.generated.js +6 -5
  21. package/build/compiler/vite.js +3 -6
  22. package/build/devserver/.tsbuildinfo +1 -1
  23. package/build/devserver/db/database.js +7 -3
  24. package/build/devserver/db/types.js +1 -1
  25. package/build/devserver/production.js +4 -3
  26. package/build/devserver/runtime/crypto.d.ts +1 -1
  27. package/build/io/.tsbuildinfo +1 -1
  28. package/build/logger/.tsbuildinfo +1 -1
  29. package/build/shared/.tsbuildinfo +1 -1
  30. package/examples/basic/client/routes/analytics.tsx +7 -5
  31. package/examples/basic/server/tsconfig.json +1 -3
  32. package/package.json +45 -44
  33. package/presets/no-uint8array-tostring.js +120 -153
  34. package/presets/oxlint.d.ts +5 -0
  35. package/presets/oxlint.js +224 -0
  36. package/server/runtime/tsconfig.json +1 -3
  37. package/tsconfig.json +2 -11
  38. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -38
  39. package/.github/ISSUE_TEMPLATE/bug_report.yml +0 -90
  40. package/.github/ISSUE_TEMPLATE/config.yml +0 -8
  41. package/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
  42. package/.github/PULL_REQUEST_TEMPLATE.md +0 -43
  43. package/.github/changelog-config.json +0 -45
  44. package/.github/dependabot.yml +0 -27
  45. package/.github/workflows/ci.yml +0 -222
  46. package/.vscode/settings.json +0 -10
  47. package/docs/README.md +0 -107
  48. package/docs/auth/README.md +0 -104
  49. package/docs/auth/configuration.md +0 -105
  50. package/docs/auth/emails.md +0 -92
  51. package/docs/auth/extending.md +0 -202
  52. package/docs/auth/how-it-works.md +0 -138
  53. package/docs/auth/usage.md +0 -188
  54. package/docs/backend/README.md +0 -143
  55. package/docs/backend/data.md +0 -351
  56. package/docs/backend/rest.md +0 -402
  57. package/docs/backend/rpc.md +0 -226
  58. package/docs/background/README.md +0 -114
  59. package/docs/background/daemons.md +0 -276
  60. package/docs/background/derive.md +0 -179
  61. package/docs/cli/README.md +0 -379
  62. package/docs/concepts/ai-guide.md +0 -132
  63. package/docs/concepts/config.md +0 -416
  64. package/docs/concepts/decorators.md +0 -127
  65. package/docs/concepts/security.md +0 -108
  66. package/docs/concepts/tiers.md +0 -166
  67. package/docs/concepts/types.md +0 -216
  68. package/docs/database/README.md +0 -143
  69. package/docs/database/capacity.md +0 -350
  70. package/docs/database/counters.md +0 -174
  71. package/docs/database/documents.md +0 -277
  72. package/docs/database/events.md +0 -307
  73. package/docs/database/membership.md +0 -246
  74. package/docs/database/setup.md +0 -155
  75. package/docs/database/unique.md +0 -216
  76. package/docs/database/views.md +0 -246
  77. package/docs/frontend/README.md +0 -104
  78. package/docs/frontend/components.md +0 -286
  79. package/docs/frontend/data-fetching.md +0 -260
  80. package/docs/frontend/images.md +0 -148
  81. package/docs/frontend/metadata.md +0 -344
  82. package/docs/frontend/navigation.md +0 -296
  83. package/docs/frontend/rendering.md +0 -236
  84. package/docs/frontend/routing.md +0 -346
  85. package/docs/frontend/scripts.md +0 -118
  86. package/docs/frontend/search.md +0 -191
  87. package/docs/frontend/styling.md +0 -147
  88. package/docs/frontend/toil-global.md +0 -216
  89. package/docs/getting-started/README.md +0 -81
  90. package/docs/getting-started/create-project.md +0 -131
  91. package/docs/getting-started/deploy.md +0 -101
  92. package/docs/getting-started/first-app.md +0 -215
  93. package/docs/getting-started/installation.md +0 -124
  94. package/docs/getting-started/migrating.md +0 -125
  95. package/docs/getting-started/project-structure.md +0 -163
  96. package/docs/introduction/README.md +0 -66
  97. package/docs/introduction/design-principles.md +0 -81
  98. package/docs/introduction/distributed.md +0 -91
  99. package/docs/introduction/how-it-works.md +0 -121
  100. package/docs/introduction/hyperscale.md +0 -70
  101. package/docs/introduction/modern-stack.md +0 -85
  102. package/docs/introduction/vs-other-frameworks.md +0 -64
  103. package/docs/introduction/why-toil.md +0 -99
  104. package/docs/llms.txt +0 -95
  105. package/docs/realtime/README.md +0 -102
  106. package/docs/realtime/channels.md +0 -211
  107. package/docs/realtime/streams.md +0 -369
  108. package/docs/services/README.md +0 -60
  109. package/docs/services/analytics.md +0 -279
  110. package/docs/services/caching.md +0 -175
  111. package/docs/services/cookies.md +0 -235
  112. package/docs/services/crypto.md +0 -209
  113. package/docs/services/email.md +0 -289
  114. package/docs/services/environment.md +0 -141
  115. package/docs/services/ratelimit.md +0 -174
  116. package/docs/services/time.md +0 -85
  117. package/eslint.config.js +0 -57
  118. package/examples/basic/client/routes/docs/[...slug].tsx +0 -12
  119. package/presets/eslint.js +0 -88
  120. package/src/backend/index.ts +0 -204
  121. package/src/cli/configure.ts +0 -363
  122. package/src/cli/create.ts +0 -924
  123. package/src/cli/db.ts +0 -158
  124. package/src/cli/diagnostics.ts +0 -665
  125. package/src/cli/doctor.ts +0 -982
  126. package/src/cli/features.ts +0 -170
  127. package/src/cli/index.ts +0 -326
  128. package/src/cli/notify.ts +0 -120
  129. package/src/cli/proc.ts +0 -56
  130. package/src/cli/ui.ts +0 -169
  131. package/src/cli/update.ts +0 -248
  132. package/src/cli/updates.ts +0 -92
  133. package/src/cli/validate.ts +0 -31
  134. package/src/cli/version-check.ts +0 -125
  135. package/src/client/auth.ts +0 -869
  136. package/src/client/channel/channel.ts +0 -146
  137. package/src/client/components/Form.tsx +0 -65
  138. package/src/client/components/Image.tsx +0 -160
  139. package/src/client/components/Script.tsx +0 -113
  140. package/src/client/components/Slot.tsx +0 -21
  141. package/src/client/dev/devtools.tsx +0 -1089
  142. package/src/client/dev/error-overlay.tsx +0 -225
  143. package/src/client/errors.ts +0 -11
  144. package/src/client/head/head.ts +0 -182
  145. package/src/client/head/metadata.ts +0 -110
  146. package/src/client/index.ts +0 -130
  147. package/src/client/navigation/Link.tsx +0 -108
  148. package/src/client/navigation/NavLink.tsx +0 -86
  149. package/src/client/navigation/navigation.ts +0 -235
  150. package/src/client/navigation/prefetch.ts +0 -169
  151. package/src/client/navigation/scroll.ts +0 -53
  152. package/src/client/routing/Router.tsx +0 -216
  153. package/src/client/routing/action.ts +0 -122
  154. package/src/client/routing/error-boundary.tsx +0 -43
  155. package/src/client/routing/hooks.ts +0 -140
  156. package/src/client/routing/lazy.ts +0 -77
  157. package/src/client/routing/loader.ts +0 -381
  158. package/src/client/routing/match.ts +0 -47
  159. package/src/client/routing/mount.tsx +0 -90
  160. package/src/client/routing/params-context.ts +0 -10
  161. package/src/client/routing/slot-context.ts +0 -7
  162. package/src/client/rpc.ts +0 -97
  163. package/src/client/search/search.ts +0 -189
  164. package/src/client/search/use-page-search.ts +0 -73
  165. package/src/client/ssr/markers.tsx +0 -172
  166. package/src/client/stream/client.ts +0 -237
  167. package/src/client/types.ts +0 -73
  168. package/src/compiler/auth-emails.ts +0 -312
  169. package/src/compiler/config.ts +0 -369
  170. package/src/compiler/docs.ts +0 -127
  171. package/src/compiler/email-preview.ts +0 -314
  172. package/src/compiler/emails.ts +0 -404
  173. package/src/compiler/fonts.ts +0 -89
  174. package/src/compiler/generate.ts +0 -471
  175. package/src/compiler/image-blur.ts +0 -42
  176. package/src/compiler/image-report.ts +0 -88
  177. package/src/compiler/index.ts +0 -1362
  178. package/src/compiler/pages.ts +0 -49
  179. package/src/compiler/plugin.ts +0 -391
  180. package/src/compiler/prerender.ts +0 -263
  181. package/src/compiler/routes.ts +0 -170
  182. package/src/compiler/seo.ts +0 -415
  183. package/src/compiler/sri.ts +0 -144
  184. package/src/compiler/ssg.ts +0 -177
  185. package/src/compiler/ssr-codegen.ts +0 -85
  186. package/src/compiler/template-build.ts +0 -676
  187. package/src/compiler/template.ts +0 -262
  188. package/src/compiler/toil-docs.generated.ts +0 -77
  189. package/src/compiler/vite.ts +0 -245
  190. package/src/devserver/analytics/index.ts +0 -317
  191. package/src/devserver/config/dotenv.ts +0 -102
  192. package/src/devserver/config/env.ts +0 -30
  193. package/src/devserver/config/ratelimit.ts +0 -123
  194. package/src/devserver/daemon/catalog.ts +0 -120
  195. package/src/devserver/daemon/cron.ts +0 -87
  196. package/src/devserver/daemon/host.ts +0 -134
  197. package/src/devserver/daemon/index.ts +0 -369
  198. package/src/devserver/daemon/runtime.ts +0 -48
  199. package/src/devserver/db/catalog.ts +0 -109
  200. package/src/devserver/db/database.ts +0 -1834
  201. package/src/devserver/db/derives.ts +0 -121
  202. package/src/devserver/db/index.ts +0 -20
  203. package/src/devserver/db/routeKinds.ts +0 -191
  204. package/src/devserver/db/types.ts +0 -168
  205. package/src/devserver/email/caps.ts +0 -0
  206. package/src/devserver/email/config.ts +0 -141
  207. package/src/devserver/email/console.ts +0 -348
  208. package/src/devserver/email/index.ts +0 -155
  209. package/src/devserver/email/providers.ts +0 -131
  210. package/src/devserver/email/status.ts +0 -23
  211. package/src/devserver/email/validate.ts +0 -37
  212. package/src/devserver/email/wire.ts +0 -55
  213. package/src/devserver/http/cache.ts +0 -0
  214. package/src/devserver/http/envelope.ts +0 -157
  215. package/src/devserver/http/proxy.ts +0 -172
  216. package/src/devserver/http/runtime.ts +0 -387
  217. package/src/devserver/index.ts +0 -43
  218. package/src/devserver/production-ipc.ts +0 -63
  219. package/src/devserver/production-worker.ts +0 -83
  220. package/src/devserver/production.ts +0 -718
  221. package/src/devserver/runtime/crypto.ts +0 -587
  222. package/src/devserver/runtime/host.ts +0 -427
  223. package/src/devserver/runtime/module.ts +0 -442
  224. package/src/devserver/server.ts +0 -251
  225. package/src/devserver/ssr.ts +0 -208
  226. package/src/devserver/stream/catalog.ts +0 -106
  227. package/src/devserver/stream/host.ts +0 -42
  228. package/src/devserver/stream/index.ts +0 -301
  229. package/src/devserver/stream/manager.ts +0 -167
  230. package/src/devserver/stream/router.ts +0 -101
  231. package/src/devserver/stream/wire.ts +0 -58
  232. package/src/devserver/stream/ws.ts +0 -78
  233. package/src/devserver/wasm/sections.ts +0 -59
  234. package/src/devserver/wasm/surface.ts +0 -115
  235. package/src/io/FastMap.ts +0 -151
  236. package/src/io/FastSet.ts +0 -113
  237. package/src/io/codec.ts +0 -362
  238. package/src/io/index.ts +0 -10
  239. package/src/io/lengths.ts +0 -14
  240. package/src/io/types.ts +0 -19
  241. package/src/logger/index.ts +0 -22
  242. package/src/shared/index.ts +0 -46
  243. package/test/analytics-dev.test.ts +0 -113
  244. package/test/assembly/aspect-shim.ts +0 -33
  245. package/test/assembly/cookie.spec.ts +0 -303
  246. package/test/assembly/example.spec.ts +0 -22
  247. package/test/assembly/ssr.spec.ts +0 -95
  248. package/test/assembly.test.ts +0 -59
  249. package/test/auth-emails.test.ts +0 -118
  250. package/test/built-ssr.test.ts +0 -148
  251. package/test/channel.test.ts +0 -21
  252. package/test/config-host-port.test.ts +0 -59
  253. package/test/configure.test.ts +0 -94
  254. package/test/daemon-build.test.ts +0 -278
  255. package/test/daemon-catalog.test.ts +0 -349
  256. package/test/daemon-emulation.test.ts +0 -256
  257. package/test/db.test.ts +0 -0
  258. package/test/devserver-database.test.ts +0 -1102
  259. package/test/devserver-email.test.ts +0 -306
  260. package/test/devserver-pqauth.test.ts +0 -93
  261. package/test/devserver-secrets.test.ts +0 -63
  262. package/test/devserver.test.ts +0 -259
  263. package/test/doctor.test.ts +0 -298
  264. package/test/dom/Image.test.tsx +0 -144
  265. package/test/dom/Link.test.tsx +0 -67
  266. package/test/dom/NavLink.test.tsx +0 -37
  267. package/test/dom/Script.test.tsx +0 -48
  268. package/test/dom/action.test.tsx +0 -146
  269. package/test/dom/error-overlay.test.tsx +0 -44
  270. package/test/dom/loader.test.tsx +0 -121
  271. package/test/dom/navigation.test.ts +0 -59
  272. package/test/dom/revalidate.test.tsx +0 -38
  273. package/test/dom/route-head.test.tsx +0 -56
  274. package/test/dom/router-loading.test.tsx +0 -44
  275. package/test/dom/scroll.test.ts +0 -56
  276. package/test/dom/slot.test.tsx +0 -131
  277. package/test/dom/use-metadata.test.tsx +0 -58
  278. package/test/dom/view-transitions.test.tsx +0 -53
  279. package/test/dynamic-routing.test.ts +0 -132
  280. package/test/email-console.test.ts +0 -86
  281. package/test/email-preview.test.ts +0 -73
  282. package/test/emails.test.ts +0 -58
  283. package/test/errors.test.ts +0 -21
  284. package/test/example-guestbook.test.ts +0 -123
  285. package/test/features.test.ts +0 -149
  286. package/test/fixtures/bignum-wire/spec.ts +0 -25
  287. package/test/fixtures/daemon-app.ts +0 -65
  288. package/test/fixtures/stream-echo.ts +0 -26
  289. package/test/fixtures/stream-gate.ts +0 -28
  290. package/test/fixtures/stream-trap.ts +0 -18
  291. package/test/fixtures/stream-typed.ts +0 -41
  292. package/test/fonts.test.ts +0 -28
  293. package/test/global-setup.ts +0 -17
  294. package/test/head.test.ts +0 -42
  295. package/test/image-blur.test.ts +0 -50
  296. package/test/io.test.ts +0 -117
  297. package/test/metadata.test.ts +0 -40
  298. package/test/navlink.test.ts +0 -28
  299. package/test/pages.test.ts +0 -105
  300. package/test/placeholder.test.ts +0 -9
  301. package/test/pqauth-e2e.test.ts +0 -216
  302. package/test/pqauth-email.test.ts +0 -801
  303. package/test/prerender.test.ts +0 -116
  304. package/test/prettier-plugin.test.ts +0 -46
  305. package/test/routes.test.ts +0 -76
  306. package/test/rpc-bignum-wire.test.ts +0 -164
  307. package/test/rpc-dispatch.test.ts +0 -132
  308. package/test/rpc-kinds.test.ts +0 -18
  309. package/test/rpc.test.ts +0 -66
  310. package/test/search.test.ts +0 -114
  311. package/test/seo.test.ts +0 -175
  312. package/test/slot-layouts.test.ts +0 -69
  313. package/test/sri.test.ts +0 -129
  314. package/test/ssg.test.ts +0 -36
  315. package/test/ssr-hydration.test.tsx +0 -122
  316. package/test/ssr-render.test.ts +0 -197
  317. package/test/ssr-template.test.tsx +0 -482
  318. package/test/stream-emulation.test.ts +0 -479
  319. package/test/ui.test.ts +0 -40
  320. package/test/update.test.ts +0 -58
  321. package/test/validate.test.ts +0 -42
  322. package/test/version-check.test.ts +0 -130
  323. package/tests/data-parity/generated-parity.ts +0 -99
  324. package/tests/data-parity/parity.ts +0 -80
  325. package/tests/data-parity/spec.ts +0 -46
@@ -1,54 +1,26 @@
1
- /**
2
- * ESLint rule: disallow `.toString()` on Uint8Array (and branded byte types), which returns
3
- * comma-separated decimals instead of hex.
4
- */
5
- import { AST_NODE_TYPES, ESLintUtils } from '@typescript-eslint/utils';
6
- import { SyntaxKind } from 'typescript';
7
-
8
- function isUint8ArrayType(type, checker) {
9
- const symbol = type.getSymbol();
10
- if (symbol?.getName() === 'Uint8Array') {
11
- return true;
12
- }
13
-
14
- const baseTypes = type.getBaseTypes?.();
15
- if (baseTypes) {
16
- for (const baseType of baseTypes) {
17
- if (isUint8ArrayType(baseType, checker)) {
18
- return true;
19
- }
20
- }
21
- }
22
-
23
- if (type.isIntersection()) {
24
- for (const subType of type.types) {
25
- if (isUint8ArrayType(subType, checker)) {
26
- return true;
27
- }
28
- }
29
- }
30
-
31
- if (type.isUnion()) {
32
- return (
33
- type.types.length > 0 &&
34
- type.types.every((subType) => isUint8ArrayType(subType, checker))
35
- );
1
+ /** Oxlint plugin using the TypeScript 7 native checker for branded byte arrays. */
2
+ import path from 'node:path';
3
+ import { API } from 'typescript/unstable/sync';
4
+ import { SyntaxKind } from 'typescript/unstable/ast';
5
+
6
+ function isUint8ArrayType(type, checker, ancestors = new Set()) {
7
+ if (!type || ancestors.has(type.id)) return false;
8
+ const seen = new Set(ancestors).add(type.id);
9
+ if (type.getSymbol()?.name === 'Uint8Array') return true;
10
+ if (type.getBaseTypes()?.some((base) => isUint8ArrayType(base, checker, seen))) return true;
11
+ if (type.isIntersectionType())
12
+ return type.getTypes().some((part) => isUint8ArrayType(part, checker, seen));
13
+ if (type.isUnionType()) {
14
+ const parts = type.getTypes();
15
+ return parts.length > 0 && parts.every((part) => isUint8ArrayType(part, checker, seen));
36
16
  }
37
-
38
- const constraint = type.getConstraint?.();
39
- if (constraint && isUint8ArrayType(constraint, checker)) {
40
- return true;
41
- }
42
-
43
- return false;
17
+ const constraint = checker.getBaseConstraintOfType(type);
18
+ return constraint && constraint.id !== type.id
19
+ ? isUint8ArrayType(constraint, checker, seen)
20
+ : false;
44
21
  }
45
22
 
46
- /**
47
- * Types whose toString() is the dangerous default behavior we want to catch.
48
- * If toString is declared on any type NOT in this set, it has been
49
- * intentionally overridden and we should leave it alone.
50
- */
51
- const DEFAULT_TOSTRING_OWNERS = new Set([
23
+ const DEFAULT_OWNERS = new Set([
52
24
  'Object',
53
25
  'Uint8Array',
54
26
  'Int8Array',
@@ -63,138 +35,133 @@ const DEFAULT_TOSTRING_OWNERS = new Set([
63
35
  'BigUint64Array',
64
36
  ]);
65
37
 
66
- /**
67
- * Given a declaration node, walk up the AST parents to find the enclosing
68
- * class or interface name. More reliable than checker.getTypeAtLocation(decl.parent),
69
- * which can return odd results for .d.ts files.
70
- */
71
- function getEnclosingClassName(decl) {
72
- let current = decl.parent;
73
- while (current) {
74
- if (
75
- current.kind === SyntaxKind.ClassDeclaration ||
76
- current.kind === SyntaxKind.ClassExpression ||
77
- current.kind === SyntaxKind.InterfaceDeclaration
78
- ) {
79
- if (current.name) {
80
- return current.name.text;
38
+ function hasOverride(symbol) {
39
+ for (const handle of symbol?.declarations ?? []) {
40
+ let node = handle.resolve()?.parent;
41
+ while (node) {
42
+ if (
43
+ [
44
+ SyntaxKind.ClassDeclaration,
45
+ SyntaxKind.ClassExpression,
46
+ SyntaxKind.InterfaceDeclaration,
47
+ ].includes(node.kind)
48
+ ) {
49
+ const name = node.name?.text;
50
+ if (name && !DEFAULT_OWNERS.has(name)) return true;
51
+ break;
81
52
  }
53
+ node = node.parent;
82
54
  }
83
-
84
- current = current.parent;
85
55
  }
86
-
87
- return undefined;
56
+ return false;
88
57
  }
89
58
 
90
- /**
91
- * Checks whether the resolved toString() on this type is a custom override
92
- * rather than the default Uint8Array/Object prototype version.
93
- */
94
59
  function hasCustomToString(type, checker) {
95
- const toStringSymbol = type.getProperty('toString');
96
- if (!toStringSymbol) {
97
- return false;
98
- }
99
-
100
- const declarations = toStringSymbol.getDeclarations();
101
- if (!declarations || declarations.length === 0) {
102
- return false;
103
- }
104
-
105
- for (const decl of declarations) {
106
- const ownerName = getEnclosingClassName(decl);
107
- if (ownerName && !DEFAULT_TOSTRING_OWNERS.has(ownerName)) {
108
- return true;
109
- }
110
- }
111
-
112
- const apparentType = checker.getApparentType(type);
113
- if (apparentType !== type) {
114
- const apparentToString = apparentType.getProperty('toString');
115
- if (apparentToString && apparentToString !== toStringSymbol) {
116
- const apparentDecls = apparentToString.getDeclarations();
117
- if (apparentDecls) {
118
- for (const decl of apparentDecls) {
119
- const ownerName = getEnclosingClassName(decl);
120
- if (ownerName && !DEFAULT_TOSTRING_OWNERS.has(ownerName)) {
121
- return true;
122
- }
123
- }
124
- }
125
- }
126
- }
127
-
128
- return false;
60
+ if (hasOverride(checker.getPropertyOfType(type, 'toString'))) return true;
61
+ const apparent = checker.getApparentType(type);
62
+ return (
63
+ apparent &&
64
+ apparent.id !== type.id &&
65
+ hasOverride(checker.getPropertyOfType(apparent, 'toString'))
66
+ );
129
67
  }
130
68
 
131
- const createRule = ESLintUtils.RuleCreator(
132
- (name) => `https://github.com/dacely-cloud/toiljs/tree/main/presets#${name}`,
133
- );
134
-
135
- const rule = createRule({
136
- name: 'no-uint8array-tostring',
69
+ export const rule = {
137
70
  meta: {
138
71
  type: 'problem',
139
72
  docs: {
140
73
  description:
141
- 'Disallow .toString() on Uint8Array and branded types (Script, Bytes32, etc.) which produces comma-separated decimals instead of hex',
74
+ 'Disallow the default Uint8Array.toString(), including branded byte types.',
142
75
  },
76
+ schema: [],
143
77
  messages: {
144
78
  noUint8ArrayToString:
145
- '{{typeName}}.toString() returns comma-separated decimals (e.g. "0,32,70,107"), not a hex string. ' +
146
- 'Use Buffer.from(arr).toString("hex") or toHex() instead.',
79
+ '{{typeName}}.toString() returns comma-separated decimals (e.g. "0,32,70,107"), not a hex string. Use Buffer.from(arr).toString("hex") or toHex() instead.',
147
80
  },
148
- schema: [],
149
81
  },
150
- defaultOptions: [],
151
82
  create(context) {
152
- const services = ESLintUtils.getParserServices(context);
153
- const checker = services.program.getTypeChecker();
154
-
83
+ const calls = [];
155
84
  return {
156
85
  CallExpression(node) {
86
+ const callee = node.callee;
157
87
  if (
158
- node.callee.type !== AST_NODE_TYPES.MemberExpression ||
159
- node.callee.property.type !== AST_NODE_TYPES.Identifier ||
160
- node.callee.property.name !== 'toString' ||
161
- node.arguments.length > 0
162
- ) {
163
- return;
164
- }
165
-
166
- const objectNode = node.callee.object;
167
- const tsNode = services.esTreeNodeToTSNodeMap.get(objectNode);
168
- const type = checker.getTypeAtLocation(tsNode);
169
-
170
- if (!isUint8ArrayType(type, checker)) {
171
- return;
172
- }
173
-
174
- if (hasCustomToString(type, checker)) {
175
- return;
176
- }
177
-
178
- const typeName = checker.typeToString(type);
179
- context.report({
180
- node,
181
- messageId: 'noUint8ArrayToString',
182
- data: { typeName },
88
+ callee.type === 'MemberExpression' &&
89
+ callee.property.type === 'Identifier' &&
90
+ callee.property.name === 'toString' &&
91
+ node.arguments.length === 0
92
+ )
93
+ calls.push(node);
94
+ },
95
+ 'Program:exit'() {
96
+ if (calls.length === 0) return;
97
+ const file = path.resolve(context.filename);
98
+ // Use the actual lint input, including editor buffers and fix passes.
99
+ const api = new API({
100
+ cwd: context.cwd,
101
+ fs: {
102
+ readFile: (name) =>
103
+ path.resolve(name) === file ? context.sourceCode.text : undefined,
104
+ },
183
105
  });
106
+ let snapshot;
107
+ try {
108
+ snapshot = api.updateSnapshot({ openFiles: [file] });
109
+ const project = snapshot.getDefaultProjectForFile(file);
110
+ if (!project) throw new Error(`No TypeScript 7 project for ${file}`);
111
+ const checker = project.checker;
112
+ const source = project.program.getSourceFile(file);
113
+ if (!source) throw new Error(`No TypeScript 7 source file for ${file}`);
114
+ const wanted = new Map(
115
+ calls.map((node) => [node.callee.object.range.join(':'), undefined]),
116
+ );
117
+ function visit(node) {
118
+ const key = `${node.getStart(source)}:${node.end}`;
119
+ if (wanted.has(key)) wanted.set(key, node);
120
+ node.forEachChild(visit);
121
+ }
122
+ visit(source);
123
+ const receivers = calls.map((node) => {
124
+ const receiver = wanted.get(node.callee.object.range.join(':'));
125
+ if (!receiver) throw new Error(`Cannot map byte-array receiver in ${file}`);
126
+ return receiver;
127
+ });
128
+ const types = checker.getTypeAtLocation(receivers);
129
+ for (let i = 0; i < calls.length; i++) {
130
+ const type = types[i];
131
+ if (isUint8ArrayType(type, checker) && !hasCustomToString(type, checker)) {
132
+ context.report({
133
+ node: calls[i],
134
+ messageId: 'noUint8ArrayToString',
135
+ data: { typeName: checker.typeToString(type) },
136
+ });
137
+ }
138
+ }
139
+ } finally {
140
+ snapshot?.dispose();
141
+ api.close();
142
+ }
184
143
  },
185
144
  };
186
145
  },
187
- });
146
+ };
188
147
 
189
- const plugin = {
190
- meta: {
191
- name: 'eslint-plugin-no-uint8array-tostring',
192
- version: '1.0.0',
193
- },
148
+ export default {
149
+ meta: { name: 'toiljs', version: '2.0.0' },
194
150
  rules: {
195
151
  'no-uint8array-tostring': rule,
152
+ // Legacy octal literals are invalid in modules; retain this check for script inputs too.
153
+ 'no-octal': {
154
+ meta: {
155
+ type: 'problem',
156
+ schema: [],
157
+ messages: { octal: 'Octal literals should not be used.' },
158
+ },
159
+ create: (context) => ({
160
+ Literal(node) {
161
+ if (typeof node.value === 'number' && /^0[0-7]+$/.test(node.raw))
162
+ context.report({ node, messageId: 'octal' });
163
+ },
164
+ }),
165
+ },
196
166
  },
197
167
  };
198
-
199
- export default plugin;
200
- export { rule };
@@ -0,0 +1,5 @@
1
+ import type { OxlintConfig } from 'oxlint';
2
+
3
+ /** Shared strict TypeScript 7 and React configuration, including native semantic checks. */
4
+ declare const config: OxlintConfig;
5
+ export default config;
@@ -0,0 +1,224 @@
1
+ // Port of the effective ESLint rules, including strict type-aware checks.
2
+ import { fileURLToPath } from 'node:url';
3
+ import { defineConfig } from 'oxlint';
4
+
5
+ export default defineConfig({
6
+ categories: {
7
+ correctness: 'off',
8
+ },
9
+ plugins: ['typescript', 'react'],
10
+ jsPlugins: [
11
+ {
12
+ name: 'toiljs',
13
+ specifier: fileURLToPath(new URL('./no-uint8array-tostring.js', import.meta.url)),
14
+ },
15
+ {
16
+ name: 'react-hooks-js',
17
+ specifier: fileURLToPath(import.meta.resolve('eslint-plugin-react-hooks')),
18
+ },
19
+ {
20
+ name: 'style',
21
+ specifier: fileURLToPath(import.meta.resolve('@stylistic/eslint-plugin')),
22
+ },
23
+ ],
24
+ options: {
25
+ typeAware: true,
26
+ },
27
+ ignorePatterns: [
28
+ 'build/**',
29
+ 'dist/**',
30
+ 'node_modules/**',
31
+ 'server/**',
32
+ 'std/server/**',
33
+ 'toil-env.d.ts',
34
+ '.toil/**',
35
+ 'src/compiler/toil-docs.generated.ts',
36
+ ],
37
+ rules: {
38
+ 'eslint/constructor-super': 'off',
39
+ 'eslint/for-direction': 'error',
40
+ 'eslint/getter-return': 'off',
41
+ 'eslint/no-async-promise-executor': 'off',
42
+ 'eslint/no-case-declarations': 'error',
43
+ 'eslint/no-class-assign': 'off',
44
+ 'eslint/no-compare-neg-zero': 'error',
45
+ 'eslint/no-cond-assign': 'error',
46
+ 'eslint/no-const-assign': 'off',
47
+ 'eslint/no-constant-binary-expression': 'off',
48
+ 'eslint/no-constant-condition': 'error',
49
+ 'eslint/no-control-regex': 'error',
50
+ 'eslint/no-debugger': 'error',
51
+ 'eslint/no-delete-var': 'error',
52
+ 'eslint/no-dupe-class-members': 'off',
53
+ 'eslint/no-dupe-else-if': 'error',
54
+ 'eslint/no-dupe-keys': 'off',
55
+ 'eslint/no-duplicate-case': 'error',
56
+ 'eslint/no-empty': 'off',
57
+ 'eslint/no-empty-character-class': 'error',
58
+ 'eslint/no-empty-pattern': 'error',
59
+ 'eslint/no-empty-static-block': 'error',
60
+ 'eslint/no-ex-assign': 'error',
61
+ 'eslint/no-extra-boolean-cast': 'error',
62
+ 'eslint/no-fallthrough': 'error',
63
+ 'eslint/no-func-assign': 'off',
64
+ 'eslint/no-global-assign': 'error',
65
+ 'eslint/no-import-assign': 'off',
66
+ 'eslint/no-invalid-regexp': 'error',
67
+ 'eslint/no-irregular-whitespace': 'error',
68
+ 'eslint/no-loss-of-precision': 'error',
69
+ 'eslint/no-misleading-character-class': 'error',
70
+ 'eslint/no-new-native-nonconstructor': 'off',
71
+ 'eslint/no-nonoctal-decimal-escape': 'error',
72
+ 'eslint/no-obj-calls': 'off',
73
+ 'toiljs/no-octal': 'error',
74
+ 'eslint/no-prototype-builtins': 'error',
75
+ 'eslint/no-redeclare': 'off',
76
+ 'eslint/no-regex-spaces': 'error',
77
+ 'eslint/no-self-assign': 'error',
78
+ 'eslint/no-setter-return': 'off',
79
+ 'eslint/no-shadow-restricted-names': 'error',
80
+ 'eslint/no-sparse-arrays': 'error',
81
+ 'eslint/no-this-before-super': 'off',
82
+ 'eslint/no-unassigned-vars': 'error',
83
+ 'eslint/no-undef': 'off',
84
+ 'eslint/no-unexpected-multiline': 'error',
85
+ 'eslint/no-unreachable': 'off',
86
+ 'eslint/no-unsafe-finally': 'error',
87
+ 'eslint/no-unsafe-negation': 'off',
88
+ 'eslint/no-unsafe-optional-chaining': 'error',
89
+ 'eslint/no-unused-labels': 'error',
90
+ 'eslint/no-unused-private-class-members': 'error',
91
+ 'eslint/no-unused-vars': 'off',
92
+ 'eslint/no-useless-assignment': 'off',
93
+ 'eslint/no-useless-backreference': 'error',
94
+ 'eslint/no-useless-catch': 'error',
95
+ 'eslint/no-useless-escape': 'error',
96
+ 'eslint/no-with': 'off',
97
+ 'eslint/preserve-caught-error': 'error',
98
+ 'eslint/require-yield': 'error',
99
+ 'eslint/use-isnan': 'error',
100
+ 'eslint/valid-typeof': 'error',
101
+ 'eslint/no-var': 'error',
102
+ 'eslint/prefer-const': 'error',
103
+ 'eslint/prefer-rest-params': 'error',
104
+ 'eslint/prefer-spread': 'off',
105
+ 'typescript/ban-ts-comment': 'off',
106
+ 'eslint/no-array-constructor': 'error',
107
+ 'typescript/no-duplicate-enum-values': 'off',
108
+ 'typescript/no-empty-object-type': 'off',
109
+ 'typescript/no-explicit-any': 'error',
110
+ 'typescript/no-extra-non-null-assertion': 'error',
111
+ 'typescript/no-misused-new': 'error',
112
+ 'typescript/no-namespace': 'error',
113
+ 'typescript/no-non-null-asserted-optional-chain': 'error',
114
+ 'typescript/no-require-imports': 'error',
115
+ 'typescript/no-this-alias': 'error',
116
+ 'typescript/no-unnecessary-type-constraint': 'error',
117
+ 'typescript/no-unsafe-declaration-merging': 'error',
118
+ 'typescript/no-unsafe-function-type': 'error',
119
+ 'eslint/no-unused-expressions': 'error',
120
+ 'typescript/no-wrapper-object-types': 'error',
121
+ 'typescript/prefer-as-const': 'error',
122
+ 'typescript/prefer-namespace-keyword': 'error',
123
+ 'typescript/triple-slash-reference': 'error',
124
+ 'typescript/await-thenable': 'error',
125
+ 'typescript/no-array-delete': 'error',
126
+ 'typescript/no-base-to-string': 'error',
127
+ 'typescript/no-confusing-void-expression': 'off',
128
+ 'typescript/no-deprecated': 'off',
129
+ 'typescript/no-duplicate-type-constituents': 'error',
130
+ 'typescript/no-dynamic-delete': 'error',
131
+ 'typescript/no-extraneous-class': 'off',
132
+ 'typescript/no-floating-promises': 'off',
133
+ 'typescript/no-for-in-array': 'error',
134
+ 'eslint/no-implied-eval': 'off',
135
+ 'typescript/no-implied-eval': 'error',
136
+ 'typescript/no-invalid-void-type': 'error',
137
+ 'typescript/no-meaningless-void-operator': 'error',
138
+ 'typescript/no-misused-promises': 'off',
139
+ 'typescript/no-misused-spread': 'error',
140
+ 'typescript/no-mixed-enums': 'error',
141
+ 'typescript/no-non-null-asserted-nullish-coalescing': 'error',
142
+ 'typescript/no-non-null-assertion': 'error',
143
+ 'typescript/no-redundant-type-constituents': 'error',
144
+ 'typescript/no-unnecessary-boolean-literal-compare': 'error',
145
+ 'typescript/no-unnecessary-condition': 'off',
146
+ 'typescript/no-unnecessary-template-expression': 'error',
147
+ 'typescript/no-unnecessary-type-arguments': 'off',
148
+ 'typescript/no-unnecessary-type-assertion': 'error',
149
+ 'typescript/no-unnecessary-type-conversion': 'warn',
150
+ 'typescript/no-unnecessary-type-parameters': 'off',
151
+ 'typescript/no-unsafe-argument': 'off',
152
+ 'typescript/no-unsafe-assignment': 'off',
153
+ 'typescript/no-unsafe-call': 'off',
154
+ 'typescript/no-unsafe-enum-comparison': 'error',
155
+ 'typescript/no-unsafe-member-access': 'off',
156
+ 'typescript/no-unsafe-return': 'error',
157
+ 'typescript/no-unsafe-unary-minus': 'error',
158
+ 'eslint/no-useless-constructor': 'error',
159
+ 'typescript/no-useless-default-assignment': 'error',
160
+ 'eslint/no-throw-literal': 'off',
161
+ 'typescript/only-throw-error': 'off',
162
+ 'typescript/prefer-literal-enum-member': 'error',
163
+ 'eslint/prefer-promise-reject-errors': 'off',
164
+ 'typescript/prefer-promise-reject-errors': 'error',
165
+ 'typescript/prefer-reduce-type-parameter': 'error',
166
+ 'typescript/prefer-return-this-type': 'error',
167
+ 'typescript/related-getter-setter-pairs': 'error',
168
+ 'eslint/require-await': 'off',
169
+ 'typescript/require-await': 'error',
170
+ 'typescript/restrict-plus-operands': [
171
+ 'error',
172
+ {
173
+ allowAny: false,
174
+ allowBoolean: false,
175
+ allowNullish: false,
176
+ allowNumberAndString: false,
177
+ allowRegExp: false,
178
+ },
179
+ ],
180
+ 'typescript/restrict-template-expressions': 'off',
181
+ 'typescript/return-await': ['error', 'error-handling-correctness-only'],
182
+ 'typescript/unbound-method': 'warn',
183
+ 'typescript/unified-signatures': 'error',
184
+ 'typescript/use-unknown-in-catch-callback-variable': 'error',
185
+ 'react-hooks-js/rules-of-hooks': 'error',
186
+ 'react-hooks-js/exhaustive-deps': 'warn',
187
+ 'react-hooks-js/static-components': 'error',
188
+ 'react-hooks-js/use-memo': 'error',
189
+ 'react-hooks-js/preserve-manual-memoization': 'error',
190
+ 'react-hooks-js/incompatible-library': 'warn',
191
+ 'react-hooks-js/immutability': 'error',
192
+ 'react-hooks-js/globals': 'error',
193
+ 'react-hooks-js/refs': 'error',
194
+ 'react-hooks-js/set-state-in-effect': 'warn',
195
+ 'react-hooks-js/error-boundaries': 'error',
196
+ 'react-hooks-js/purity': 'error',
197
+ 'react-hooks-js/set-state-in-render': 'error',
198
+ 'react-hooks-js/unsupported-syntax': 'warn',
199
+ 'react-hooks-js/config': 'error',
200
+ 'react-hooks-js/gating': 'error',
201
+ 'react/only-export-components': [
202
+ 'warn',
203
+ {
204
+ allowConstantExport: true,
205
+ allowExportNames: [
206
+ 'loader',
207
+ 'revalidate',
208
+ 'metadata',
209
+ 'generateMetadata',
210
+ 'searchHints',
211
+ ],
212
+ },
213
+ ],
214
+ 'toiljs/no-uint8array-tostring': 'error',
215
+ 'style/padding-line-between-statements': [
216
+ 'error',
217
+ {
218
+ blankLine: 'always',
219
+ prev: 'block-like',
220
+ next: '*',
221
+ },
222
+ ],
223
+ },
224
+ });
@@ -1,7 +1,5 @@
1
1
  {
2
2
  "extends": "toilscript/std/assembly.json",
3
- "compilerOptions": {
4
- "plugins": [{ "name": "toilscript/std/ts-plugin.cjs" }]
5
- },
3
+ "compilerOptions": {},
6
4
  "include": ["./**/*.ts"]
7
5
  }
package/tsconfig.json CHANGED
@@ -8,15 +8,6 @@
8
8
  "noEmit": true,
9
9
  "incremental": false
10
10
  },
11
- "include": [
12
- "src/**/*.ts",
13
- "src/**/*.tsx",
14
- "test/**/*.ts",
15
- "std/client/index.d.ts"
16
- ],
17
- "exclude": [
18
- "node_modules",
19
- "build",
20
- "server"
21
- ]
11
+ "include": ["src/**/*.ts", "src/**/*.tsx", "std/client/index.d.ts"],
12
+ "exclude": ["node_modules", "build", "server"]
22
13
  }
@@ -1,38 +0,0 @@
1
- ---
2
- name: Bug report
3
- about: Create a report to help us improve
4
- title: ''
5
- labels: ''
6
- assignees: ''
7
-
8
- ---
9
-
10
- **Describe the bug**
11
- A clear and concise description of what the bug is.
12
-
13
- **To Reproduce**
14
- Steps to reproduce the behavior:
15
- 1. Go to '...'
16
- 2. Click on '....'
17
- 3. Scroll down to '....'
18
- 4. See error
19
-
20
- **Expected behavior**
21
- A clear and concise description of what you expected to happen.
22
-
23
- **Screenshots**
24
- If applicable, add screenshots to help explain your problem.
25
-
26
- **Desktop (please complete the following information):**
27
- - OS: [e.g. iOS]
28
- - Browser [e.g. chrome, safari]
29
- - Version [e.g. 22]
30
-
31
- **Smartphone (please complete the following information):**
32
- - Device: [e.g. iPhone6]
33
- - OS: [e.g. iOS8.1]
34
- - Browser [e.g. stock browser, safari]
35
- - Version [e.g. 22]
36
-
37
- **Additional context**
38
- Add any other context about the problem here.