Fix JS on MusicBrainz to not use variables outside the block where they were defined
We use a tool called ESLint to find problems in our JavaScript code and ensure it has a consistent style. ESLint is configured to use "rules" which each check for a different problem in the code.
This task requires you to fix all problems detected by the block-scoped-var rule.
To invoke this rule and find a list of such problems, you must first navigate to the git checkout of musicbrainz-server in your terminal, and run:
./script/check_eslint_rule 'block-scoped-var: warn' root/
The output will tell you which files it detected problems in, including line numbers, alongside a description of the actual issue on each line.
In this case, you'll need to ensure that variables are not used outside the block where they were defined. Variables declared with JavaScript's "var" statement allow this, but it can be confusing, so we would prefer to just use the variables only inside the block they're defined in. While fixing these, please change any usage of "var" to its block-scoped variant "let" (or "const" if the variable is constant, i.e. never reassigned). If a variable is simply repurposed later on, you should make that second use a new, different variable.
To complete the task, submit a pull request to our GitHub repository with a proper description mentioning the specific rule, and respond to any suggestions and requests by the MusicBrainz developers until the pull request is approved (you do not need to wait until it gets merged).