Skip to content

Preparing for v3#757

Merged
Janther merged 13 commits intomainfrom
preparing-parser-for-v3
Dec 21, 2022
Merged

Preparing for v3#757
Janther merged 13 commits intomainfrom
preparing-parser-for-v3

Conversation

@Janther
Copy link
Copy Markdown
Member

@Janther Janther commented Nov 14, 2022

closes #747

Once the PR is merged, the plugin will run smoothly with V2 and V3.

We had to drop the coverage since there were a few cases where we would branch the execution depending on which version of prettier we'd be running.

@Janther Janther requested a review from a team November 14, 2022 23:32
@Janther Janther force-pushed the preparing-parser-for-v3 branch 2 times, most recently from d441249 to 789f8cf Compare November 23, 2022 11:06
@Janther Janther force-pushed the preparing-parser-for-v3 branch 2 times, most recently from c5bb9a5 to 1161544 Compare December 8, 2022 20:35
@Janther Janther force-pushed the preparing-parser-for-v3 branch from 1161544 to 0675da9 Compare December 13, 2022 21:41
@Janther Janther force-pushed the preparing-parser-for-v3 branch from f3adf96 to b7cd74d Compare December 20, 2022 10:01
Copy link
Copy Markdown
Member

@fvictorio fvictorio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand all the changes here, but since we've already released v1.0.0, I'm fine with merging this!

@fvictorio
Copy link
Copy Markdown
Member

Something I wonder though: can we have automated tests that make some smoke test with prettier v2 and v3, to check that everything works?

cc @sosukesuzuki @fisker do you know if some plugin is doing something like that?

@Janther
Copy link
Copy Markdown
Member Author

Janther commented Dec 21, 2022

I don't understand all the changes here, but since we've already released v1.0.0, I'm fine with merging this!

So mainly V2 would still generate the concat object under the hood so in some places when we print comments, with V2 we would get a concatenation of comments and with V3 we would get an array of comments. We needed an array always so we could iterate, that's why we have to check if it's V2 so we can retrieve the array within the concat object, while in V3 we just ask for the array.

other changes is that the clean function is more strict now and doesn't iterate over comments. so now we have to clean the comments as well.

and for testing, prettier now returns promises so we have to wait for the resolution.

I also added a utility function that tells us if the prettier version satisfies a range. that way we can use the same function to check if we are in V2 or V3 and also if we are at least V2.3.0 which is when we had to force our users to update their prettier version.

also since there are branches that we would never reach because one thing if mocking Prettier version on tests and another is Mocking the behaviour of the concat builder (or lack of it) so I had to lower our coverage standards.

prettier standalone plugins file names also changed in V3 so we had to adapt so our latest markdown would be properly loaded on standalone testing.

and finally the thing that started this rabbit hole. The parse function now receives 2 arguments and in V2 we used to get 3. So we had to adapt.

@Janther
Copy link
Copy Markdown
Member Author

Janther commented Dec 21, 2022

Something I wonder though: can we have automated tests that make some smoke test with prettier v2 and v3, to check that everything works?

in this PR there's a new task in our CI that installs V2 before running the tests in V2. I'm not too familiar with GitHub actions but I assume we could run all of the tests only if a particular small test fails.

@fvictorio
Copy link
Copy Markdown
Member

in this PR there's a new task in our CI that installs V2 before running the tests in V2. I'm not too familiar with GitHub actions but I assume we could run all of the tests only if a particular small test fails

I missed that part, that is cool and I think it's good enough!

And thanks for the explanation 😃

@Janther Janther merged commit 44a230b into main Dec 21, 2022
@Janther Janther deleted the preparing-parser-for-v3 branch December 21, 2022 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate to Prettier v3

2 participants