Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to support prettier 3.0 #2157

Merged
merged 30 commits into from
Aug 4, 2023

Conversation

timotheeguerin
Copy link
Member

@timotheeguerin timotheeguerin commented Jul 7, 2023

fix #2153

This include breaking change if using the typespec formatter programatically. Some breaking changes to prettier carry over https://prettier.io/blog/2023/07/05/3.0.0.html

@github-actions
Copy link
Contributor

github-actions bot commented Jul 7, 2023

Changes in this PR will be published to the following url to try(check status of TypeSpec Pull Request Try It pipeline for publish status):
Playground: https://cadlplayground.z22.web.core.windows.net/prs/2157/

Website: https://cadlwebsite.z1.web.core.windows.net/prs/2157/

@@ -1,15 +1,15 @@
{
"arrowParens": "always",
"trailingComma": "es5",
Copy link
Member Author

Choose a reason for hiding this comment

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

Filed #2159 to change to the new default of all

@timotheeguerin timotheeguerin marked this pull request as ready for review July 10, 2023 13:45
@timotheeguerin timotheeguerin added the breaking-change A change that might cause specs or code to break label Jul 13, 2023
Copy link
Contributor

@daviwil daviwil left a comment

Choose a reason for hiding this comment

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

Jeez! Do we actually get any benefits from this upgrade? Seems like they made you jump through hoops to integrate it.

@timotheeguerin
Copy link
Member Author

Yeah there isn’t much benefits from consuming prettier 3.0. They added a few more targeted export so you don’t import the file system part in a plug-in but still missing the utils so do have to import from standalone.

I’m off for a week so will revisit after to make sure they haven’t pushed a new update with some fixes which would simplify this.

But this lets people that use prettier 3.0 to be able to use the plugin.

timotheeguerin added a commit that referenced this pull request Jul 24, 2023
Extracted this part of the breaking change from
#2157

With prettier 3.0.0 the formatter is async. Which requires the emitter
framework to provide a way to deal with async content mutation.

This only breaks in the emitter framework is calling
`this.emitter.emitSourceFile` directly which would happen if you wrote a
custom `writeOutput`. If usage only include `sourceFile` override then
it still allows returning a non promise.

```diff
-const emittedSf = this.emitter.emitSourceFile(sf);
+const emittedSf = await this.emitter.emitSourceFile(sf);
```
@markcowl
Copy link
Contributor

Change to discuss: formatTypeSpec helper is now async

@timotheeguerin
Copy link
Member Author

timotheeguerin commented Jul 27, 2023

Change to discuss: formatTypeSpec helper is now async

Didn't we already discuss that 2 weeks ago? It shouldn't really be used by any dpg emitter.

@timotheeguerin timotheeguerin enabled auto-merge (squash) August 3, 2023 19:22
@timotheeguerin timotheeguerin changed the title Update to support prettier 3.0.0 Update to support prettier 3.0 Aug 3, 2023
@timotheeguerin timotheeguerin merged commit d355e5c into microsoft:main Aug 4, 2023
11 checks passed
@timotheeguerin timotheeguerin deleted the prettier-3.0.0 branch August 4, 2023 00:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change A change that might cause specs or code to break
Projects
None yet
Development

Successfully merging this pull request may close these issues.

@typespec/prettier-plugin-typespec errors with Prettier 3.0.0
3 participants