refactor: retire function-keyword in favor of arrow/method syntax (reconstruct #474 on current master) - #589
refactor: retire function-keyword in favor of arrow/method syntax (reconstruct #474 on current master)#589kriscendobot wants to merge 19 commits into
Conversation
|
Reconstruction of #474 on current upstream master is up. Scope — reproduces #474's function-keyword→arrow/concise-method conversion across the same 17 packages How it differs from merged #474 — re-derived against the current tree, not cherry-picked. Conversions Deliberately out of scope — the audit surfaced further un-migrated sites in SES files #474 never Verification — |
|
Mirror of endojs/endo#3318 (head b25a1b6e2). |
|
On it — I've posted a job ( |
|
Mirror parity verified against endojs/endo#3318 (head Compared this PR's diff to endo#3318's at that head:
No changes needed — this reconstruction is a faithful mirror of endo#3318 at |
Add the house-style doc for arrow and concise-method syntax over the function keyword (rationale, hardened-JS hazards, exception categories) and link it from AGENTS.md. Reconstructs the doc from #474.
a97452b to
4f14a7f
Compare
Summary
Reconstructs endojs/endo-but-for-bots#474
(refactor: retire function-keyword in favor of arrow/method syntax per erights review, merged)
on the current upstream
endojs/endomaster, rather than cherry-picking #474's commits onto astale base.
Per erights's review,
function-keyword functions carry four hazards inside hardened-JavaScript code(they have
[[Construct]], an irrelevantprototype,freeze≠harden, and declaration hoisting/TDZhazards). Arrow functions and concise methods have none of these and are the desired default. This PR
converts
function-keyword declarations/expressions to arrow / concise-method syntax across the samepackage set #474 covered, keeps the documented legitimate exceptions, and (re)establishes the house-style
convention doc.
How this differs from the merged #474
snapshot (
master-0594e99). The transformation was re-derived against that tree; where a conversion hadalready been absorbed upstream (e.g.
pass-style/src/byteArray.js,passStyleOf.js), the net change iszero and the file simply does not appear in this PR.
branch (BaseHandledPromise rename, concise generator methods in
captp/daemon, theinitAsyncLocalStorage descriptor-form install, and the cross-reference notes at exception sites).
docs/house-style/function-keyword.mdis present and current (rationale, conversionrules, and the full legitimate-exception list), linked from
AGENTS.md.Legitimate exceptions kept (unchanged from #474)
Constructor emulation (
BaseHandledPromise,NewCompartment, SES inert constructors,ModuleSource/AbstractModuleSource), standalone generator/async-generator expressions and intrinsic-prototypesentinels (
trampoline,ses/commons.js,compartment-mapper,daemon), vendored/third-party code(
cjs-module-analyzer,test262), the sloppy-modegetThisprobe, TS-assertion-via-arrow+@overload,and module-init forward references (
convertValToSlot/convertSlotToVal,serializeAndSendMessage,safeRequire). See the house-style doc for the full rationale.Out of scope (follow-up)
An audit of the current tree surfaced further un-migrated
function-keyword sites in SES files that#474 never touched — the lockdown/taming dispatch functions (
tame-*.js),permits-intrinsics.js,permits.js,enable-property-overrides.js,make-evaluate.js, and SES's ownmake-hardener.js. Theseare outside #474's original scope and several sit on the security-critical SES initialization boundary, so
they are deliberately left for a separate, individually-reviewed pass rather than folded into this
reconstruction.
Verification
eslinton all changed files: 0 errors (4 pre-existing-stylejsdoc/require-paramwarnings on theconverted daemon generator methods, identical to refactor: retire function-keyword in favor of arrow/method syntax per erights review #474's merged form; non-fatal).
node --checkon every changed file: clean.zip,trampoline,eventual-send): green. The conversion preserves arity,return value, and
thisbinding — the intended behavioral diff is zero.Upstream counterpart
The canonical upstream PR for this work is endojs/endo#3312
(refactor: retire function-keyword in favor of arrow/method syntax, OPEN). This fork PR mirrors #3312's
transformation; the head tree here is identical to #3312's, rebased onto a fresh frozen base
(
master-2708cac, a snapshot of the current upstreamendojs/endomaster). The earlier boatman-createdduplicate #3318 is closed and is not tracked.