diff --git a/.github/ISSUE_TEMPLATE/formatting.md b/.github/ISSUE_TEMPLATE/formatting.md index b41b177fb..f1da21e6e 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.0.0** +**Prettier 3.0.1** [Playground link](https://prettier.io/playground/#.....) ```sh diff --git a/.github/ISSUE_TEMPLATE/integration.md b/.github/ISSUE_TEMPLATE/integration.md index 017763ba5..4aaef5328 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.0.0 +- Prettier Version: 3.0.1 - Running Prettier via: - Runtime: - Operating System: diff --git a/CHANGELOG.md b/CHANGELOG.md index 59efeeb98..7071e2918 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,184 @@ +# 3.0.1 + +[diff](https://github.com/prettier/prettier/compare/3.0.0...3.0.1) + +#### Fix cursor positioning for a special case ([#14812](https://github.com/prettier/prettier/pull/14812) by [@fisker](https://github.com/fisker)) + + +```js +// <|> is the cursor position + +/* Input */ +// All messages are represented in JSON. +// So, the prettier.py controls a subprocess which spawns "node {this_file}". +import {<|> } from "fs" + +/* Prettier 3.0.0 */ +// All messages are represented in JSON. +// So, the prettier.py <|>controls a subprocess which spawns "node {this_file}". +import {} from "fs" + +/* Prettier 3.0.1 */ +// All messages are represented in JSON. +// So, the prettier.py controls a subprocess which spawns "node {this_file}". +import {<|>} from "fs" +``` + +#### Fix plugins/estree.d.ts to make it a module ([#15018](https://github.com/prettier/prettier/pull/15018) by [@kingyue737](https://github.com/kingyue737)) + +Add `export {}` in `plugins/estree.d.ts` to fix the "File is not a module" error + +#### Add parenthesis around leading multiline comment in return statement ([#15037](https://github.com/prettier/prettier/pull/15037) by [@auvred](https://github.com/auvred)) + + +```jsx +// Input +function fn() { + return ( + /** + * @type {...} + */ expresssion + ) +} + +// Prettier 3.0.0 +function fn() { + return /** + * @type {...} + */ expresssion; +} + +// Prettier 3.0.1 +function fn() { + return ( + /** + * @type {...} + */ expresssion + ); +} +``` + +#### Add support for Vue "Generic Components" ([#15066](https://github.com/prettier/prettier/pull/15066) by [@auvred](https://github.com/auvred)) + +https://blog.vuejs.org/posts/vue-3-3#generic-components + + +```vue + + + + + + + + +``` + +#### Fix comments print in `IfStatement` ([#15076](https://github.com/prettier/prettier/pull/15076) by [@fisker](https://github.com/fisker)) + + +```js +function a(b) { + if (b) return 1; // comment + else return 2; +} + +/* Prettier 3.0.0 */ +Error: Comment "comment" was not printed. Please report this error! + +/* Prettier 3.0.1 */ +function a(b) { + if (b) return 1; // comment + else return 2; +} +``` + +#### Add missing type definition for `printer.preprocess` ([#15123](https://github.com/prettier/prettier/pull/15123) by [@so1ve](https://github.com/so1ve)) + +```diff +export interface Printer { + // ... ++ preprocess?: ++ | ((ast: T, options: ParserOptions) => T | Promise) ++ | undefined; +} +``` + +#### Add missing `getVisitorKeys` method type definition for `Printer` ([#15125](https://github.com/prettier/prettier/pull/15125) by [@auvred](https://github.com/auvred)) + +```tsx +const printer: Printer = { + print: () => [], + getVisitorKeys(node, nonTraversableKeys) { + return ["body"]; + }, +}; +``` + +#### Add typing to support `readonly` array properties of AST Node ([#15127](https://github.com/prettier/prettier/pull/15127) by [@auvred](https://github.com/auvred)) + + +```tsx +// Input +interface TestNode { + readonlyArray: readonly string[]; +} + +declare const path: AstPath; + +path.map(() => "", "readonlyArray"); + +// Prettier 3.0.0 +interface TestNode { + readonlyArray: readonly string[]; +} + +declare const path: AstPath; + +path.map(() => "", "readonlyArray"); +// ^ Argument of type '"readonlyArray"' is not assignable to parameter of type '"regularArray"'. ts(2345) + +// Prettier 3.0.1 +interface TestNode { + readonlyArray: readonly string[]; +} + +declare const path: AstPath; + +path.map(() => "", "readonlyArray"); +``` + +#### Add space before unary minus followed by a function call ([#15129](https://github.com/prettier/prettier/pull/15129) by [@pamelalozano](https://github.com/pamelalozano)) + + +```less +// Input +div { + margin: - func(); +} + +// Prettier 3.0.0 +div { + margin: -func(); +} + +// Prettier 3.0.1 +div { + margin: - func(); +} +``` + # 3.0.0 [diff](https://github.com/prettier/prettier/compare/3.0.0-alpha.6...3.0.0) diff --git a/docs/browser.md b/docs/browser.md index 47519a327..20da0b9ea 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 - - + + - + +