sort-js-object-keys
sort-js-object-keys copied to clipboard
[BUG] Spreads are improperly sorted
Description
Sorting an object with spreads results in fields in the wrong order, altering the result.
Given these objects:
const objA = {
h: 1080,
w: 1600
}
const objB = {
...objA,
w: 1920
}
sorting objB with the extension results in
const objB = {
w: 1920,
...objA
}
which is incorrect, as the new fields are no longer overwriting those in the spread object.
Expected result
const objB = {
...objA,
w: 1920
}
objB === { h: 1080, w: 1920 }
Actual result
const objB = {
w: 1920,
...objA
}
objB === { h: 1080, w: 1600 }
Environment
macOS Big Sur 11.6 (20G165) VSC 1.62.0