fix: restore full destructure bindings and silence ESLint unused-var warnings #1442
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.
Overview
This pull request fixes a critical bug in
convert_keymap_extras_header.jsthat caused it to fail on all inputs. It restores the full destructure bindings and adds// eslint-disable-next-line no-unused-varsdirectives to preserve positional correctness while avoiding linting errors.Description
Commit 0828211 introduced a regression in the
convert_keymap_extras_header.jsscript used for i18n keymap extras.Several destructuring assignments (
let [a, b, c] = function_call();) had commented-out elements (e.g. /*fullMatch, */) to avoidno-unused-varswarnings.It appears that these unused variables (which are indeed unused because only a subset of the destructured outputs of a function are used) were quickly commented out to get rid of the warning. Unfortunately, this broke the code because the variables were no longer assigned to the correct output of the function within the destructuring assignments (if you turn
let [a, b, c] = function_call();intolet [a, /*b,*/ c] = function_call();, variablecwill point to what was intended to beb).There are multiple ways to deal with this problem:
Option 1: eslint disable comment
(does not make it clear which variable exactly is unused)
Option 2: Ignore variables with an underscore prefix
Add a rule in
eslint.config.jsto ignore the no-unused-vars warning for variables that start with an underscore:and then do this in the code:
(makes it clear which variable exactly is unused)
Option 3: name all unused variables as
_Unfortunately, this option will not work. Consider the case of multiple ignored/unused variables in the destructured assignment of line 256 in function
convertLine:For now, the PR adopts option 1 but this can be discussed.
Affected functions
Relevant discussion thread on Discord: https://discord.com/channels/440868230475677696/867530744116543508/1434968023113928848