toiljs 0.0.115 → 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.
- package/CHANGELOG.md +10 -0
- package/README.md +16 -7
- package/TYPESCRIPT_LAW.md +1946 -2073
- package/build/backend/.tsbuildinfo +1 -1
- package/build/cli/.tsbuildinfo +1 -1
- package/build/cli/index.js +2375 -258
- package/build/client/.tsbuildinfo +1 -1
- package/build/client/dev/devtools.js +1 -1
- package/build/client/dev/error-overlay.js +1 -1
- package/build/client/routing/mount.js +1 -1
- package/build/compiler/.tsbuildinfo +1 -1
- package/build/compiler/auth-emails.js +7 -3
- package/build/compiler/emails.js +1 -1
- package/build/compiler/index.d.ts +1 -0
- package/build/compiler/index.js +25 -4
- package/build/compiler/pages.js +2 -3
- package/build/compiler/prerender.d.ts +3 -8
- package/build/compiler/prerender.js +88 -127
- package/build/compiler/ssg.js +3 -4
- package/build/compiler/template-build.js +3 -4
- package/build/compiler/toil-docs.generated.js +6 -5
- package/build/compiler/vite.js +3 -6
- package/build/devserver/.tsbuildinfo +1 -1
- package/build/devserver/db/database.js +7 -3
- package/build/devserver/db/types.js +1 -1
- package/build/devserver/production.js +4 -3
- package/build/devserver/runtime/crypto.d.ts +1 -1
- package/build/io/.tsbuildinfo +1 -1
- package/build/logger/.tsbuildinfo +1 -1
- package/build/shared/.tsbuildinfo +1 -1
- package/examples/basic/client/routes/analytics.tsx +7 -5
- package/examples/basic/server/tsconfig.json +1 -3
- package/package.json +45 -44
- package/presets/no-uint8array-tostring.js +120 -153
- package/presets/oxlint.d.ts +5 -0
- package/presets/oxlint.js +224 -0
- package/server/runtime/tsconfig.json +1 -3
- package/tsconfig.json +2 -11
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -38
- package/.github/ISSUE_TEMPLATE/bug_report.yml +0 -90
- package/.github/ISSUE_TEMPLATE/config.yml +0 -8
- package/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
- package/.github/PULL_REQUEST_TEMPLATE.md +0 -43
- package/.github/changelog-config.json +0 -45
- package/.github/dependabot.yml +0 -27
- package/.github/workflows/ci.yml +0 -222
- package/.vscode/settings.json +0 -10
- package/docs/README.md +0 -107
- package/docs/auth/README.md +0 -104
- package/docs/auth/configuration.md +0 -105
- package/docs/auth/emails.md +0 -92
- package/docs/auth/extending.md +0 -202
- package/docs/auth/how-it-works.md +0 -138
- package/docs/auth/usage.md +0 -188
- package/docs/backend/README.md +0 -143
- package/docs/backend/data.md +0 -351
- package/docs/backend/rest.md +0 -402
- package/docs/backend/rpc.md +0 -226
- package/docs/background/README.md +0 -114
- package/docs/background/daemons.md +0 -276
- package/docs/background/derive.md +0 -179
- package/docs/cli/README.md +0 -379
- package/docs/concepts/ai-guide.md +0 -132
- package/docs/concepts/config.md +0 -416
- package/docs/concepts/decorators.md +0 -127
- package/docs/concepts/security.md +0 -108
- package/docs/concepts/tiers.md +0 -166
- package/docs/concepts/types.md +0 -216
- package/docs/database/README.md +0 -143
- package/docs/database/capacity.md +0 -350
- package/docs/database/counters.md +0 -174
- package/docs/database/documents.md +0 -277
- package/docs/database/events.md +0 -307
- package/docs/database/membership.md +0 -246
- package/docs/database/setup.md +0 -155
- package/docs/database/unique.md +0 -216
- package/docs/database/views.md +0 -246
- package/docs/frontend/README.md +0 -104
- package/docs/frontend/components.md +0 -286
- package/docs/frontend/data-fetching.md +0 -260
- package/docs/frontend/images.md +0 -148
- package/docs/frontend/metadata.md +0 -344
- package/docs/frontend/navigation.md +0 -296
- package/docs/frontend/rendering.md +0 -236
- package/docs/frontend/routing.md +0 -346
- package/docs/frontend/scripts.md +0 -118
- package/docs/frontend/search.md +0 -191
- package/docs/frontend/styling.md +0 -147
- package/docs/frontend/toil-global.md +0 -216
- package/docs/getting-started/README.md +0 -81
- package/docs/getting-started/create-project.md +0 -131
- package/docs/getting-started/deploy.md +0 -101
- package/docs/getting-started/first-app.md +0 -215
- package/docs/getting-started/installation.md +0 -124
- package/docs/getting-started/migrating.md +0 -125
- package/docs/getting-started/project-structure.md +0 -163
- package/docs/introduction/README.md +0 -66
- package/docs/introduction/design-principles.md +0 -81
- package/docs/introduction/distributed.md +0 -91
- package/docs/introduction/how-it-works.md +0 -121
- package/docs/introduction/hyperscale.md +0 -70
- package/docs/introduction/modern-stack.md +0 -85
- package/docs/introduction/vs-other-frameworks.md +0 -64
- package/docs/introduction/why-toil.md +0 -99
- package/docs/llms.txt +0 -95
- package/docs/realtime/README.md +0 -102
- package/docs/realtime/channels.md +0 -211
- package/docs/realtime/streams.md +0 -369
- package/docs/services/README.md +0 -60
- package/docs/services/analytics.md +0 -279
- package/docs/services/caching.md +0 -175
- package/docs/services/cookies.md +0 -235
- package/docs/services/crypto.md +0 -209
- package/docs/services/email.md +0 -289
- package/docs/services/environment.md +0 -141
- package/docs/services/ratelimit.md +0 -174
- package/docs/services/time.md +0 -85
- package/eslint.config.js +0 -57
- package/examples/basic/client/routes/docs/[...slug].tsx +0 -12
- package/presets/eslint.js +0 -88
- package/src/backend/index.ts +0 -204
- package/src/cli/configure.ts +0 -363
- package/src/cli/create.ts +0 -924
- package/src/cli/db.ts +0 -158
- package/src/cli/diagnostics.ts +0 -665
- package/src/cli/doctor.ts +0 -982
- package/src/cli/features.ts +0 -170
- package/src/cli/index.ts +0 -326
- package/src/cli/notify.ts +0 -120
- package/src/cli/proc.ts +0 -56
- package/src/cli/ui.ts +0 -169
- package/src/cli/update.ts +0 -248
- package/src/cli/updates.ts +0 -92
- package/src/cli/validate.ts +0 -31
- package/src/cli/version-check.ts +0 -125
- package/src/client/auth.ts +0 -869
- package/src/client/channel/channel.ts +0 -146
- package/src/client/components/Form.tsx +0 -65
- package/src/client/components/Image.tsx +0 -160
- package/src/client/components/Script.tsx +0 -113
- package/src/client/components/Slot.tsx +0 -21
- package/src/client/dev/devtools.tsx +0 -1089
- package/src/client/dev/error-overlay.tsx +0 -225
- package/src/client/errors.ts +0 -11
- package/src/client/head/head.ts +0 -182
- package/src/client/head/metadata.ts +0 -110
- package/src/client/index.ts +0 -130
- package/src/client/navigation/Link.tsx +0 -108
- package/src/client/navigation/NavLink.tsx +0 -86
- package/src/client/navigation/navigation.ts +0 -235
- package/src/client/navigation/prefetch.ts +0 -169
- package/src/client/navigation/scroll.ts +0 -53
- package/src/client/routing/Router.tsx +0 -216
- package/src/client/routing/action.ts +0 -122
- package/src/client/routing/error-boundary.tsx +0 -43
- package/src/client/routing/hooks.ts +0 -140
- package/src/client/routing/lazy.ts +0 -77
- package/src/client/routing/loader.ts +0 -381
- package/src/client/routing/match.ts +0 -47
- package/src/client/routing/mount.tsx +0 -90
- package/src/client/routing/params-context.ts +0 -10
- package/src/client/routing/slot-context.ts +0 -7
- package/src/client/rpc.ts +0 -97
- package/src/client/search/search.ts +0 -189
- package/src/client/search/use-page-search.ts +0 -73
- package/src/client/ssr/markers.tsx +0 -172
- package/src/client/stream/client.ts +0 -237
- package/src/client/types.ts +0 -73
- package/src/compiler/auth-emails.ts +0 -312
- package/src/compiler/config.ts +0 -369
- package/src/compiler/docs.ts +0 -127
- package/src/compiler/email-preview.ts +0 -314
- package/src/compiler/emails.ts +0 -404
- package/src/compiler/fonts.ts +0 -89
- package/src/compiler/generate.ts +0 -471
- package/src/compiler/image-blur.ts +0 -42
- package/src/compiler/image-report.ts +0 -88
- package/src/compiler/index.ts +0 -1362
- package/src/compiler/pages.ts +0 -49
- package/src/compiler/plugin.ts +0 -391
- package/src/compiler/prerender.ts +0 -263
- package/src/compiler/routes.ts +0 -170
- package/src/compiler/seo.ts +0 -415
- package/src/compiler/sri.ts +0 -144
- package/src/compiler/ssg.ts +0 -177
- package/src/compiler/ssr-codegen.ts +0 -85
- package/src/compiler/template-build.ts +0 -676
- package/src/compiler/template.ts +0 -262
- package/src/compiler/toil-docs.generated.ts +0 -77
- package/src/compiler/vite.ts +0 -245
- package/src/devserver/analytics/index.ts +0 -317
- package/src/devserver/config/dotenv.ts +0 -102
- package/src/devserver/config/env.ts +0 -30
- package/src/devserver/config/ratelimit.ts +0 -123
- package/src/devserver/daemon/catalog.ts +0 -120
- package/src/devserver/daemon/cron.ts +0 -87
- package/src/devserver/daemon/host.ts +0 -134
- package/src/devserver/daemon/index.ts +0 -369
- package/src/devserver/daemon/runtime.ts +0 -48
- package/src/devserver/db/catalog.ts +0 -109
- package/src/devserver/db/database.ts +0 -1834
- package/src/devserver/db/derives.ts +0 -121
- package/src/devserver/db/index.ts +0 -20
- package/src/devserver/db/routeKinds.ts +0 -191
- package/src/devserver/db/types.ts +0 -168
- package/src/devserver/email/caps.ts +0 -0
- package/src/devserver/email/config.ts +0 -141
- package/src/devserver/email/console.ts +0 -348
- package/src/devserver/email/index.ts +0 -155
- package/src/devserver/email/providers.ts +0 -131
- package/src/devserver/email/status.ts +0 -23
- package/src/devserver/email/validate.ts +0 -37
- package/src/devserver/email/wire.ts +0 -55
- package/src/devserver/http/cache.ts +0 -0
- package/src/devserver/http/envelope.ts +0 -157
- package/src/devserver/http/proxy.ts +0 -172
- package/src/devserver/http/runtime.ts +0 -387
- package/src/devserver/index.ts +0 -43
- package/src/devserver/production-ipc.ts +0 -63
- package/src/devserver/production-worker.ts +0 -83
- package/src/devserver/production.ts +0 -718
- package/src/devserver/runtime/crypto.ts +0 -587
- package/src/devserver/runtime/host.ts +0 -427
- package/src/devserver/runtime/module.ts +0 -442
- package/src/devserver/server.ts +0 -251
- package/src/devserver/ssr.ts +0 -208
- package/src/devserver/stream/catalog.ts +0 -106
- package/src/devserver/stream/host.ts +0 -42
- package/src/devserver/stream/index.ts +0 -301
- package/src/devserver/stream/manager.ts +0 -167
- package/src/devserver/stream/router.ts +0 -101
- package/src/devserver/stream/wire.ts +0 -58
- package/src/devserver/stream/ws.ts +0 -78
- package/src/devserver/wasm/sections.ts +0 -59
- package/src/devserver/wasm/surface.ts +0 -115
- package/src/io/FastMap.ts +0 -151
- package/src/io/FastSet.ts +0 -113
- package/src/io/codec.ts +0 -362
- package/src/io/index.ts +0 -10
- package/src/io/lengths.ts +0 -14
- package/src/io/types.ts +0 -19
- package/src/logger/index.ts +0 -22
- package/src/shared/index.ts +0 -46
- package/test/analytics-dev.test.ts +0 -113
- package/test/assembly/aspect-shim.ts +0 -33
- package/test/assembly/cookie.spec.ts +0 -303
- package/test/assembly/example.spec.ts +0 -22
- package/test/assembly/ssr.spec.ts +0 -95
- package/test/assembly.test.ts +0 -59
- package/test/auth-emails.test.ts +0 -118
- package/test/built-ssr.test.ts +0 -148
- package/test/channel.test.ts +0 -21
- package/test/config-host-port.test.ts +0 -59
- package/test/configure.test.ts +0 -94
- package/test/daemon-build.test.ts +0 -278
- package/test/daemon-catalog.test.ts +0 -349
- package/test/daemon-emulation.test.ts +0 -256
- package/test/db.test.ts +0 -0
- package/test/devserver-database.test.ts +0 -1102
- package/test/devserver-email.test.ts +0 -306
- package/test/devserver-pqauth.test.ts +0 -93
- package/test/devserver-secrets.test.ts +0 -63
- package/test/devserver.test.ts +0 -259
- package/test/doctor.test.ts +0 -298
- package/test/dom/Image.test.tsx +0 -144
- package/test/dom/Link.test.tsx +0 -67
- package/test/dom/NavLink.test.tsx +0 -37
- package/test/dom/Script.test.tsx +0 -48
- package/test/dom/action.test.tsx +0 -146
- package/test/dom/error-overlay.test.tsx +0 -44
- package/test/dom/loader.test.tsx +0 -121
- package/test/dom/navigation.test.ts +0 -59
- package/test/dom/revalidate.test.tsx +0 -38
- package/test/dom/route-head.test.tsx +0 -56
- package/test/dom/router-loading.test.tsx +0 -44
- package/test/dom/scroll.test.ts +0 -56
- package/test/dom/slot.test.tsx +0 -131
- package/test/dom/use-metadata.test.tsx +0 -58
- package/test/dom/view-transitions.test.tsx +0 -53
- package/test/dynamic-routing.test.ts +0 -132
- package/test/email-console.test.ts +0 -86
- package/test/email-preview.test.ts +0 -73
- package/test/emails.test.ts +0 -58
- package/test/errors.test.ts +0 -21
- package/test/example-guestbook.test.ts +0 -123
- package/test/features.test.ts +0 -149
- package/test/fixtures/bignum-wire/spec.ts +0 -25
- package/test/fixtures/daemon-app.ts +0 -65
- package/test/fixtures/stream-echo.ts +0 -26
- package/test/fixtures/stream-gate.ts +0 -28
- package/test/fixtures/stream-trap.ts +0 -18
- package/test/fixtures/stream-typed.ts +0 -41
- package/test/fonts.test.ts +0 -28
- package/test/global-setup.ts +0 -17
- package/test/head.test.ts +0 -42
- package/test/image-blur.test.ts +0 -50
- package/test/io.test.ts +0 -117
- package/test/metadata.test.ts +0 -40
- package/test/navlink.test.ts +0 -28
- package/test/pages.test.ts +0 -105
- package/test/placeholder.test.ts +0 -9
- package/test/pqauth-e2e.test.ts +0 -216
- package/test/pqauth-email.test.ts +0 -801
- package/test/prerender.test.ts +0 -116
- package/test/prettier-plugin.test.ts +0 -46
- package/test/routes.test.ts +0 -76
- package/test/rpc-bignum-wire.test.ts +0 -164
- package/test/rpc-dispatch.test.ts +0 -132
- package/test/rpc-kinds.test.ts +0 -18
- package/test/rpc.test.ts +0 -66
- package/test/search.test.ts +0 -114
- package/test/seo.test.ts +0 -175
- package/test/slot-layouts.test.ts +0 -69
- package/test/sri.test.ts +0 -129
- package/test/ssg.test.ts +0 -36
- package/test/ssr-hydration.test.tsx +0 -122
- package/test/ssr-render.test.ts +0 -197
- package/test/ssr-template.test.tsx +0 -482
- package/test/stream-emulation.test.ts +0 -479
- package/test/ui.test.ts +0 -40
- package/test/update.test.ts +0 -58
- package/test/validate.test.ts +0 -42
- package/test/version-check.test.ts +0 -130
- package/tests/data-parity/generated-parity.ts +0 -99
- package/tests/data-parity/parity.ts +0 -80
- package/tests/data-parity/spec.ts +0 -46
|
@@ -1,54 +1,26 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
if (
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
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
|
|
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()
|
|
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
|
|
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
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
node.arguments.length
|
|
162
|
-
)
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
const
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
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
|
-
|
|
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,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
|
+
});
|
package/tsconfig.json
CHANGED
|
@@ -8,15 +8,6 @@
|
|
|
8
8
|
"noEmit": true,
|
|
9
9
|
"incremental": false
|
|
10
10
|
},
|
|
11
|
-
"include": [
|
|
12
|
-
|
|
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.
|