Skip to content

Commit d2c4b0c

Browse files
committed
Bug 1869678 - Use more idiomatic code patterns for better type inference r=robwu
These fall under 5 main categories: 1) Declare and/or initialize all class fiels in the constructor. (general good practise) 2) Use real getters and redefineGetter instead of defineLazyGetter. (also keeps related code closer together) 3) When subclassing, don't override class fields with getters (or vice versa). microsoft/TypeScript#33509 4) Declare and assign object literals at the same time, not separatelly. (don't use `let foo;` at the top of the file, use `var foo = {`) 5) Don't re-use local variables unnecesarily with different types. (general good practise, local variables are "free") Differential Revision: https://phabricator.services.mozilla.com/D196386 UltraBlame original commit: 8e768446e17cc306729e3b0f705b0285c69321cf
1 parent e29e1d8 commit d2c4b0c

20 files changed

+2015
-1416
lines changed

toolkit/components/extensions/.eslintrc.js

Lines changed: 108 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,9 +393,13 @@ console
393393
/
394394
No
395395
using
396-
variables
396+
things
397397
before
398+
they
399+
'
400+
re
398401
defined
402+
.
399403
"
400404
no
401405
-
@@ -406,9 +410,112 @@ before
406410
define
407411
"
408412
:
413+
[
409414
"
410415
error
411416
"
417+
{
418+
allowNamedExports
419+
:
420+
true
421+
classes
422+
:
423+
true
424+
/
425+
/
426+
The
427+
next
428+
two
429+
being
430+
false
431+
allows
432+
idiomatic
433+
patterns
434+
which
435+
are
436+
more
437+
/
438+
/
439+
type
440+
-
441+
inference
442+
friendly
443+
.
444+
Functions
445+
are
446+
hoisted
447+
so
448+
this
449+
is
450+
safe
451+
.
452+
functions
453+
:
454+
false
455+
/
456+
/
457+
This
458+
flag
459+
is
460+
only
461+
meaningful
462+
for
463+
var
464+
declarations
465+
.
466+
/
467+
/
468+
When
469+
false
470+
it
471+
still
472+
disallows
473+
use
474+
-
475+
before
476+
-
477+
define
478+
in
479+
the
480+
same
481+
scope
482+
.
483+
/
484+
/
485+
Since
486+
we
487+
only
488+
allow
489+
var
490+
at
491+
the
492+
global
493+
scope
494+
this
495+
is
496+
no
497+
worse
498+
than
499+
/
500+
/
501+
how
502+
we
503+
currently
504+
declare
505+
an
506+
uninitialized
507+
let
508+
at
509+
the
510+
top
511+
of
512+
file
513+
.
514+
variables
515+
:
516+
false
517+
}
518+
]
412519
/
413520
/
414521
Disallow

toolkit/components/extensions/ConduitsParent.sys.mjs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3114,7 +3114,8 @@ this
31143114
)
31153115
;
31163116
}
3117-
sender
3117+
let
3118+
remote
31183119
=
31193120
Hub
31203121
.
@@ -3128,10 +3129,10 @@ sender
31283129
if
31293130
(
31303131
!
3131-
sender
3132+
remote
31323133
|
31333134
|
3134-
sender
3135+
remote
31353136
.
31363137
actor
31373138
!
@@ -3173,7 +3174,7 @@ Hub
31733174
.
31743175
recvConduitClosed
31753176
(
3176-
sender
3177+
remote
31773178
)
31783179
;
31793180
}
@@ -3224,6 +3225,8 @@ actor
32243225
this
32253226
query
32263227
sender
3228+
:
3229+
remote
32273230
}
32283231
)
32293232
;

0 commit comments

Comments
 (0)