Fix migrating mt-[0px]
to -mt-[0px]
instead of the other way around
#18154
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.
I was testing to upgrade tool on various random projects just to see how it behaves. Then I noticed an odd migration...
This PR fixes an issue where the upgrade tool accidentally migrated classes such as
mt-[0px]
to-mt-[0px]
. The reason for this is because we are trying to find a replacement, and the computed signature for both of them are exactly the same.mt-[0px]
translates to:-mt-[0px]
translates to:Which in turn translates to
Notice that this is
0px
, not-0px
.Internally we use the roots of functional utilities to find replacements. For intellisense purposes we typically show negative versions before positive versions. This then means that we will try
-mt-*
beforemt-*
. Because of the signature above, themt-[0px]
was translated into-mt-[0px]
.We could solve this in a few ways. The first thing we can try is to make sure that the signature is not the same and that
-mt-[0px]
actually translates into-0px
not0px
.This would solve our problem of the accidental migration. However, if we just sort the functional utilities roots such that the positive versions exist before negative version and rely on the fact that
-mt-[0px]
has the same signature. Then it also means that by doing that we can migrate-mt-[0px]
intomt-[0px]
which is even better because it's the same result and shorter.Test plan
mt-[0px]
does not get migrated to-mt-[0px]
.-mt-[0px]
does get migrated tomt-[0px]
.