This replaces the code that previously tried to check for sorting via a wrapped compare function with a much simpler approach: JSON encode the old and (sorted) new version and see if they match. This code only runs if we have not already seen an update to the keys/contents before, so the performance implications are minimal.
This also adds a test to ensure that false negatives don't occur (i.e. it checks the --fail-on-update behavior against a file that is not being updated and was already sorted).
Fixes #955.
Why am I submitting this PR
The previous update broke --fail-on-update, making it always fail if sorting was configured.
Does it fix an existing ticket?
Yes #955
Checklist
[x] only relevant code is changed (make a diff before you submit the PR)
[x] tests are included and pass: yarn test (see details here)
This replaces the code that previously tried to check for sorting via a wrapped
compare
function with a much simpler approach: JSON encode the old and (sorted) new version and see if they match. This code only runs if we have not already seen an update to the keys/contents before, so the performance implications are minimal.This also adds a test to ensure that false negatives don't occur (i.e. it checks the --fail-on-update behavior against a file that is not being updated and was already sorted).
Fixes #955.
Why am I submitting this PR
The previous update broke --fail-on-update, making it always fail if sorting was configured.
Does it fix an existing ticket?
Yes #955
Checklist
yarn test
(see details here)