Skip to content

Fix undeclared variables in webrtc, time and normalize - #1436

Open
mikeua wants to merge 1 commit into
amark:masterfrom
mikeua:fix-undeclared-vars-lib
Open

mikeua wants to merge 1 commit into
amark:masterfrom
mikeua:fix-undeclared-vars-lib

Conversation

@mikeua

@mikeua mikeua commented Oct 7, 2026

Copy link
Copy Markdown

More no-undef findings in lib/ (follow-up to #1434):

  • lib/webrtc.js: open() does peer.$ = gun and gun.on('rtc', eve), but there is no gun in scope (the module only has root from GUN.on('opt', function(root){…})). Unless the app happens to define a global gun, creating a WebRTC peer throws ReferenceError: gun is not defined. Changed both to root.$, which is what the rest of the file uses (root.$.get('/RTC/…')).
  • lib/time.js: opt is assigned without being declared, leaking an implicit global; added it to the existing var list.
  • lib/normalize.js: in moveSpace() the var list ends with ; after s = …, so sAdd and pAdd (and n2) become implicit globals shared across recursive calls; t2 in next() was also undeclared. Changed ; to , and declared the missing names.

All three files still parse, and eslint no-undef no longer reports these names.

- lib/webrtc.js: open() referenced an undeclared 'gun' for peer.$ and
  the 'rtc' event, so creating a peer throws ReferenceError unless the
  app happens to define a global 'gun'. Use root.$, like the rest of
  the file.
- lib/time.js: 'opt' was assigned without a declaration (implicit
  global).
- lib/normalize.js: a ';' instead of ',' ended the var list in
  moveSpace(), turning sAdd/pAdd (and n2) into implicit globals; t2 in
  next() was undeclared as well.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant