From 782f16627b7f6376207282a902eb51ccddeff50f Mon Sep 17 00:00:00 2001 From: Georgii Dolzhykov Date: Mon, 9 Mar 2020 22:36:24 +0200 Subject: [PATCH] edit entries, regenerate the post --- changelog_unreleased/angular/pr-7371.md | 2 +- changelog_unreleased/api/pr-5813.md | 2 + changelog_unreleased/api/pr-6993.md | 4 +- changelog_unreleased/api/pr-7485.md | 4 +- changelog_unreleased/api/pr-7511.md | 12 +- changelog_unreleased/api/pr-7620.md | 4 +- changelog_unreleased/blog-post-intro.md | 7 + changelog_unreleased/cli/pr-7587.md | 2 +- changelog_unreleased/cli/pr-7660.md | 2 +- changelog_unreleased/javascript/pr-6685.md | 2 +- changelog_unreleased/javascript/pr-7011.md | 16 - changelog_unreleased/javascript/pr-7138.md | 2 +- changelog_unreleased/javascript/pr-7367.md | 2 +- changelog_unreleased/javascript/pr-7791.md | 11 +- changelog_unreleased/less/pr-6981.md | 2 +- changelog_unreleased/markdown/pr-7203.md | 2 +- changelog_unreleased/mdx/pr-6949.md | 4 - changelog_unreleased/scss/pr-7211.md | 4 +- changelog_unreleased/typescript/pr-6400.md | 2 +- changelog_unreleased/typescript/pr-7144.md | 3 +- changelog_unreleased/typescript/pr-7631.md | 2 +- changelog_unreleased/vue/pr-7479.md | 31 +- cspell.json | 2 + scripts/draft-blog-post.js | 58 ++-- scripts/lint-changelog.js | 14 +- ...020-00-00-2.0.0.md => 2020-03-21-2.0.0.md} | 324 +++++++++++++----- 26 files changed, 324 insertions(+), 196 deletions(-) create mode 100644 changelog_unreleased/blog-post-intro.md delete mode 100644 changelog_unreleased/javascript/pr-7011.md rename website/blog/{2020-00-00-2.0.0.md => 2020-03-21-2.0.0.md} (82%) diff --git a/changelog_unreleased/angular/pr-7371.md b/changelog_unreleased/angular/pr-7371.md index 76e7385619e7..736b2db2d55d 100644 --- a/changelog_unreleased/angular/pr-7371.md +++ b/changelog_unreleased/angular/pr-7371.md @@ -1,4 +1,4 @@ -#### Fix formatting i18n attributes ([#7371](https://github.com/prettier/prettier/pull/7371) by [@thorn0](https://github.com/thorn0)) +#### Fix formatting of i18n attributes ([#7371](https://github.com/prettier/prettier/pull/7371) by [@thorn0](https://github.com/thorn0)) Prettier 1.19 [added](https://prettier.io/blog/2019/11/09/1.19.0.html#add-formatting-for-i18n-attributes-6695-by-voithos) support for formatting [i18n attributes](https://angular.io/guide/i18n), but putting the closing quote mark on a new line diff --git a/changelog_unreleased/api/pr-5813.md b/changelog_unreleased/api/pr-5813.md index bc9daf48ab21..bb844b69134b 100644 --- a/changelog_unreleased/api/pr-5813.md +++ b/changelog_unreleased/api/pr-5813.md @@ -1 +1,3 @@ #### [BREAKING] Fix config overrides pattern matching to include dot files ([#5813](https://github.com/prettier/prettier/pull/5813) by [@chrisblossom](https://github.com/chrisblossom)) + +Previously, [configuration overrides](/docs/en/configuration.html#configuration-overrides) weren't applied to files whose name had a leading dot. diff --git a/changelog_unreleased/api/pr-6993.md b/changelog_unreleased/api/pr-6993.md index 3221bfcdd86d..60a6798bf785 100644 --- a/changelog_unreleased/api/pr-6993.md +++ b/changelog_unreleased/api/pr-6993.md @@ -1,10 +1,10 @@ -#### [BREAKING] Remove deprecated API ([#6993](https://github.com/prettier/prettier/pull/6993) by [@fisker](https://github.com/fisker)) +#### [BREAKING] Remove deprecated API and change util signatures ([#6993](https://github.com/prettier/prettier/pull/6993) by [@fisker](https://github.com/fisker)) - Parser `typescript-eslint` is removed. Use the `typescript` parser instead. - `prettier.util.mapDoc` is removed. Use `prettier.doc.utils.mapDoc` instead. - `prettier.util.isNextLineEmpty` is updated.
Use `isNextLineEmpty(text, node, locEnd)` instead of `isNextLineEmpty(text, node, options)`. - `prettier.util.isPreviousLineEmpty` is updated.
- Use `isPreviousLineEmpty(text, node, locStart)` instead of `isNextLineEmpty(text, node, options)`. + Use `isPreviousLineEmpty(text, node, locStart)` instead of `isPreviousLineEmpty(text, node, options)`. - `prettier.util.getNextNonSpaceNonCommentCharacterIndex` is updated.
Use `getNextNonSpaceNonCommentCharacterIndex(text, node, locEnd)` instead of `getNextNonSpaceNonCommentCharacterIndex(text, node, options)`. diff --git a/changelog_unreleased/api/pr-7485.md b/changelog_unreleased/api/pr-7485.md index 0ff37b647073..6abc9b8706bb 100644 --- a/changelog_unreleased/api/pr-7485.md +++ b/changelog_unreleased/api/pr-7485.md @@ -1,3 +1,3 @@ -#### Cache plugins search result ([#7485](https://github.com/prettier/prettier/pull/7485) by [@fisker](https://github.com/fisker)) +#### [BREAKING] Cache plugin search results ([#7485](https://github.com/prettier/prettier/pull/7485) by [@fisker](https://github.com/fisker)) -Previously, we search plugins on every `format` call, the plugins search result is cached since v2.0.0, cache can be clear by calling `prettier.clearConfigCache()`. +Previously, Prettier searched the file system for plugins on every `prettier.format` call. Now, search results are cached. The cache can be cleared by calling `prettier.clearConfigCache()`. diff --git a/changelog_unreleased/api/pr-7511.md b/changelog_unreleased/api/pr-7511.md index 05cc658b82de..ab59b6806b67 100644 --- a/changelog_unreleased/api/pr-7511.md +++ b/changelog_unreleased/api/pr-7511.md @@ -1,8 +1,8 @@ -#### Remove deprecated options and option values ([#7511](https://github.com/prettier/prettier/pull/7511), [#7533](https://github.com/prettier/prettier/pull/7533), [#7535](https://github.com/prettier/prettier/pull/7535), [#7536](https://github.com/prettier/prettier/pull/7536) by [@fisker](https://github.com/fisker)) +#### [BREAKING] Remove deprecated options and option values ([#7511](https://github.com/prettier/prettier/pull/7511), [#7533](https://github.com/prettier/prettier/pull/7533), [#7535](https://github.com/prettier/prettier/pull/7535), [#7536](https://github.com/prettier/prettier/pull/7536) by [@fisker](https://github.com/fisker)) - Options: - - `useFlowParser` (`--flow-parser` in CLI) [has been deprecated since `v0.0.10`](https://github.com/prettier/prettier/blob/master/CHANGELOG.md#0010). -- Renamed option values whose old names were kept for backward compatibility: - - `parser`: `babylon` (renamed to `babel` in _v1.16.0_), `postcss` (renamed to `css` in _v1.7.1_) - - `trailingComma`: `true` (renamed to `always` in _v1.9.0_), `false` (renamed to `never` in _v1.9.0_) - - `proseWrap`: `true` (renamed to `es5` in _v0.19.0_), `false` (renamed to `none` in _v0.19.0_) + - `useFlowParser` (`--flow-parser` in CLI) has been deprecated [since `v0.0.10`](https://github.com/prettier/prettier/blob/master/CHANGELOG.md#0010). +- Option values: + - `parser`: `babylon` (renamed to `babel` in v1.16.0), `postcss` (renamed to `css` in v1.7.1) + - `proseWrap`: `true` (renamed to `always` in v1.9.0), `false` (renamed to `never` in v1.9.0) + - `trailingComma`: `true` (renamed to `es5` in v0.19.0), `false` (renamed to `none` in v0.19.0) diff --git a/changelog_unreleased/api/pr-7620.md b/changelog_unreleased/api/pr-7620.md index a9db65b2dc55..f3f1a67785e7 100644 --- a/changelog_unreleased/api/pr-7620.md +++ b/changelog_unreleased/api/pr-7620.md @@ -1,3 +1,3 @@ -#### [BREAKING] Remove the `version` parameter of `prettier.getSupportInfo()` ([#7620](https://github.com/prettier/prettier/pull/7620) by [@thorn0](https://github.com/thorn0)) +#### [BREAKING] Remove the `version` parameter of `prettier.getSupportInfo` ([#7620](https://github.com/prettier/prettier/pull/7620) by [@thorn0](https://github.com/thorn0)) -In Prettier 1.x (since 1.8.0), it was possible to pass a version number to `prettier.getSupportInfo()` to get information on the languages, options, etc. supported by previous versions. This interesting but apparently not very useful API kept causing maintenance problems and has been removed in Prettier 2.0.0. +Since Prettier 1.8.0, it was possible to pass a version number to `prettier.getSupportInfo` to get information on the languages, options, etc. supported by previous versions. This interesting but apparently not very useful API kept causing maintenance problems and has been removed in Prettier 2.0.0. diff --git a/changelog_unreleased/blog-post-intro.md b/changelog_unreleased/blog-post-intro.md new file mode 100644 index 000000000000..f349dba5bcd2 --- /dev/null +++ b/changelog_unreleased/blog-post-intro.md @@ -0,0 +1,7 @@ +--- +author: "Georgii Dolzhykov (@thorn0)" +authorURL: "https://github.com/thorn0" +title: "Prettier 2.0 “2020”" +--- + +Better defaults, a better CLI and better heuristics. Oh, and TypeScript 3.8. diff --git a/changelog_unreleased/cli/pr-7587.md b/changelog_unreleased/cli/pr-7587.md index 001af15c5e43..0a4ca4325471 100644 --- a/changelog_unreleased/cli/pr-7587.md +++ b/changelog_unreleased/cli/pr-7587.md @@ -1,3 +1,3 @@ -#### Test whether passed globs are names of existing files before treating them as globs ([#7587](https://github.com/prettier/prettier/pull/7587) by [@fisker](https://github.com/fisker)) +#### [HIGHLIGHT] Test whether passed globs are names of existing files before treating them as globs ([#7587](https://github.com/prettier/prettier/pull/7587) by [@fisker](https://github.com/fisker)) Since file names in Linux can contain almost any characters, strings like `foo*.js` and `[bar].css` are valid file names. Previously, if the user needed to format a file named `[bar].css`, a glob escaping syntax had to be used: `prettier "\[bar].css"` (this one doesn't work on Windows, where backslashes are treated as path separators) or `prettier "[[]bar].css"`. Because of this, important use cases were broken. E.g. [lint-staged](https://github.com/okonet/lint-staged) passes absolute paths and knows nothing about the escaping syntax. Now, when Prettier CLI gets a glob, it first tries to resolve it as a literal file name. diff --git a/changelog_unreleased/cli/pr-7660.md b/changelog_unreleased/cli/pr-7660.md index 123bd1240e57..3007f89bf62a 100644 --- a/changelog_unreleased/cli/pr-7660.md +++ b/changelog_unreleased/cli/pr-7660.md @@ -1,4 +1,4 @@ -#### Expand directories, including `.` ([#7660](https://github.com/prettier/prettier/pull/7660) by [@thorn0](https://github.com/thorn0)) +#### [HIGHLIGHT] Expand directories, including `.` ([#7660](https://github.com/prettier/prettier/pull/7660) by [@thorn0](https://github.com/thorn0)) It's finally possible to run `prettier --write .` to format all supported files in the current directory and its subdirectories. Directory names can be mixed with file names and glob patterns (e.g. `prettier src "test/*.spec.js" foo.js`). diff --git a/changelog_unreleased/javascript/pr-6685.md b/changelog_unreleased/javascript/pr-6685.md index 295fd2ca4ae8..6a002873dec3 100644 --- a/changelog_unreleased/javascript/pr-6685.md +++ b/changelog_unreleased/javascript/pr-6685.md @@ -1,4 +1,4 @@ -#### Improved method chain breaking heuristic ([#6685](https://github.com/prettier/prettier/pull/6685) by [@mmkal](https://github.com/mmkal)) +#### [HIGHLIGHT] Improved method chain breaking heuristic ([#6685](https://github.com/prettier/prettier/pull/6685) by [@mmkal](https://github.com/mmkal)) Previously, any method call chain of length three or longer would be automatically broken into multiple lines. The new heuristic is based on the complexity of the call arguments in the chain, rather than simply on the chain's length. Now, if chained method calls have arguments which aren't easy to understand at a glance (e.g. functions or deeply-nested objects), the chain is broken. Otherwise, they're allowed to remain on one line. See prior issues [#3197](https://github.com/prettier/prettier/issues/3107), [#4765](https://github.com/prettier/prettier/pull/4765), [#1565](https://github.com/prettier/prettier/issues/1565) and [#4125](https://github.com/prettier/prettier/pull/4125) for context and examples. diff --git a/changelog_unreleased/javascript/pr-7011.md b/changelog_unreleased/javascript/pr-7011.md deleted file mode 100644 index 642c75a7034b..000000000000 --- a/changelog_unreleased/javascript/pr-7011.md +++ /dev/null @@ -1,16 +0,0 @@ -#### Preserve parentheses for JSDoc type casting with extra trailing spaces and asterisks ([#7011](https://github.com/prettier/prettier/pull/7011) by [@evilebottnawi](https://github.com/evilebottnawi)) - - -```javascript -// Input -const foo = /** @type {!Foo} **/ (baz); -const bar = /** @type {!Foo} * * */(baz); - -// Prettier stable -const foo = /** @type {!Foo} **/ baz; -const bar = /** @type {!Foo} * * */ baz; - -// Prettier master -const foo = /** @type {!Foo} **/ (baz); -const bar = /** @type {!Foo} * * */ (baz); -``` diff --git a/changelog_unreleased/javascript/pr-7138.md b/changelog_unreleased/javascript/pr-7138.md index 7fe07e540a2f..596d3ef593f3 100644 --- a/changelog_unreleased/javascript/pr-7138.md +++ b/changelog_unreleased/javascript/pr-7138.md @@ -3,7 +3,7 @@ Because decorators modify the line following, splitting a decorator call’s arguments onto multiple lines can obscure the relationship between the decorator and its intended target, producing less-readable code. Therefore, the -function composition logic introduced in #6033 has been changed to exclude +function composition logic introduced in [#6033](https://github.com/prettier/prettier/pull/6033) has been changed to exclude decorator calls. diff --git a/changelog_unreleased/javascript/pr-7367.md b/changelog_unreleased/javascript/pr-7367.md index 8e4d9de10fa8..58eaa4e94faf 100644 --- a/changelog_unreleased/javascript/pr-7367.md +++ b/changelog_unreleased/javascript/pr-7367.md @@ -1,4 +1,4 @@ -#### Fix: remove unnecessary parens when yielding JSX ([#7367](https://github.com/prettier/prettier/pull/7367) by [@cola119](https://github.com/cola119)) +#### Remove unnecessary parens when yielding JSX ([#7367](https://github.com/prettier/prettier/pull/7367) by [@cola119](https://github.com/cola119)) ```jsx diff --git a/changelog_unreleased/javascript/pr-7791.md b/changelog_unreleased/javascript/pr-7791.md index 11755d52185d..37779583051a 100644 --- a/changelog_unreleased/javascript/pr-7791.md +++ b/changelog_unreleased/javascript/pr-7791.md @@ -1,6 +1,8 @@ -#### Ultimate fix for Closure-style type casts ([#7791](https://github.com/prettier/prettier/pull/7791) by [@thorn0](https://github.com/thorn0)) +#### [HIGHLIGHT] Ultimate fix for Closure-style type casts ([#7791](https://github.com/prettier/prettier/pull/7791) by [@thorn0](https://github.com/thorn0), [#7011](https://github.com/prettier/prettier/pull/7011) by [@evilebottnawi](https://github.com/evilebottnawi)) -Prettier has been trying not to corrupt these JSDoc type assertions since [v1.6.0](https://prettier.io/blog/2017/08/29/1.6.0.html#handle-closure-compiler-type-cast-syntax-correctly-2484httpsgithubcomprettierprettierpull2484-by-yangsuhttpsgithubcomyangsu), with mixed results. As type checking based on JSDoc becomes increasingly common, we've been getting new bug reports about this syntax. The bugs were tricky because the required parentheses around the expression weren't part of the AST, so Prettier didn't have a good way to detect their presence. Finally, we used the `createParenthesizedExpressions` option of the Babel parser to represent parentheses in the AST using non-standard nodes. This helped fix all the reported bugs. +Prettier has been trying not to corrupt these JSDoc type assertions since [v1.6.0](https://prettier.io/blog/2017/08/29/1.6.0.html#handle-closure-compiler-type-cast-syntax-correctly-2484httpsgithubcomprettierprettierpull2484-by-yangsuhttpsgithubcomyangsu), with mixed results. As type checking based on JSDoc becomes increasingly common, we've been getting new bug reports about this syntax. The bugs were tricky because the required parentheses around the expression weren't part of the AST, so Prettier didn't have a good way to detect their presence. + +Finally, we used the `createParenthesizedExpressions` option of the Babel parser to represent parentheses in the AST using non-standard nodes. This helped fix all the reported bugs. Consequently, Prettier won't recognize JSDoc type casts if the `flow` or `typescript` parser is used, but this is reasonable as this syntax makes little sense in Flow and TypeScript files. @@ -18,7 +20,4 @@ const nestedAssertions /** @type {MyType} */ /** @type {unknown} */ = x; const nestedAssertions = /** @type {MyType} */ (/** @type {unknown} */ (x)); ``` -Reference documentation for this syntax: - -- [Closure Compiler](https://github.com/google/closure-compiler/wiki/Annotating-JavaScript-for-the-Closure-Compiler#type-type) -- [TypeScript (with `--checkJs`)](https://www.typescriptlang.org/docs/handbook/type-checking-javascript-files.html#casts) +Reference documentation for this syntax: [Closure Compiler](https://github.com/google/closure-compiler/wiki/Annotating-JavaScript-for-the-Closure-Compiler#type-type), [TypeScript (with `--checkJs`)](https://www.typescriptlang.org/docs/handbook/type-checking-javascript-files.html#casts). diff --git a/changelog_unreleased/less/pr-6981.md b/changelog_unreleased/less/pr-6981.md index b8dbacd6cfeb..40d0c3d83fea 100644 --- a/changelog_unreleased/less/pr-6981.md +++ b/changelog_unreleased/less/pr-6981.md @@ -1,6 +1,6 @@ #### Fix multiple long-standing issues by updating `postcss-less` ([#6981](https://github.com/prettier/prettier/pull/6981) by [@fisker](https://github.com/fisker), [#7021](https://github.com/prettier/prettier/pull/7021) by [@evilebottnawi](https://github.com/evilebottnawi), [@thorn0](https://github.com/thorn0)) -- [`each`](http://lesscss.org/functions/#list-functions-each) is supported now ([#5653](https://github.com/prettier/prettier/issues/5653). +- [`each`](http://lesscss.org/functions/#list-functions-each) is supported now ([#5653](https://github.com/prettier/prettier/issues/5653)). - `!important` was being moved out of mixin call parameters ([#3544](https://github.com/prettier/prettier/issues/3544)). - Comments in rulesets passed to mixin calls caused duplicate semicolons ([#3096](https://github.com/prettier/prettier/issues/3096)). - `::before` was broken in mixin call parameters ([#5791](https://github.com/prettier/prettier/issues/5791)). diff --git a/changelog_unreleased/markdown/pr-7203.md b/changelog_unreleased/markdown/pr-7203.md index cd572553dcbe..41c36d0bb44a 100644 --- a/changelog_unreleased/markdown/pr-7203.md +++ b/changelog_unreleased/markdown/pr-7203.md @@ -1,4 +1,4 @@ -#### Fix incorrect prettification of multi-line markdown footnote ([#7203](https://github.com/prettier/prettier/pull/7203) by [@sasurau4](https://github.com/sasurau4)) +#### Fix formatting of multi-line footnote ([#7203](https://github.com/prettier/prettier/pull/7203) by [@sasurau4](https://github.com/sasurau4)) ```md diff --git a/changelog_unreleased/mdx/pr-6949.md b/changelog_unreleased/mdx/pr-6949.md index 2561c0d34936..c122da7027f7 100644 --- a/changelog_unreleased/mdx/pr-6949.md +++ b/changelog_unreleased/mdx/pr-6949.md @@ -21,10 +21,6 @@ parsable as HTML, such as `test` SyntaxError: Unexpected closing tag "Tag". It may happen when the tag has already been closed by another tag. For more info see https://www.w3.org/TR/html5/syntax.html#closing-elements-that-have-implied-end-tags (1:35) > 1 | test - | ^ - 2 | - 3 | - 4 |
diff --git a/changelog_unreleased/scss/pr-7211.md b/changelog_unreleased/scss/pr-7211.md index dc283cbf5363..6331e7c088a1 100644 --- a/changelog_unreleased/scss/pr-7211.md +++ b/changelog_unreleased/scss/pr-7211.md @@ -1,6 +1,4 @@ -#### Fix scss variable string concatenation removing spaces ([#7211](https://github.com/prettier/prettier/pull/7211) by [@sasurau4](https://github.com/sasurau4)) - -Previously, when Prettier format the scss variable string concatenation, it would remove spaces. Now, Prettier insert spaces around plus operator. +#### Fix whitespace in SCSS concatenation ([#7211](https://github.com/prettier/prettier/pull/7211) by [@sasurau4](https://github.com/sasurau4)) ```scss diff --git a/changelog_unreleased/typescript/pr-6400.md b/changelog_unreleased/typescript/pr-6400.md index 4863893c0e01..407af44e1371 100644 --- a/changelog_unreleased/typescript/pr-6400.md +++ b/changelog_unreleased/typescript/pr-6400.md @@ -1,3 +1,3 @@ #### Babel as an alternative parser for TypeScript ([#6400](https://github.com/prettier/prettier/pull/6400) by [@JounQin](https://github.com/JounQin) & [@thorn0](https://github.com/thorn0)) -A new value for the `parser` option has been added: `babel-ts`, which makes use of Babel’s TypeScript plugin. The `babel-ts` parser supports JavaScript features not yet supported by TypeScript (ECMAScript proposals, e.g. [private methods and accessors](https://github.com/tc39/proposal-private-methods)), but it's less permissive when it comes to error recovery and less battle-tested than the `typescript` parser. While Babel’s TypeScript plugin is quite mature, ASTs produced by the two parsers aren't 100% compatible. We tried to take the discrepancies into account, but there are most likely still cases where code gets formatted differently or even incorrectly. We call upon the you, our users, to help us find such cases. If you see them, please raise issues. In the long run, this will help with [unifying the AST format](https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/typescript-estree#ast-alignment-tests) in future versions of the parsers and thus contribute to a better, more solid JavaScript parser ecosystem. +A new value for the `parser` option has been added: `babel-ts`, which makes use of Babel’s TypeScript plugin. The `babel-ts` parser supports JavaScript features not yet supported by TypeScript (ECMAScript proposals, e.g. [private methods and accessors](https://github.com/tc39/proposal-private-methods)), but it's less permissive when it comes to error recovery and less battle-tested than the `typescript` parser. While Babel’s TypeScript plugin is quite mature, ASTs produced by the two parsers aren't 100% compatible. We tried to take the discrepancies into account, but there are most likely still cases where code gets formatted differently or even incorrectly. We call upon you, our users, to help us find such cases. If you see them, please raise issues. In the long run, this will help with [unifying the AST format](https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/typescript-estree#ast-alignment-tests) in future versions of the parsers and thus contribute to a better, more solid JavaScript parser ecosystem. diff --git a/changelog_unreleased/typescript/pr-7144.md b/changelog_unreleased/typescript/pr-7144.md index 5b83c3b05421..5782581c0c87 100644 --- a/changelog_unreleased/typescript/pr-7144.md +++ b/changelog_unreleased/typescript/pr-7144.md @@ -1,4 +1,4 @@ -#### Fix formatting comments for function-like nodes ([#7144](https://github.com/prettier/prettier/pull/7144) by [@armano2](https://github.com/armano2)) +#### Fix formatting of comments for function-like nodes ([#7144](https://github.com/prettier/prettier/pull/7144) by [@armano2](https://github.com/armano2)) ```ts @@ -54,6 +54,7 @@ let foo9: new (/* bar */) => /* foo */ /* baz */ string; let foo10: new (/* foo */ a: /* bar */ string) => /* baz */ string; ``` + ```ts // Input abstract class Test { diff --git a/changelog_unreleased/typescript/pr-7631.md b/changelog_unreleased/typescript/pr-7631.md index d3db02f9403f..a9f544625569 100644 --- a/changelog_unreleased/typescript/pr-7631.md +++ b/changelog_unreleased/typescript/pr-7631.md @@ -1,4 +1,4 @@ -#### TypeScript 3.8 ([#7631](https://github.com/prettier/prettier/pull/7631) by [@thorn0](https://github.com/thorn0), [#7764](https://github.com/prettier/prettier/pull/7764) by [@sosukesuzuki](https://github.com/sosukesuzuki), [#7804](https://github.com/prettier/prettier/pull/7804) by [@sosukesuzuki](https://github.com/sosukesuzuki)) +#### [HIGHLIGHT] TypeScript 3.8 ([#7631](https://github.com/prettier/prettier/pull/7631) by [@thorn0](https://github.com/thorn0), [#7764](https://github.com/prettier/prettier/pull/7764) by [@sosukesuzuki](https://github.com/sosukesuzuki), [#7804](https://github.com/prettier/prettier/pull/7804) by [@sosukesuzuki](https://github.com/sosukesuzuki)) Prettier now supports the new syntax added in TypeScript 3.8: diff --git a/changelog_unreleased/vue/pr-7479.md b/changelog_unreleased/vue/pr-7479.md index 8b566d72aeb0..709f659a2ea4 100644 --- a/changelog_unreleased/vue/pr-7479.md +++ b/changelog_unreleased/vue/pr-7479.md @@ -1,29 +1,22 @@ -#### Don't print single `TemplateLiteral` and `StringLiteral` expression on new line ([#7479](https://github.com/prettier/prettier/pull/7479) by [@fisker](https://github.com/fisker)) - -Previously, we print long `TemplateLiteral` and `StringLiteral` on new line in attribute, now we print them on the same line with attribute name. +#### Don't print sole string literals in attributes on a new line ([#7479](https://github.com/prettier/prettier/pull/7479) by [@fisker](https://github.com/fisker)) ```vue - - @@ -31,12 +24,8 @@ Previously, we print long `TemplateLiteral` and `StringLiteral` on new line in a - ``` diff --git a/cspell.json b/cspell.json index 9c7199325ceb..17b88e5135b7 100644 --- a/cspell.json +++ b/cspell.json @@ -84,6 +84,7 @@ "docblock", "docblocks", "Dodds", + "Dolzhykov", "dotfile", "dotfiles", "duailibe", @@ -117,6 +118,7 @@ "Friedly", "fuzzer", "gavinjoyce", + "Georgii", "gettin", "git's", "gitattributes", diff --git a/scripts/draft-blog-post.js b/scripts/draft-blog-post.js index 2be0e30ea47d..edcd055004dc 100644 --- a/scripts/draft-blog-post.js +++ b/scripts/draft-blog-post.js @@ -4,12 +4,17 @@ const fs = require("fs"); const path = require("path"); +const rimraf = require("rimraf"); const changelogUnreleasedDir = path.join(__dirname, "../changelog_unreleased"); const blogDir = path.join(__dirname, "../website/blog"); - +const introFile = path.join(changelogUnreleasedDir, "blog-post-intro.md"); const version = require("../package.json").version.replace(/-.+/, ""); -const versionShort = version.replace(/\.0$/, ""); +const postGlob = path.join(blogDir, `????-??-??-${version}.md`); +const postFile = path.join( + blogDir, + `${new Date().toISOString().replace(/T.+/, "")}-${version}.md` +); const categories = [ { dir: "javascript", title: "JavaScript" }, @@ -23,7 +28,7 @@ const categories = [ { dir: "vue", title: "Vue" }, { dir: "angular", title: "Angular" }, { dir: "lwc", title: "LWC" }, - { dir: "handlebars", title: "Handlebars" }, + { dir: "handlebars", title: "Handlebars (alpha)" }, { dir: "graphql", title: "GraphQL" }, { dir: "markdown", title: "Markdown" }, { dir: "mdx", title: "MDX" }, @@ -71,27 +76,27 @@ for (const dir of dirs) { }); } -const result = [ - `--- -author: "🚧" -authorURL: "https://github.com/🚧" -title: "Prettier ${versionShort}: 🚧" ----`, - "🚧 Write an introduction here.", - "", - ...printEntries({ - title: "Highlights", - filter: entry => entry.highlight - }), - ...printEntries({ - title: "Breaking changes", - filter: entry => entry.breaking && !entry.highlight - }), - ...printEntries({ - title: "Other changes", - filter: entry => !entry.breaking && !entry.highlight - }) -]; +rimraf.sync(postGlob); + +fs.writeFileSync( + postFile, + [ + fs.readFileSync(introFile, "utf8").trim(), + "", + ...printEntries({ + title: "Highlights", + filter: entry => entry.highlight + }), + ...printEntries({ + title: "Breaking changes", + filter: entry => entry.breaking && !entry.highlight + }), + ...printEntries({ + title: "Other changes", + filter: entry => !entry.breaking && !entry.highlight + }) + ].join("\n\n") + "\n" +); function printEntries({ title, filter }) { const result = []; @@ -110,8 +115,3 @@ function printEntries({ title, filter }) { return result; } - -fs.writeFileSync( - path.join(blogDir, `${new Date().getFullYear()}-00-00-${version}.md`), - result.join("\n\n") + "\n" -); diff --git a/scripts/lint-changelog.js b/scripts/lint-changelog.js index 54cd2600f3f6..879d5119bc88 100644 --- a/scripts/lint-changelog.js +++ b/scripts/lint-changelog.js @@ -1,9 +1,11 @@ +#!/usr/bin/env node "use strict"; const fs = require("fs"); const path = require("path"); const CHANGELOG_DIR = "changelog_unreleased"; const TEMPLATE_FILE = "TEMPLATE.md"; +const BLOG_POST_INTRO_FILE = "blog-post-intro.md"; const CHANGELOG_CATEGORIES = [ "angular", "api", @@ -32,11 +34,19 @@ const showErrorMessage = message => { const files = fs.readdirSync(CHANGELOG_ROOT); for (const file of files) { - if (file !== TEMPLATE_FILE && !CHANGELOG_CATEGORIES.includes(file)) { + if ( + file !== TEMPLATE_FILE && + file !== BLOG_POST_INTRO_FILE && + !CHANGELOG_CATEGORIES.includes(file) + ) { showErrorMessage(`Please remove "${file}" from "${CHANGELOG_DIR}".`); } } -for (const file of [TEMPLATE_FILE, ...CHANGELOG_CATEGORIES]) { +for (const file of [ + TEMPLATE_FILE, + BLOG_POST_INTRO_FILE, + ...CHANGELOG_CATEGORIES +]) { if (!files.includes(file)) { showErrorMessage(`Please don't remove "${file}" from "${CHANGELOG_DIR}".`); } diff --git a/website/blog/2020-00-00-2.0.0.md b/website/blog/2020-03-21-2.0.0.md similarity index 82% rename from website/blog/2020-00-00-2.0.0.md rename to website/blog/2020-03-21-2.0.0.md index 64fdec2e8dd2..0d83b3f83ffe 100644 --- a/website/blog/2020-00-00-2.0.0.md +++ b/website/blog/2020-03-21-2.0.0.md @@ -1,19 +1,100 @@ --- -author: "🚧" -authorURL: "https://github.com/🚧" -title: "Prettier 2.0: 🚧" +author: "Georgii Dolzhykov (@thorn0)" +authorURL: "https://github.com/thorn0" +title: "Prettier 2.0 “2020”" --- -🚧 Write an introduction here. +Better defaults, a better CLI and better heuristics. Oh, and TypeScript 3.8. +## Highlights + +### JavaScript + +#### Improved method chain breaking heuristic ([#6685](https://github.com/prettier/prettier/pull/6685) by [@mmkal](https://github.com/mmkal)) + +Previously, any method call chain of length three or longer would be automatically broken into multiple lines. The new heuristic is based on the complexity of the call arguments in the chain, rather than simply on the chain's length. Now, if chained method calls have arguments which aren't easy to understand at a glance (e.g. functions or deeply-nested objects), the chain is broken. Otherwise, they're allowed to remain on one line. See prior issues [#3197](https://github.com/prettier/prettier/issues/3107), [#4765](https://github.com/prettier/prettier/pull/4765), [#1565](https://github.com/prettier/prettier/issues/1565) and [#4125](https://github.com/prettier/prettier/pull/4125) for context and examples. + + +```javascript +// Output (Prettier stable) +if ( + foo + .one() + .two() + .three() === + bar + .four() + .five() + .six() +) { + // ... +} + +// Output (Prettier master) +if (foo.one().two().three() === bar.four().five().six()) { + // ... +} +``` + +#### Ultimate fix for Closure-style type casts ([#7791](https://github.com/prettier/prettier/pull/7791) by [@thorn0](https://github.com/thorn0), [#7011](https://github.com/prettier/prettier/pull/7011) by [@evilebottnawi](https://github.com/evilebottnawi)) + +Prettier has been trying not to corrupt these JSDoc type assertions since [v1.6.0](https://prettier.io/blog/2017/08/29/1.6.0.html#handle-closure-compiler-type-cast-syntax-correctly-2484httpsgithubcomprettierprettierpull2484-by-yangsuhttpsgithubcomyangsu), with mixed results. As type checking based on JSDoc becomes increasingly common, we've been getting new bug reports about this syntax. The bugs were tricky because the required parentheses around the expression weren't part of the AST, so Prettier didn't have a good way to detect their presence. + +Finally, we used the `createParenthesizedExpressions` option of the Babel parser to represent parentheses in the AST using non-standard nodes. This helped fix all the reported bugs. + +Consequently, Prettier won't recognize JSDoc type casts if the `flow` or `typescript` parser is used, but this is reasonable as this syntax makes little sense in Flow and TypeScript files. + + +```jsx +// Input +const nestedAssertions = /** @type {MyType} */ + (/** @type {unknown} */ + (x)); + +// Prettier stable +const nestedAssertions /** @type {MyType} */ /** @type {unknown} */ = x; + +// Prettier master +const nestedAssertions = /** @type {MyType} */ (/** @type {unknown} */ (x)); +``` + +Reference documentation for this syntax: [Closure Compiler](https://github.com/google/closure-compiler/wiki/Annotating-JavaScript-for-the-Closure-Compiler#type-type), [TypeScript (with `--checkJs`)](https://www.typescriptlang.org/docs/handbook/type-checking-javascript-files.html#casts). + +### TypeScript + +#### TypeScript 3.8 ([#7631](https://github.com/prettier/prettier/pull/7631) by [@thorn0](https://github.com/thorn0), [#7764](https://github.com/prettier/prettier/pull/7764) by [@sosukesuzuki](https://github.com/sosukesuzuki), [#7804](https://github.com/prettier/prettier/pull/7804) by [@sosukesuzuki](https://github.com/sosukesuzuki)) + +Prettier now supports the new syntax added in TypeScript 3.8: + +- [Type-Only Imports and Exports](https://devblogs.microsoft.com/typescript/announcing-typescript-3-8/#type-only-imports-exports) +- [ECMAScript Private Fields](https://devblogs.microsoft.com/typescript/announcing-typescript-3-8/#ecmascript-private-fields) +- [`export * as ns`](https://devblogs.microsoft.com/typescript/announcing-typescript-3-8/#export-star-as-namespace-syntax) + +### CLI + +#### Test whether passed globs are names of existing files before treating them as globs ([#7587](https://github.com/prettier/prettier/pull/7587) by [@fisker](https://github.com/fisker)) + +Since file names in Linux can contain almost any characters, strings like `foo*.js` and `[bar].css` are valid file names. Previously, if the user needed to format a file named `[bar].css`, a glob escaping syntax had to be used: `prettier "\[bar].css"` (this one doesn't work on Windows, where backslashes are treated as path separators) or `prettier "[[]bar].css"`. Because of this, important use cases were broken. E.g. [lint-staged](https://github.com/okonet/lint-staged) passes absolute paths and knows nothing about the escaping syntax. Now, when Prettier CLI gets a glob, it first tries to resolve it as a literal file name. + +#### Expand directories, including `.` ([#7660](https://github.com/prettier/prettier/pull/7660) by [@thorn0](https://github.com/thorn0)) + +It's finally possible to run `prettier --write .` to format all supported files in the current directory and its subdirectories. +Directory names can be mixed with file names and glob patterns (e.g. `prettier src "test/*.spec.js" foo.js`). + +Also, the order in which files are processed has changed. Previously, all the files were sorted alphabetically before +formatting. Now, their order corresponds to the order of the specified paths. For each path, the list of resolved +files is sorted, but the full sorting of the resulting combined list isn't done anymore. + ## Breaking changes ### API #### Fix config overrides pattern matching to include dot files ([#5813](https://github.com/prettier/prettier/pull/5813) by [@chrisblossom](https://github.com/chrisblossom)) +Previously, [configuration overrides](/docs/en/configuration.html#configuration-overrides) weren't applied to files whose name had a leading dot. + #### Drop support for Node versions older than 10 ([#6908](https://github.com/prettier/prettier/pull/6908) by [@fisker](https://github.com/fisker)) The minimal required Node version now is 10.13.0. @@ -29,14 +110,14 @@ Finally, the default value becomes `es5` instead of `none` in Prettier v2.0. If the old behavior is still preferred, please configure Prettier with `{ "trailingComma": "none" }`. There is a possibility that the default value will change to `always` (meaning even more trailing commas) in a future major version of Prettier as the JavaScript ecosystem further matures. -#### Remove deprecated API ([#6993](https://github.com/prettier/prettier/pull/6993) by [@fisker](https://github.com/fisker)) +#### Remove deprecated API and change util signatures ([#6993](https://github.com/prettier/prettier/pull/6993) by [@fisker](https://github.com/fisker)) - Parser `typescript-eslint` is removed. Use the `typescript` parser instead. - `prettier.util.mapDoc` is removed. Use `prettier.doc.utils.mapDoc` instead. - `prettier.util.isNextLineEmpty` is updated.
Use `isNextLineEmpty(text, node, locEnd)` instead of `isNextLineEmpty(text, node, options)`. - `prettier.util.isPreviousLineEmpty` is updated.
- Use `isPreviousLineEmpty(text, node, locStart)` instead of `isNextLineEmpty(text, node, options)`. + Use `isPreviousLineEmpty(text, node, locStart)` instead of `isPreviousLineEmpty(text, node, options)`. - `prettier.util.getNextNonSpaceNonCommentCharacterIndex` is updated.
Use `getNextNonSpaceNonCommentCharacterIndex(text, node, locEnd)` instead of `getNextNonSpaceNonCommentCharacterIndex(text, node, options)`. @@ -81,9 +162,22 @@ It may be also worth [checking the option docs](https://prettier.io/docs/en/opti This will help you avoid a mix of line endings in the repo and a broken `git blame`. If the old behavior is still preferred, please configure Prettier with `{ "endOfLine": "auto" }`. -#### Remove the `version` parameter of `prettier.getSupportInfo()` ([#7620](https://github.com/prettier/prettier/pull/7620) by [@thorn0](https://github.com/thorn0)) +#### Cache plugin search results ([#7485](https://github.com/prettier/prettier/pull/7485) by [@fisker](https://github.com/fisker)) + +Previously, Prettier searched the file system for plugins on every `prettier.format` call. Now, search results are cached. The cache can be cleared by calling `prettier.clearConfigCache()`. -In Prettier 1.x (since 1.8.0), it was possible to pass a version number to `prettier.getSupportInfo()` to get information on the languages, options, etc. supported by previous versions. This interesting but apparently not very useful API kept causing maintenance problems and has been removed in Prettier 2.0.0. +#### Remove deprecated options and option values ([#7511](https://github.com/prettier/prettier/pull/7511), [#7533](https://github.com/prettier/prettier/pull/7533), [#7535](https://github.com/prettier/prettier/pull/7535), [#7536](https://github.com/prettier/prettier/pull/7536) by [@fisker](https://github.com/fisker)) + +- Options: + - `useFlowParser` (`--flow-parser` in CLI) has been deprecated [since `v0.0.10`](https://github.com/prettier/prettier/blob/master/CHANGELOG.md#0010). +- Option values: + - `parser`: `babylon` (renamed to `babel` in v1.16.0), `postcss` (renamed to `css` in v1.7.1) + - `proseWrap`: `true` (renamed to `always` in v1.9.0), `false` (renamed to `never` in v1.9.0) + - `trailingComma`: `true` (renamed to `es5` in v0.19.0), `false` (renamed to `none` in v0.19.0) + +#### Remove the `version` parameter of `prettier.getSupportInfo` ([#7620](https://github.com/prettier/prettier/pull/7620) by [@thorn0](https://github.com/thorn0)) + +Since Prettier 1.8.0, it was possible to pass a version number to `prettier.getSupportInfo` to get information on the languages, options, etc. supported by previous versions. This interesting but apparently not very useful API kept causing maintenance problems and has been removed in Prettier 2.0.0. ## Other changes @@ -116,32 +210,6 @@ const f = function (value: T) {}; const g = function* () {}; ``` -#### Improved method chain breaking heuristic ([#6685](https://github.com/prettier/prettier/pull/6685) by [@mmkal](https://github.com/mmkal)) - -Previously, any method call chain of length three or longer would be automatically broken into multiple lines. The new heuristic is based on the complexity of the call arguments in the chain, rather than simply on the chain's length. Now, if chained method calls have arguments which aren't easy to understand at a glance (e.g. functions or deeply-nested objects), the chain is broken. Otherwise, they're allowed to remain on one line. See prior issues [#3197](https://github.com/prettier/prettier/issues/3107), [#4765](https://github.com/prettier/prettier/pull/4765), [#1565](https://github.com/prettier/prettier/issues/1565) and [#4125](https://github.com/prettier/prettier/pull/4125) for context and examples. - - -```javascript -// Output (Prettier stable) -if ( - foo - .one() - .two() - .three() === - bar - .four() - .five() - .six() -) { - // ... -} - -// Output (Prettier master) -if (foo.one().two().three() === bar.four().five().six()) { - // ... -} -``` - #### Fix unstable formatting of labeled statements with comments ([#6984](https://github.com/prettier/prettier/pull/6984) by [@clement26695](https://github.com/clement26695)) @@ -193,23 +261,6 @@ bar)}`; }`; ``` -#### Preserve parentheses for JSDoc type casting with extra trailing spaces and asterisks ([#7011](https://github.com/prettier/prettier/pull/7011) by [@evilebottnawi](https://github.com/evilebottnawi)) - - -```javascript -// Input -const foo = /** @type {!Foo} **/ (baz); -const bar = /** @type {!Foo} * * */(baz); - -// Prettier stable -const foo = /** @type {!Foo} **/ baz; -const bar = /** @type {!Foo} * * */ baz; - -// Prettier master -const foo = /** @type {!Foo} **/ (baz); -const bar = /** @type {!Foo} * * */ (baz); -``` - #### Fix unstable formatting of logical expressions ([#7026](https://github.com/prettier/prettier/pull/7026) by [@thorn0](https://github.com/thorn0)) @@ -293,7 +344,7 @@ const foo = ( Because decorators modify the line following, splitting a decorator call’s arguments onto multiple lines can obscure the relationship between the decorator and its intended target, producing less-readable code. Therefore, the -function composition logic introduced in #6033 has been changed to exclude +function composition logic introduced in [#6033](https://github.com/prettier/prettier/pull/6033) has been changed to exclude decorator calls. @@ -359,7 +410,7 @@ html`
`; html` TEXT `; ``` -#### Fix: remove unnecessary parens when yielding JSX ([#7367](https://github.com/prettier/prettier/pull/7367) by [@cola119](https://github.com/cola119)) +#### Remove unnecessary parens when yielding JSX ([#7367](https://github.com/prettier/prettier/pull/7367) by [@cola119](https://github.com/cola119)) ```jsx @@ -451,11 +502,26 @@ foo ? ( ) : null; ``` +#### Keep comments position for assignments/variables ([#7709](https://github.com/prettier/prettier/pull/7709) by [@sosukesuzuki](https://github.com/sosukesuzuki)) + + +```jsx +// Input +const foo = /* comments */ + bar; + +// Prettier stable +const foo /* comments */ = bar; + +// Prettier master +const foo = /* comments */ bar; +``` + ### TypeScript #### Babel as an alternative parser for TypeScript ([#6400](https://github.com/prettier/prettier/pull/6400) by [@JounQin](https://github.com/JounQin) & [@thorn0](https://github.com/thorn0)) -A new value for the `parser` option has been added: `babel-ts`, which makes use of Babel’s TypeScript plugin. The `babel-ts` parser supports JavaScript features not yet supported by TypeScript (ECMAScript proposals, e.g. [private methods and accessors](https://github.com/tc39/proposal-private-methods)), but it's less permissive when it comes to error recovery and less battle-tested than the `typescript` parser. While Babel’s TypeScript plugin is quite mature, ASTs produced by the two parsers aren't 100% compatible. We tried to take the discrepancies into account, but there are most likely still cases where code gets formatted differently or even incorrectly. We call upon the you, our users, to help us find such cases. If you see them, please raise issues. In the long run, this will help with [unifying the AST format](https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/typescript-estree#ast-alignment-tests) in future versions of the parsers and thus contribute to a better, more solid JavaScript parser ecosystem. +A new value for the `parser` option has been added: `babel-ts`, which makes use of Babel’s TypeScript plugin. The `babel-ts` parser supports JavaScript features not yet supported by TypeScript (ECMAScript proposals, e.g. [private methods and accessors](https://github.com/tc39/proposal-private-methods)), but it's less permissive when it comes to error recovery and less battle-tested than the `typescript` parser. While Babel’s TypeScript plugin is quite mature, ASTs produced by the two parsers aren't 100% compatible. We tried to take the discrepancies into account, but there are most likely still cases where code gets formatted differently or even incorrectly. We call upon you, our users, to help us find such cases. If you see them, please raise issues. In the long run, this will help with [unifying the AST format](https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/typescript-estree#ast-alignment-tests) in future versions of the parsers and thus contribute to a better, more solid JavaScript parser ecosystem. #### Fix formatting of complex types in arrow function return type annotations ([#6901](https://github.com/prettier/prettier/pull/6901) by [@sosukesuzuki](https://github.com/sosukesuzuki)) @@ -588,7 +654,7 @@ type f1 = ( ) => number; ``` -#### Fix formatting comments for function-like nodes ([#7144](https://github.com/prettier/prettier/pull/7144) by [@armano2](https://github.com/armano2)) +#### Fix formatting of comments for function-like nodes ([#7144](https://github.com/prettier/prettier/pull/7144) by [@armano2](https://github.com/armano2)) ```ts @@ -644,6 +710,7 @@ let foo9: new (/* bar */) => /* foo */ /* baz */ string; let foo10: new (/* foo */ a: /* bar */ string) => /* baz */ string; ``` + ```ts // Input abstract class Test { @@ -694,6 +761,20 @@ type A = { [key: string] }; type B = { [a: string, b: string]: string }; ``` +#### Fix printing of comments in empty type parameters ([#7729](https://github.com/prettier/prettier/pull/7729) by [@sosukesuzuki](https://github.com/sosukesuzuki)) + + +```ts +// Input +const a: T = 1; + +// Prettier stable +Error: Comment "comment" was not printed. Please report this error! + +// Prettier master +const a: T = 1; +``` + ### Flow #### Add support for `symbol` ([#7472](https://github.com/prettier/prettier/pull/7472) by [@fisker](https://github.com/fisker)) @@ -818,9 +899,7 @@ $my-map: ( ); ``` -#### Fix scss variable string concatenation removing spaces ([#7211](https://github.com/prettier/prettier/pull/7211) by [@sasurau4](https://github.com/sasurau4)) - -Previously, when Prettier format the scss variable string concatenation, it would remove spaces. Now, Prettier insert spaces around plus operator. +#### Fix whitespace in SCSS concatenation ([#7211](https://github.com/prettier/prettier/pull/7211) by [@sasurau4](https://github.com/sasurau4)) ```scss @@ -840,6 +919,15 @@ a { } ``` +### Less + +#### Fix multiple long-standing issues by updating `postcss-less` ([#6981](https://github.com/prettier/prettier/pull/6981) by [@fisker](https://github.com/fisker), [#7021](https://github.com/prettier/prettier/pull/7021) by [@evilebottnawi](https://github.com/evilebottnawi), [@thorn0](https://github.com/thorn0)) + +- [`each`](http://lesscss.org/functions/#list-functions-each) is supported now ([#5653](https://github.com/prettier/prettier/issues/5653)). +- `!important` was being moved out of mixin call parameters ([#3544](https://github.com/prettier/prettier/issues/3544)). +- Comments in rulesets passed to mixin calls caused duplicate semicolons ([#3096](https://github.com/prettier/prettier/issues/3096)). +- `::before` was broken in mixin call parameters ([#5791](https://github.com/prettier/prettier/issues/5791)). + ### HTML #### Comments in `pre` tags caused bad formatting of following closing tag ([#5959](https://github.com/prettier/prettier/pull/5959) by [@selvazhagan](https://github.com/selvazhagan)) @@ -1111,7 +1199,7 @@ Previously, it worked only for tags. Useful for protecting various macros and pr ```html - + A super long string that has been marked as ignore because it was probably generated by some script. @@ -1195,47 +1283,88 @@ export default { ``` -#### Don't print single `TemplateLiteral` and `StringLiteral` expression on new line ([#7479](https://github.com/prettier/prettier/pull/7479) by [@fisker](https://github.com/fisker)) - -Previously, we print long `TemplateLiteral` and `StringLiteral` on new line in attribute, now we print them on the same line with attribute name. +#### Don't print sole string literals in attributes on a new line ([#7479](https://github.com/prettier/prettier/pull/7479) by [@fisker](https://github.com/fisker)) ```vue - + + +``` - +#### Fix indentation of Vue expressions ([#7781](https://github.com/prettier/prettier/pull/7781) by [@fisker](https://github.com/fisker)) + + +```vue + + + + + + + ``` ### Angular @@ -1256,7 +1385,7 @@ While there are some syntax incompatibilities (one-time bindings and the precede
Warning!
``` -#### Fix formatting i18n attributes ([#7371](https://github.com/prettier/prettier/pull/7371) by [@thorn0](https://github.com/thorn0)) +#### Fix formatting of i18n attributes ([#7371](https://github.com/prettier/prettier/pull/7371) by [@thorn0](https://github.com/thorn0)) Prettier 1.19 [added](https://prettier.io/blog/2019/11/09/1.19.0.html#add-formatting-for-i18n-attributes-6695-by-voithos) support for formatting [i18n attributes](https://angular.io/guide/i18n), but putting the closing quote mark on a new line @@ -1286,7 +1415,7 @@ prop="My Text">
> ``` -### Handlebars +### Handlebars (alpha) #### Fix superfluous line breaks in `ConcatStatement` ([#7051](https://github.com/prettier/prettier/pull/7051) by [@dcyriller](https://github.com/dcyriller)) @@ -1480,6 +1609,32 @@ and ``` +#### Preserve whitespace control characters ([#7575](https://github.com/prettier/prettier/pull/7575) by [@mahirshah](https://github.com/mahirshah)) + + +```hbs +{{!-- input --}} +{{~#if bar}} + if1 +{{~else~}} + else +{{~/if~}} + +{{!-- stable --}} +{{#if bar}} + if1 +{{else}} + else +{{/if}} + +{{!-- master --}} +{{~#if bar}} + if1 +{{~else~}} + else +{{~/if~}} +``` + ### GraphQL #### Improve detection of separator between interfaces ([#7305](https://github.com/prettier/prettier/pull/7305) by [@fisker](https://github.com/fisker)) @@ -1665,7 +1820,7 @@ Previously, when Prettier formatted an HTML tag placed just after a list item, i
asdf
``` -#### Fix incorrect prettification of multi-line markdown footnote ([#7203](https://github.com/prettier/prettier/pull/7203) by [@sasurau4](https://github.com/sasurau4)) +#### Fix formatting of multi-line footnote ([#7203](https://github.com/prettier/prettier/pull/7203) by [@sasurau4](https://github.com/sasurau4)) ```md @@ -1752,17 +1907,6 @@ SyntaxError: Unexpected closing tag "Tag". It may happen when the tag has alread ``` -### API - -#### Remove deprecated options and option values ([#7511](https://github.com/prettier/prettier/pull/7511), [#7533](https://github.com/prettier/prettier/pull/7533), [#7535](https://github.com/prettier/prettier/pull/7535), [#7536](https://github.com/prettier/prettier/pull/7536) by [@fisker](https://github.com/fisker)) - -- Options: - - `useFlowParser` (`--flow-parser` in CLI) [has been deprecated since `v0.0.10`](https://github.com/prettier/prettier/blob/master/CHANGELOG.md#0010). -- Renamed option values whose old names were kept for backward compatibility: - - `parser`: `babylon` (renamed to `babel` in _v1.16.0_), `postcss` (renamed to `css` in _v1.7.1_) - - `trailingComma`: `true` (renamed to `always` in _v1.9.0_), `false` (renamed to `never` in _v1.9.0_) - - `proseWrap`: `true` (renamed to `es5` in _v0.19.0_), `false` (renamed to `none` in _v0.19.0_) - ### CLI #### Support file extensions `.cjs` and `.yaml.sed` ([#7210](https://github.com/prettier/prettier/pull/7210) by [@sosukesuzuki](https://github.com/sosukesuzuki)) @@ -1778,10 +1922,6 @@ $ prettier test.cjs console.log("Hello, World!"); ``` -#### Test whether passed globs are names of existing files before treating them as globs ([#7587](https://github.com/prettier/prettier/pull/7587) by [@fisker](https://github.com/fisker)) - -Since file names in Linux can contain almost any characters, strings like `foo*.js` and `[bar].css` are valid file names. Previously, if the user needed to format a file named `[bar].css`, a glob escaping syntax had to be used: `prettier "\[bar].css"` (this one doesn't work on Windows, where backslashes are treated as path separators) or `prettier "[[]bar].css"`. Because of this, important use cases were broken. E.g. [lint-staged](https://github.com/okonet/lint-staged) passes absolute paths and knows nothing about the escaping syntax. Now, when Prettier CLI gets a glob, it first tries to resolve it as a literal file name. - #### Respect `--ignore-path` when prettier executes from a subdirectory ([#7588](https://github.com/prettier/prettier/pull/7588) by [@heylookltsme](https://github.com/heylookltsme)) Changes the filename used when filtering ignored files to be relative to the