diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index 7bf46148bb93..e211da2bfd44 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.2 +afc0a6b5fae11c86c18bbc345775821607d4d41d # 3.2.1 5811ad00705488365e0d0baf50c92965edddf58e # 3.2.0 diff --git a/.github/ISSUE_TEMPLATE/formatting.md b/.github/ISSUE_TEMPLATE/formatting.md index 0df60bdedde0..e43296162df8 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.2** +**Prettier 3.2.3** [Playground link](https://prettier.io/playground/#.....) ```sh diff --git a/.github/ISSUE_TEMPLATE/integration.md b/.github/ISSUE_TEMPLATE/integration.md index b4a5566d9946..67991a89cf55 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.2 +- Prettier Version: 3.2.3 - Running Prettier via: - Runtime: - Operating System: diff --git a/.prettierrc b/.prettierrc index 20c2d97a0926..bb34518270e9 100644 --- a/.prettierrc +++ b/.prettierrc @@ -5,7 +5,6 @@ overrides: - files: "bin/prettier.cjs" options: trailingComma: none - # TODO: Enable this after `jsonc` parser released - # - files: ".vscode/*.json" - # options: - # parser: jsonc + - files: ".vscode/*.json" + options: + parser: jsonc diff --git a/.vscode/extensions.json b/.vscode/extensions.json index a0ee92829b81..ebce3d3e0697 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -3,6 +3,6 @@ "esbenp.prettier-vscode", "editorconfig.editorconfig", "dbaeumer.vscode-eslint", - "streetsidesoftware.code-spell-checker" - ] + "streetsidesoftware.code-spell-checker", + ], } diff --git a/.vscode/settings.example.json b/.vscode/settings.example.json index a01541d57723..fca393e94753 100644 --- a/.vscode/settings.example.json +++ b/.vscode/settings.example.json @@ -2,14 +2,14 @@ "[javascript]": { "editor.defaultFormatter": "esbenp.prettier-vscode", "editor.formatOnSave": true, - "editor.codeActionsOnSave": ["source.fixAll.eslint"] + "editor.codeActionsOnSave": ["source.fixAll.eslint"], }, "editor.codeActionsOnSave": { - "source.fixAll.eslint": "explicit" + "source.fixAll.eslint": "explicit", }, "prettier.requireConfig": true, "eslint.experimental.useFlatConfig": true, "files.exclude": { - "dist*": true - } + "dist*": true, + }, } diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a65d7de2430..9c3c1f0d64d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,51 @@ +# 3.2.3 + +[diff](https://github.com/prettier/prettier/compare/3.2.2...3.2.3) + +#### Throw errors for invalid code ([#15881](https://github.com/prettier/prettier/pull/15881) by [@fisker](https://github.com/fisker), [@Josh-Cena](https://github.com/Josh-Cena), [@auvred](https://github.com/auvred)) + + +```ts +// Input +1++; + +// Prettier 3.2.2 +1++; + +// Prettier 3.2.3 +SyntaxError: Invalid left-hand side expression in unary operation (1:1) +> 1 | 1++; + | ^ +``` + + +```ts +// Input +try {} catch (error = 1){} + +// Prettier 3.2.2 +try { +} catch (error) {} + +// Prettier 3.2.3 +SyntaxError: Catch clause variable cannot have an initializer. (1:23) +> 1 | try {} catch (error = 1){} + | ^ +``` + +#### Fix parser inference ([#15927](https://github.com/prettier/prettier/pull/15927) by [@fisker](https://github.com/fisker)) + + +```console +// Prettier 3.2.2 +prettier --file-info tsconfig.json +{ "ignored": false, "inferredParser": "json" } + +// Prettier 3.2.3 +prettier --file-info tsconfig.json +{ "ignored": false, "inferredParser": "jsonc" } +``` + # 3.2.2 [diff](https://github.com/prettier/prettier/compare/3.2.1...3.2.2) diff --git a/changelog_unreleased/api/15927.md b/changelog_unreleased/api/15927.md new file mode 100644 index 000000000000..36a468c81a28 --- /dev/null +++ b/changelog_unreleased/api/15927.md @@ -0,0 +1,12 @@ +#### Fix parser inference (#15927 by @fisker) + + +```console +// Prettier stable +prettier --file-info tsconfig.json +{ "ignored": false, "inferredParser": "json" } + +// Prettier main +prettier --file-info tsconfig.json +{ "ignored": false, "inferredParser": "jsonc" } +``` diff --git a/changelog_unreleased/javascript/15896.md b/changelog_unreleased/javascript/15896.md deleted file mode 100644 index 1ae1ed20c121..000000000000 --- a/changelog_unreleased/javascript/15896.md +++ /dev/null @@ -1,8 +0,0 @@ -#### Fix crash when parsing template literal CSS in a JSX style tag using a spread attribute (#15896 by @eelco) - -For example this code would crash before: - - -```jsx - -``` diff --git a/changelog_unreleased/javascript/15920.md b/changelog_unreleased/javascript/15920.md deleted file mode 100644 index b802807c5f1d..000000000000 --- a/changelog_unreleased/javascript/15920.md +++ /dev/null @@ -1,13 +0,0 @@ -#### Fix formatting error on optional call expression and member chain (#15920 by @sosukesuzuki) - - -```jsx -// Input -a(() => {}, c?.d()); - -// Prettier stable -TypeError: Cannot read properties of undefined (reading 'type') - -// Prettier main -a(() => {}, c?.d()); -``` diff --git a/changelog_unreleased/typescript/15881.md b/changelog_unreleased/typescript/15881.md new file mode 100644 index 000000000000..ad68ab7619cf --- /dev/null +++ b/changelog_unreleased/typescript/15881.md @@ -0,0 +1,30 @@ +#### Throw errors for invalid code (#15881 by @fisker, @Josh-Cena, @auvred) + + +```ts +// Input +1++; + +// Prettier stable +1++; + +// Prettier main +SyntaxError: Invalid left-hand side expression in unary operation (1:1) +> 1 | 1++; + | ^ +``` + + +```ts +// Input +try {} catch (error = 1){} + +// Prettier stable +try { +} catch (error) {} + +// Prettier main +SyntaxError: Catch clause variable cannot have an initializer. (1:23) +> 1 | try {} catch (error = 1){} + | ^ +``` diff --git a/cspell.json b/cspell.json index 93da3c59ae59..9b1bcc420f20 100644 --- a/cspell.json +++ b/cspell.json @@ -50,7 +50,6 @@ "cliify", "cmds", "codebases", - "Codecov", "codemirror", "codemod", "codemods", @@ -80,10 +79,8 @@ "Dolzhykov", "Doshi", "dotfile", - "dotfiles", "duailibe", "Duperron", - "eastasianwidth", "Eemeli", "ekkhus", "elektronik", @@ -96,7 +93,6 @@ "eslump", "espree", "esproposal", - "estree", "execa", "Fabio", "fabiospampinato", @@ -107,14 +103,12 @@ "Filipe", "Fiorini", "Fisker", - "fizzbuzz", "flamegraph", "foldgutter", "formatprg", "Friedly", "frobble", "ftest", - "fuzzer", "Georgii", "gettin", "githook", @@ -171,14 +165,11 @@ "Kasturi", "kddnewton", "Kearney", - "keyframes", "keyof", "Khatri", "Konstantin", "l’objectif", - "lcov", "libdef", - "lilconfig", "linebreak", "linebreaks", "lintstaged", @@ -271,7 +262,6 @@ "Rects", "Redeclaration", "refmt", - "regexes", "rhengles", "Rubocop", "ruleset", @@ -303,7 +293,6 @@ "starturl", "stylefmt", "styleguides", - "stylelint", "stylelintrc", "Stylesheet", "subal", @@ -343,7 +332,6 @@ "unparenthesized", "unparseable", "Unrestrict", - "unstaged", "upvoted", "upvotes", "valourous", @@ -361,7 +349,6 @@ "webcompat", "webstorm", "Weixin", - "whitespaces", "withastro", "wxss", "xdescribe", @@ -374,7 +361,7 @@ "ignoreRegExpList": [ "\\n(`{3,})\\w*\\n[\\s\\S]+?\\1", "\\[(\\*{2})?@[-\\w]+?\\1\\]", - "by @[-\\w]+(?:, @[-\\w]+)?", + "by @[-\\w]+(?:, @[-\\w]+)*", "ve{2,}r{2,}y", "ve+r+y+long\\w*", "\\(https?://.*?\\)", diff --git a/docs/api.md b/docs/api.md index 5d49e8e32e86..47be4ec4e803 100644 --- a/docs/api.md +++ b/docs/api.md @@ -35,7 +35,7 @@ await prettier.formatWithCursor(" 1", { cursorOffset: 2, parser: "babel" }); ## `prettier.resolveConfig(fileUrlOrPath [, options])` -`resolveConfig` can be used to resolve configuration for a given source file, passing its path or url as the first argument. The config search will start at the file location and continue to search up the directory (you can use `process.cwd()` to start searching from the current directory). Or you can pass directly the path of the config file as `options.config` if you don’t wish to search for it. A promise is returned which will resolve to: +`resolveConfig` can be used to resolve configuration for a given source file, passing its path or url as the first argument. The config search will start at the directory of the file location and continue to search up the directory. Or you can pass directly the path of the config file as `options.config` if you don’t wish to search for it. A promise is returned which will resolve to: - An options object, providing a [config file](configuration.md) was found. - `null`, if no file was found. diff --git a/docs/browser.md b/docs/browser.md index ff257f9ad080..1a02c9cdb0ce 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 - - + + - + +