Add blog post for v3.9 (#19414)
Co-authored-by: Alexander Kachkaev <alexander@kachkaev.ru> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
10 files changed
+2680
-40
No files matched your search
@@ -0,0 +1,18 @@
|
||||
---
|
||||
authors: "fisker"
|
||||
title: "Prettier 3.9: New Parser Foundations and Formatting Improvements"
|
||||
---
|
||||
|
||||
We are excited to announce Prettier 3.9!
|
||||
|
||||
This release brings major parser upgrades for Markdown, YAML, Flow, GraphQL, and Angular, along with formatting improvements for JavaScript and TypeScript (particularly in `--no-semi` mode).
|
||||
|
||||
If you find Prettier valuable, please consider [sponsoring us on OpenCollective](https://opencollective.com/prettier) or supporting the upstream projects we rely on. Your contributions help us keep improving the tool for everyone.
|
||||
|
||||
Thank you for your continued support! ❤️
|
||||
|
||||
A reminder, when Prettier is installed or updated, it’s [strongly recommended](https://prettier.io/docs/install#summary) to specify the exact version in `package.json`: `"prettier": "3.9.0"`, not `"prettier": "^3.9.0"`.
|
||||
|
||||
If you use [`@prettier/plugin-oxc`](https://www.npmjs.com/package/@prettier/plugin-oxc) or [`@prettier/plugin-hermes`](https://www.npmjs.com/package/@prettier/plugin-hermes), don't forget upgrade them to ensure the new formatting rules are applied.
|
||||
|
||||
<!-- truncate -->
|
||||
@@ -0,0 +1,15 @@
|
||||
#### Preserve Flow comment syntax (#19398 by @SamChou19815)
|
||||
|
||||
Preserves Flow comment syntax annotations instead of printing them as regular Flow syntax.
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```flow
|
||||
// Input
|
||||
function foo<T>(bar /*: T[] */, baz /*: T */) /*: S */ {}
|
||||
|
||||
// Prettier stable
|
||||
function foo<T>(bar: T[], baz: T): S {}
|
||||
|
||||
// Prettier main
|
||||
function foo<T>(bar /*: T[] */, baz /*: T */) /*: S */ {}
|
||||
```
|
||||
@@ -1,15 +1,5 @@
|
||||
#### Preserve Flow comment syntax and improve parser performance (#19398 by @SamChou19815)
|
||||
#### [HIGHLIGHT] New Rust-based Flow parser (#19398 by @SamChou19815)
|
||||
|
||||
Prettier now uses Flow's Rust-backed parser. This preserves Flow comment syntax annotations instead of printing them as regular Flow syntax. In local parser-only benchmarks, `flow-parser/oxidized` parsed Prettier's valid Flow fixtures in 266.4ms median time, compared with 422.6ms for the old parser, and parsed `flow_parser.js` in 1298.0ms, compared with 2269.6ms.
|
||||
Prettier now uses the new Rust-based Flow parser (oxidized) released by the Flow team, which improves performance for Flow-typed code.
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```flow
|
||||
// Input
|
||||
function foo<T>(bar /*: T[] */, baz /*: T */) /*: S */ {}
|
||||
|
||||
// Prettier stable
|
||||
function foo<T>(bar: T[], baz: T): S {}
|
||||
|
||||
// Prettier main
|
||||
function foo<T>(bar /*: T[] */, baz /*: T */) /*: S */ {}
|
||||
```
|
||||
In local parser-only benchmarks, `flow-parser/oxidized` parsed Prettier's valid Flow fixtures in 266.4ms median time, compared with 422.6ms for the old parser, and parsed `flow_parser.js` in 1298.0ms, compared with 2269.6ms.
|
||||
@@ -1,17 +0,0 @@
|
||||
#### Support "directives on directive definitions" (#19171 by @YBJ0000)
|
||||
|
||||
[Directives on directive definitions](https://github.com/graphql/graphql-js/pull/4521) (and `extend directive` extensions) are now supported.
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```gql
|
||||
# Input
|
||||
directive @a @b on QUERY
|
||||
extend directive @a @b
|
||||
|
||||
# Prettier stable
|
||||
Error: Syntax Error: Expected "on", found "@".
|
||||
|
||||
# Prettier main
|
||||
directive @a @b on QUERY
|
||||
extend directive @a @b
|
||||
```
|
||||
@@ -1,6 +1,8 @@
|
||||
#### Support "Fragment arguments" (#19297 by @fisker)
|
||||
#### [HIGHLIGHT] Support GraphQL.js v17 (#19171 by @YBJ0000, #19297 by @fisker)
|
||||
|
||||
[Fragment arguments](https://github.com/graphql/graphql-js/pull/4015) are now supported.
|
||||
Prettier now fully supports newer syntax features from GraphQL.js v17, including directives on directive definitions, fragment arguments, and other enhancements.
|
||||
|
||||
[Fragment arguments](https://github.com/graphql/graphql-js/pull/4015)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```gql
|
||||
@@ -11,13 +13,25 @@ fragment variableProfilePic on User {
|
||||
|
||||
# Prettier stable
|
||||
SyntaxError: Syntax Error: Expected Name, found "(". (2:23)
|
||||
1 | fragment variableProfilePic on User {
|
||||
> 2 | ...dynamicProfilePic(size: $size)
|
||||
| ^
|
||||
3 | }
|
||||
|
||||
# Prettier main
|
||||
fragment variableProfilePic on User {
|
||||
...dynamicProfilePic(size: $size)
|
||||
}
|
||||
```
|
||||
|
||||
[Directives on directive definitions](https://github.com/graphql/graphql-js/pull/4521) (and `extend directive` extensions)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```gql
|
||||
# Input
|
||||
directive @a @b on QUERY
|
||||
extend directive @a @b
|
||||
|
||||
# Prettier stable
|
||||
Error: Syntax Error: Expected "on", found "@".
|
||||
|
||||
# Prettier main
|
||||
directive @a @b on QUERY
|
||||
extend directive @a @b
|
||||
```
|
||||
@@ -1,5 +1,7 @@
|
||||
#### [HIGHLIGHT] Upgrade parser to latest micromark (#18277 by @seiyab, @j-f1, @fisker)
|
||||
|
||||
We've upgraded Prettier's Markdown parser from the outdated remark-parse v8 to the modern micromark v4. This upgrade significantly enhances CommonMark and GFM compliance, resolves numerous long-standing parsing bugs, and lays a stronger foundation for future enhancements.
|
||||
We've upgraded Prettier's Markdown parser from the outdated `remark-parse` v8 to the modern `micromark` v4. This upgrade significantly enhances CommonMark and GFM compliance, resolves numerous long-standing parsing bugs, and lays a stronger foundation for future enhancements.
|
||||
|
||||
A huge thank you to @seiyab for their tremendous effort in driving this major upgrade!
|
||||
Huge thanks to [@seiyab](https://github.com/seiyab), [@j-f1](https://github.com/j-f1), and everyone else who contributed to this long-awaited improvement for their tremendous effort in driving this major upgrade!
|
||||
|
||||
**Note**: While the core Markdown parser has been upgraded, [the MDX parser upgrade](https://github.com/prettier/prettier/pull/18533) is not yet complete. If you're familiar with the unified ecosystem, micromark, or MDX, we'd love your help to finish the migration — contributions are very welcome!
|
||||
@@ -1,4 +1,4 @@
|
||||
#### updating `Printer` interface (#19014 by @Janther)
|
||||
#### Update `Printer` interface (#19014 by @Janther)
|
||||
|
||||
```diff
|
||||
export interface Printer<T = any> {
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
#### [HIGHLIGHT] Update dependency `yaml` to v2 (#18419 by @ota-meshi, @fisker)
|
||||
|
||||
The YAML parser has been upgraded to use `yaml` v2, which fixes many long standing parse issues.
|
||||
|
||||
Thanks to excellent work on the [`yaml-unist-parser`](https://github.com/prettier/yaml-unist-parser/pull/301) side by [@ota-meshi](https://github.com/ota-meshi).
|
||||
Reference in new issue
Block a user