diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index f01ac82f2dc2..7ae5ab1b2d70 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -5,6 +5,8 @@ # See https://git-scm.com/docs/git-blame#Documentation/git-blame.txt---ignore-revs-fileltfilegt # Prettier bump after release +# 3.2.0 +ee0d667fa2bf175c194f2f93c98c25a575454476 # 3.1.1 1178b4dff2cd78c76e8028b6deb5882348c970d9 # 3.1.0 diff --git a/.github/ISSUE_TEMPLATE/formatting.md b/.github/ISSUE_TEMPLATE/formatting.md index accaa1a0f541..b36d796ade81 100644 --- a/.github/ISSUE_TEMPLATE/formatting.md +++ b/.github/ISSUE_TEMPLATE/formatting.md @@ -26,7 +26,7 @@ Don't fill the form below manually! Let a program create a report for you: --> -**Prettier 3.2.0** +**Prettier 3.2.1** [Playground link](https://prettier.io/playground/#.....) ```sh diff --git a/.github/ISSUE_TEMPLATE/integration.md b/.github/ISSUE_TEMPLATE/integration.md index bfc4c62bb8ec..74e3f9380f82 100644 --- a/.github/ISSUE_TEMPLATE/integration.md +++ b/.github/ISSUE_TEMPLATE/integration.md @@ -20,7 +20,7 @@ BEFORE SUBMITTING AN ISSUE: **Environments:** -- Prettier Version: 3.2.0 +- Prettier Version: 3.2.1 - Running Prettier via: - Runtime: - Operating System: diff --git a/CHANGELOG.md b/CHANGELOG.md index 6bfb428fa007..a81c229859d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,27 @@ +# 3.2.1 + +[diff](https://github.com/prettier/prettier/compare/3.2.0...3.2.1) + +#### Fix formatting error on member chain ([#15915](https://github.com/prettier/prettier/pull/15915) by [@sosukesuzuki](https://github.com/sosukesuzuki)) + + +```jsx +// Input +test().test2().test2(thing?.something); + +// Prettier 3.2.0 +TypeError: Cannot read properties of undefined (reading 'type') + +// Prettier 3.2.1 +test().test2().test2(thing?.something); + +``` + # 3.2.0 [diff](https://github.com/prettier/prettier/compare/3.1.1...3.2.0) -🔗 [Release Notes](https://prettier.io/blog/2024/01/13/3.2.0.html) +🔗 [Release Notes](https://prettier.io/blog/2024/01/12/3.2.0.html) # 3.1.1 diff --git a/changelog_unreleased/angular/15777.md b/changelog_unreleased/angular/15777.md deleted file mode 100644 index 5e71f974f665..000000000000 --- a/changelog_unreleased/angular/15777.md +++ /dev/null @@ -1,19 +0,0 @@ -#### Support formatting for Angular ICU expression (#15777 by @sosukesuzuki) - -Support two kinds of Angular ICU expressions: [`plural`](https://angular.dev/guide/i18n/translation-files#translate-plurals) and [`select`](https://angular.dev/guide/i18n/translation-files#translate-alternate-expressions). - - -```html - - Updated: - {minutes, plural, - =0 {just now} - =1 {one minute ago} - other {{{minutes}} minutes ago} - } - - - - The author is {gender, select, male {male} female {female} other {other}} - -``` diff --git a/changelog_unreleased/angular/15827.md b/changelog_unreleased/angular/15827.md deleted file mode 100644 index 1cee11c2c1e5..000000000000 --- a/changelog_unreleased/angular/15827.md +++ /dev/null @@ -1,30 +0,0 @@ -#### Fix `prettier-ignore`d angular control flow block (#15827 by @fisker) - - -```html - - -@if (condition) { - Foo -} @else { - Other -} - - - -@if (condition) { - Foo -} -} @else { - Other -} - - - -@if (condition) { - Foo -} -@else { - Other -} -``` diff --git a/changelog_unreleased/angular/15887.md b/changelog_unreleased/angular/15887.md deleted file mode 100644 index e1e40cde7f64..000000000000 --- a/changelog_unreleased/angular/15887.md +++ /dev/null @@ -1,13 +0,0 @@ -#### Avoid adding colon for `track` in 3rd expression of `for` blocks (#15887 by @sosukesuzuki) - - -```html - -@for (item of items; let i = $index; track block) {} - - -@for (item of items; let i = $index; track: block) {} - - -@for (item of items; let i = $index; track block) {} -``` diff --git a/changelog_unreleased/api/15666.md b/changelog_unreleased/api/15666.md deleted file mode 100644 index 2ad2b069bc44..000000000000 --- a/changelog_unreleased/api/15666.md +++ /dev/null @@ -1,15 +0,0 @@ -#### Support absolute path as plugin in config file (#15666 by @fisker) - -```js -// prettier.config.cjs -module.exports = { - plugins: [ - // posix style - "/path/to/plugin.js", - // Windows style - "D:\\\\path\\to\\plugin.js", - // Use `require.resolve` - require.resolve("my-awesome-prettier-plugin"), - ], -}; -``` diff --git a/changelog_unreleased/api/15854.md b/changelog_unreleased/api/15854.md deleted file mode 100644 index 593066da42ed..000000000000 --- a/changelog_unreleased/api/15854.md +++ /dev/null @@ -1,11 +0,0 @@ -#### Fix `getFileInfo` and `getSupportInfo` type definitions (#15854 by @auvred) - -```ts -const plugin: Plugin = {}; - -prettier.getFileInfo("./file.ext", { - plugins: [plugin], -}); - -prettier.getSupportInfo({ plugins: [plugin], showDeprecated: true }); -``` diff --git a/changelog_unreleased/blog-post-intro.md b/changelog_unreleased/blog-post-intro.md new file mode 100644 index 000000000000..c80ebff3beed --- /dev/null +++ b/changelog_unreleased/blog-post-intro.md @@ -0,0 +1,15 @@ +--- +author: "Sosuke Suzuki (@sosukesuzuki)" +authorURL: "https://github.com/sosukesuzuki" +title: "Prettier 3.2: Support JSONC and Angular’s ICU expression" +--- + +This release includes new features such as adding a JSONC parser, adding Angular’s ICU expressions, and many bug fixes. + +We are still seeking feedback for the `--experimental-ternaries` option released in Prettier 3.1. Please read [A curious case of the ternaries](https://prettier.io/blog/2023/11/13/curious-ternaries) and respond via the Google Forms link provided. + +Additionally, we recommend reading [Prettier's CLI: A Performance Deep Dive](https://prettier.io/blog/2023/11/30/cli-deep-dive) by [Fabio Spampinato](https://github.com/fabiospampinato). This faster CLI is slated to be released as version 4.0. + + + +If you appreciate Prettier and would like to support our work, please consider sponsoring us directly via [our OpenCollective](https://opencollective.com/prettier) or by sponsoring the projects we depend on, such as [typescript-eslint](https://opencollective.com/typescript-eslint), [remark](https://opencollective.com/unified), and [Babel](https://opencollective.com/babel). Thank you for your continued support! diff --git a/changelog_unreleased/graphql/15870.md b/changelog_unreleased/graphql/15870.md deleted file mode 100644 index ef2deb5d3408..000000000000 --- a/changelog_unreleased/graphql/15870.md +++ /dev/null @@ -1,29 +0,0 @@ -#### Improve GraphQL union types formatting (#15870 by @ArchitGajjar) - - -```gql -# Input -union SearchResult = Conference| Festival | Concert | Venue | Conference| Festival | Concert | Venue - -# Prettier stable -union SearchResult = - Conference - | Festival - | Concert - | Venue - | Conference - | Festival - | Concert - | Venue - -# Prettier main -union SearchResult = - | Conference - | Festival - | Concert - | Venue - | Conference - | Festival - | Concert - | Venue -``` diff --git a/changelog_unreleased/handlebars/15605.md b/changelog_unreleased/handlebars/15605.md deleted file mode 100644 index 628f5d53baa6..000000000000 --- a/changelog_unreleased/handlebars/15605.md +++ /dev/null @@ -1,21 +0,0 @@ -#### Preserve path literal segments (#15605 by @maxpowa) - -Fixes scenarios where an input handlebars file containing literal segments would be reformatted to unwrap the literal segments, causing syntax errors in the resulting output. - - -```hbs - -{{input.[funky -{{input.funky -{{input.[funky -```html - - -

-Hello world! - - - -

- - - -

-Hello world! -``` diff --git a/changelog_unreleased/javascript/15209.md b/changelog_unreleased/javascript/15209.md deleted file mode 100644 index c533b1dfa734..000000000000 --- a/changelog_unreleased/javascript/15209.md +++ /dev/null @@ -1,21 +0,0 @@ -#### Avoid introducing linebreaks in template interpolations (#15209 by @bakkot) - -In a template string like - - -```js -`this is a long message which contains an interpolation: ${format(data)} <- like this`; -``` - -avoid adding a linebreak when formatting the expression unless one is already present or it's unavoidable due to e.g. a nested function. Previously a linebreak could be introduced whenever some interpolation in the template was sufficiently "not simple": - - -```js -`this is a long message which contains an interpolation: ${format( - data, -)} <- like this`; -``` - -Now it will instead be left alone. - -If a linebreak is already present within the `${...}`, format as normal. diff --git a/changelog_unreleased/javascript/15522.md b/changelog_unreleased/javascript/15522.md deleted file mode 100644 index cd4623c84341..000000000000 --- a/changelog_unreleased/javascript/15522.md +++ /dev/null @@ -1,22 +0,0 @@ -#### Fix non-idempotent formatting of method chain with empty line (#15522 by @seiyab) - - -```js -// Input -Foo.a() - -.b(); - -// Prettier stable (first format) -Foo.a() -.b(); - -// Prettier stable (second format) -Foo.a().b(); - - -// Prettier main -Foo.a() - - .b(); -``` diff --git a/changelog_unreleased/javascript/15677.md b/changelog_unreleased/javascript/15677.md deleted file mode 100644 index 23b340497fa5..000000000000 --- a/changelog_unreleased/javascript/15677.md +++ /dev/null @@ -1,19 +0,0 @@ -#### Fix formatting of ternary in function call (#15677 by @fisker) - - -```jsx -// Input -stopDirectory = await (useCache - ? memoizedFindProjectRoot - : findProjectRootWithoutCache)(path.dirname(path.resolve(filePath))); - -// Prettier stable -stopDirectory = await (useCache - ? memoizedFindProjectRoot - : findProjectRootWithoutCache)(path.dirname(path.resolve(filePath))); - -// Prettier main -stopDirectory = await ( - useCache ? memoizedFindProjectRoot : findProjectRootWithoutCache -)(path.dirname(path.resolve(filePath))); -``` diff --git a/changelog_unreleased/javascript/15806.md b/changelog_unreleased/javascript/15806.md deleted file mode 100644 index 8c14c4ebb441..000000000000 --- a/changelog_unreleased/javascript/15806.md +++ /dev/null @@ -1,51 +0,0 @@ -#### Fix inconsistencies for optional-chaining (#15806 by @fisker) - -Only happens when using `typescript`, `meriyah` or other ESTree parsers except `babel`. - - -```js -// Input -function someFunctionName() { - return isEqual(a.map(([t, _]) => t?.id), b.map(([t, _]) => t?.id)); - return isEqual(a?.map(([t, _]) => t?.id), b?.map(([t, _]) => t?.id)); -} -theValue = Object.entries(someLongObjectName).filter( - ([listingId]) => someListToCompareToHere.includes(listingId), -); -theValue = Object.entries(someLongObjectName).filter( - ([listingId]) => someListToCompareToHere?.includes(listingId), -); - -// Prettier stable -function someFunctionName() { - return isEqual( - a.map(([t, _]) => t?.id), - b.map(([t, _]) => t?.id), - ); - return isEqual(a?.map(([t, _]) => t?.id), b?.map(([t, _]) => t?.id)); -} -theValue = Object.entries(someLongObjectName).filter(([listingId]) => - someListToCompareToHere.includes(listingId), -); -theValue = Object.entries(someLongObjectName).filter( - ([listingId]) => someListToCompareToHere?.includes(listingId), -); - -// Prettier main -function someFunctionName() { - return isEqual( - a.map(([t, _]) => t?.id), - b.map(([t, _]) => t?.id), - ); - return isEqual( - a?.map(([t, _]) => t?.id), - b?.map(([t, _]) => t?.id), - ); -} -theValue = Object.entries(someLongObjectName).filter(([listingId]) => - someListToCompareToHere.includes(listingId), -); -theValue = Object.entries(someLongObjectName).filter(([listingId]) => - someListToCompareToHere?.includes(listingId), -); -``` diff --git a/changelog_unreleased/javascript/15826.md b/changelog_unreleased/javascript/15826.md deleted file mode 100644 index 87f79f32e808..000000000000 --- a/changelog_unreleased/javascript/15826.md +++ /dev/null @@ -1,27 +0,0 @@ -#### Fix comments in `if` (#15826 by @fisker) - - -```js -// Input -if (foo) for (i = 2; i > 0; i--) console.log(i); // comment 1 -else bar(); - -for (;;){ - if (foo) continue; // comment 2 - else bar(); -} - -// Prettier stable -Error: Comment "comment 2" was not printed. Please report this error! - -// Prettier main -if (foo) - for (i = 2; i > 0; i--) console.log(i); // comment 1 -else bar(); - -for (;;) { - if (foo) - continue; // comment 2 - else bar(); -} -``` diff --git a/changelog_unreleased/javascript/15915.md b/changelog_unreleased/javascript/15915.md new file mode 100644 index 000000000000..b493ac1b2517 --- /dev/null +++ b/changelog_unreleased/javascript/15915.md @@ -0,0 +1,14 @@ +#### Fix formatting error on member chain (#15915 by @sosukesuzuki) + + +```jsx +// Input +test().test2().test2(thing?.something); + +// Prettier stable +TypeError: Cannot read properties of undefined (reading 'type') + +// Prettier main +test().test2().test2(thing?.something); + +``` diff --git a/changelog_unreleased/json/15831.md b/changelog_unreleased/json/15831.md deleted file mode 100644 index a52ecdbab09e..000000000000 --- a/changelog_unreleased/json/15831.md +++ /dev/null @@ -1,9 +0,0 @@ -#### [Highlight] New `jsonc` parser added (#15831 by @fisker) - -Previously, we infer the parser of `.jsonc` files to be `json`, but if we want keep the trailing comma, we'll have to use a hacky workaround config `{parser: "json5", quoteProps: "preserve", singleQuote: false}`. - -The new added `jsonc` parser: - -- Always quote the object keys. -- Wrap strings with double quotes. -- Of course, respect the [`trailingComma`](https://prettier.io/docs/en/options#trailing-commas) option. diff --git a/changelog_unreleased/misc/15750.md b/changelog_unreleased/misc/15750.md deleted file mode 100644 index ebbf8223c8ae..000000000000 --- a/changelog_unreleased/misc/15750.md +++ /dev/null @@ -1,3 +0,0 @@ -#### Fix false claim in docs that cursorOffset is incompatible with rangeStart/rangeEnd (#15750 by @ExplodingCabbage) - -The cursorOffset option has in fact been compatible with rangeStart/rangeEnd for over 5 years, thanks to work by @ds300. However, Prettier's documentation (including the CLI `--help` text) continued to claim otherwise, falsely. The documentation is now fixed. diff --git a/changelog_unreleased/typescript/15811.md b/changelog_unreleased/typescript/15811.md deleted file mode 100644 index 6019f07b043f..000000000000 --- a/changelog_unreleased/typescript/15811.md +++ /dev/null @@ -1,24 +0,0 @@ -#### Improve conditional type alias layout (#15811 by @seiyab) - - -```ts -// Input -type FallbackFlags = - Equals["flags"], {}> extends true - ? Dict - : NonNullableFlag["flags"]; - -// Prettier stable -type FallbackFlags = Equals< - NonNullableFlag["flags"], - {} -> extends true - ? Dict - : NonNullableFlag["flags"]; - -// Prettier main -type FallbackFlags = - Equals["flags"], {}> extends true - ? Dict - : NonNullableFlag["flags"]; -``` diff --git a/docs/browser.md b/docs/browser.md index bc7589cf9994..49236cf37e8c 100644 --- a/docs/browser.md +++ b/docs/browser.md @@ -18,7 +18,7 @@ Required options: - **[`parser`](options.md#parser) (or [`filepath`](options.md#file-path))**: One of these options has to be specified for Prettier to know which parser to use. -- **`plugins`**: Unlike the `format` function from the [Node.js-based API](api.md#prettierformatsource--options), this function doesn’t load plugins automatically. The `plugins` option is required because all the parsers included in the Prettier package come as plugins (for reasons of file size). These plugins are files in . Note that `estree` plugin should be loaded when printing JavaScript, TypeScript, Flow, or JSON. +- **`plugins`**: Unlike the `format` function from the [Node.js-based API](api.md#prettierformatsource--options), this function doesn’t load plugins automatically. The `plugins` option is required because all the parsers included in the Prettier package come as plugins (for reasons of file size). These plugins are files in . Note that `estree` plugin should be loaded when printing JavaScript, TypeScript, Flow, or JSON. You need to load the ones that you’re going to use and pass them to `prettier.format` using the `plugins` option. @@ -29,8 +29,8 @@ See below for examples. ### Global ```html - - + + - + +