Refactor var to const/let in equipment and commands (2/4)#3301
Merged
Conversation
Migration of `var` declarations to `const`/`let` in 4 files handling
core domain logic: eqLogic, cmd, object, scenario.
Also includes incidental fixes that surfaced during the migration:
- cmd.class.js: hoisted eqLogic out of `if (notify) { ... }` block
in jeedom.cmd.execute. With `var`, hoisting made it visible to
callbacks at lines 87-172 (notifyEq calls in pre_success). With
`let`/`const` block-scoping, those callbacks would throw
"ReferenceError: eqLogic is not defined" on every command
execution from the dashboard.
4 tasks
Contributor
Author
kwizer15
approved these changes
May 2, 2026
Mips2648
approved these changes
May 5, 2026
Salvialf
reviewed
May 5, 2026
Replace the ternary expression with an explicit let + if block for clarity
and consistency with the imperative style used throughout the file:
const eqLogic = notify ? querySelector... : null
→
let eqLogic = null
if (notify) {
eqLogic = querySelector...
}
Salvialf
requested changes
May 5, 2026
Salvialf
approved these changes
May 5, 2026
Mips2648
reviewed
May 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Second of four migration PRs splitting #3297 by functional domain. This batch covers 4 files handling core domain logic (equipment, commands, objects, scenarios):
These are the most complex files in
core/js/, with deeply nested callbacks (success/error/pre_success/forEach), so this batch warrants more careful review than the utility batch.Incidental fix (caught during migration)
cmd.class.js(jeedom.cmd.execute) —var eqLogicwas declared inside anif (notify) { ... }block but referenced from callbacks at lines 87, 107, 131, 151, 166, 172 (thejeedom.cmd.notifyEq(eqLogic, true)calls inpre_success). Withvar, function-scoped hoisting made it visible. Migrated toconst/letit became block-scoped and threwReferenceError: eqLogic is not definedon every dashboard command execution. Fix: hoisted the declaration out of theifblock using a ternary soconst eqLogic = ... : null.Test plan
ReferenceErrorand the eqLogic notification (the brief icon flash) still triggerseqLogic.printandeqLogic.saveworkPart of the split following #3297 discussion.