-
Notifications
You must be signed in to change notification settings - Fork 201
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
Conversation
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): Website: https://cadlwebsite.z1.web.core.windows.net/prs/2157/ |
@@ -1,15 +1,15 @@ | |||
{ | |||
"arrowParens": "always", | |||
"trailingComma": "es5", |
There was a problem hiding this comment.
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
There was a problem hiding this 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.
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. |
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); ```
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. |
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