Utilize jscodeshift CLI results output#525
Merged
gitKrystan merged 15 commits intoember-codemods:masterfrom Apr 25, 2023
Merged
Utilize jscodeshift CLI results output#525gitKrystan merged 15 commits intoember-codemods:masterfrom
gitKrystan merged 15 commits intoember-codemods:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #523
Previous iterations of this codemod did not take full advantage of jscodeshift's (undocumented AFAICT) results API.
Thus, a user might see:
when their codemods.log file had multiple entries like this:
This discrepancy can be pretty confusing for users.
I did some code-reading and found that jscodeshift checks the output of the transform function and sorts the transform attempt into its corresponding results category based on the following:
errorsthrowunmodifiedstring(unchanged)skippedundefinedokstring(changed)While the changes to make this happen for this codemod were trivial, I found that neither codemod-cli nor jscodeshift's testing helpers expect the transform to throw, so I had to re-write the testing helpers and get a little creative to expect errors and error messages. Thus, this PR is mostly testing changes.
Additionally, due to the nature of
throwing to give anerrorsresult, I had to remove thepartialTransformsfunctionality. This means that the codemod will fail for the file if any object within the file fails. This is standard for jscodeshift codemods apparently and was the standard for this codemod until very recently when I changed it thinking it would be helpful. It turns out not to be helpful.