diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index c2cebf0ac..14d90648f 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 +# 2.8.2 +b9c3cd4c7016dfb1bb3539c5b3db15fdd54b9f6f # 2.8.1 b87de09bcf9a523fe3da31394ba0e6f5d107cf3e # 2.8.0 diff --git a/.github/ISSUE_TEMPLATE/formatting.md b/.github/ISSUE_TEMPLATE/formatting.md index 4299ace0e..340fab2a4 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 2.8.1** +**Prettier 2.8.2** [Playground link](https://prettier.io/playground/#.....) ```sh diff --git a/.github/ISSUE_TEMPLATE/integration.md b/.github/ISSUE_TEMPLATE/integration.md index a7477dbe9..b397119d2 100644 --- a/.github/ISSUE_TEMPLATE/integration.md +++ b/.github/ISSUE_TEMPLATE/integration.md @@ -20,7 +20,7 @@ BEFORE SUBMITTING AN ISSUE: **Environments:** -- Prettier Version: 2.8.1 +- Prettier Version: 2.8.2 - Running Prettier via: - Runtime: - Operating System: diff --git a/.gitignore b/.gitignore index 81ec75d24..1f5e74845 100644 --- a/.gitignore +++ b/.gitignore @@ -28,6 +28,7 @@ package-lock.json **/.pnp.* .nyc_output .devcontainer +.node-version # When installing software on gitpod.io, `core.*` files are generated /core.* diff --git a/.node-version b/.node-version deleted file mode 100644 index b460d6f2d..000000000 --- a/.node-version +++ /dev/null @@ -1 +0,0 @@ -18.12.1 diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b9bd9142..df1b8030f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,464 @@ +# 2.8.2 + +[diff](https://github.com/prettier/prettier/compare/2.8.1...2.8.2) + +#### Don't lowercase link references ([#13155](https://github.com/prettier/prettier/pull/13155) by [@DerekNonGeneric](https://github.com/DerekNonGeneric) & [@fisker](https://github.com/fisker)) + + +```markdown + +We now don't strictly follow the release notes format suggested by [Keep a Changelog]. + +[Keep a Changelog]: https://example.com/ + + +We now don't strictly follow the release notes format suggested by [Keep a Changelog]. + +[keep a changelog]: https://example.com/ + + + + +``` + +#### Preserve self-closing tags ([#13691](https://github.com/prettier/prettier/pull/13691) by [@dcyriller](https://github.com/dcyriller)) + + +```hbs +{{! Input }} +
+
+ + + + + + + +{{! Prettier 2.8.1 }} +
+
+ + + + + + + +{{! Prettier 2.8.2 }} +
+
+ + + + + + +``` + +#### Allow custom "else if"-like blocks with block params ([#13930](https://github.com/prettier/prettier/pull/13930) by [@jamescdavis](https://github.com/jamescdavis)) + +#13507 added support for custom block keywords used with `else`, but failed to allow block params. This updates printer-glimmer to allow block params with custom "else if"-like blocks. + + +```hbs +{{! Input }} +{{#when isAtWork as |work|}} + Ship that + {{work}}! +{{else when isReading as |book|}} + You can finish + {{book}} + eventually... +{{else}} + Go to bed! +{{/when}} + +{{! Prettier 2.8.1 }} +{{#when isAtWork as |work|}} + Ship that + {{work}}! +{{else when isReading}} + You can finish + {{book}} + eventually... +{{else}} + Go to bed! +{{/when}} + +{{! Prettier 2.8.2 }} +{{#when isAtWork as |work|}} + Ship that + {{work}}! +{{else when isReading as |book|}} + You can finish + {{book}} + eventually... +{{else}} + Go to bed! +{{/when}} +``` + +#### Preserve empty lines between nested SCSS maps ([#13931](https://github.com/prettier/prettier/pull/13931) by [@jneander](https://github.com/jneander)) + + +```scss +/* Input */ +$map: ( + 'one': ( + 'key': 'value', + ), + + 'two': ( + 'key': 'value', + ), +) + +/* Prettier 2.8.1 */ +$map: ( + 'one': ( + 'key': 'value', + ), + 'two': ( + 'key': 'value', + ), +) + +/* Prettier 2.8.2 */ +$map: ( + 'one': ( + 'key': 'value', + ), + + 'two': ( + 'key': 'value', + ), +) +``` + +#### Fix missing parentheses when an expression statement starts with `let[` ([#14000](https://github.com/prettier/prettier/pull/14000), [#14044](https://github.com/prettier/prettier/pull/14044) by [@fisker](https://github.com/fisker), [@thorn0](https://github.com/thorn0)) + + +```jsx +// Input +(let[0] = 2); + +// Prettier 2.8.1 +let[0] = 2; + +// Prettier 2.8.1 (second format) +SyntaxError: Unexpected token (1:5) +> 1 | let[0] = 2; + | ^ + 2 | + +// Prettier 2.8.2 +(let)[0] = 2; +``` + +#### Fix semicolon duplicated at the end of LESS file ([#14007](https://github.com/prettier/prettier/pull/14007) by [@mvorisek](https://github.com/mvorisek)) + + +```less +// Input +@variable: { + field: something; +}; + +// Prettier 2.8.1 +@variable: { + field: something; +}; ; + +// Prettier 2.8.2 +@variable: { + field: something; +}; +``` + +#### Fix no space after unary minus when followed by opening parenthesis in LESS ([#14008](https://github.com/prettier/prettier/pull/14008) by [@mvorisek](https://github.com/mvorisek)) + + +```less +// Input +.unary_minus_single { + margin: -(@a); +} + +.unary_minus_multi { + margin: 0 -(@a); +} + +.binary_minus { + margin: 0 - (@a); +} + +// Prettier 2.8.1 +.unary_minus_single { + margin: - (@a); +} + +.unary_minus_multi { + margin: 0 - (@a); +} + +.binary_minus { + margin: 0 - (@a); +} + +// Prettier 2.8.2 +.unary_minus_single { + margin: -(@a); +} + +.unary_minus_multi { + margin: 0 -(@a); +} + +.binary_minus { + margin: 0 - (@a); +} +``` + +#### Do not change case of property name if inside a variable declaration in LESS ([#14034](https://github.com/prettier/prettier/pull/14034) by [@mvorisek](https://github.com/mvorisek)) + + +```less +// Input +@var: { + preserveCase: 0; +}; + +// Prettier 2.8.1 +@var: { + preservecase: 0; +}; + +// Prettier 2.8.2 +@var: { + preserveCase: 0; +}; +``` + +#### Fix formatting for auto-accessors with comments ([#14038](https://github.com/prettier/prettier/pull/14038) by [@fisker](https://github.com/fisker)) + + +```jsx +// Input +class A { + @dec() + // comment + accessor b; +} + +// Prettier 2.8.1 +class A { + @dec() + accessor // comment + b; +} + +// Prettier 2.8.1 (second format) +class A { + @dec() + accessor; // comment + b; +} + +// Prettier 2.8.2 +class A { + @dec() + // comment + accessor b; +} +``` + +#### Add parentheses for TSTypeQuery to improve readability ([#14042](https://github.com/prettier/prettier/pull/14042) by [@onishi-kohei](https://github.com/onishi-kohei)) + + +```tsx +// Input +a as (typeof node.children)[number] +a as (typeof node.children)[] +a as ((typeof node.children)[number])[] + +// Prettier 2.8.1 +a as typeof node.children[number]; +a as typeof node.children[]; +a as typeof node.children[number][]; + +// Prettier 2.8.2 +a as (typeof node.children)[number]; +a as (typeof node.children)[]; +a as (typeof node.children)[number][]; +``` + +#### Fix displacing of comments in default switch case ([#14047](https://github.com/prettier/prettier/pull/14047) by [@thorn0](https://github.com/thorn0)) + +It was a regression in Prettier 2.6.0. + + +```jsx +// Input +switch (state) { + default: + result = state; // no change + break; +} + +// Prettier 2.8.1 +switch (state) { + default: // no change + result = state; + break; +} + +// Prettier 2.8.2 +switch (state) { + default: + result = state; // no change + break; +} +``` + +#### Support type annotations on auto accessors via `babel-ts` ([#14049](https://github.com/prettier/prettier/pull/14049) by [@sosukesuzuki](https://github.com/sosukesuzuki)) + +[The bug that `@babel/parser` cannot parse auto accessors with type annotations](https://github.com/babel/babel/issues/15205) has been fixed. So we now support it via `babel-ts` parser. + + +```tsx +class Foo { + accessor prop: number; +} +``` + +#### Fix formatting of empty type parameters ([#14073](https://github.com/prettier/prettier/pull/14073) by [@fisker](https://github.com/fisker)) + + +```jsx +// Input +const foo: bar = () => baz; + +// Prettier 2.8.1 +Error: Comment "comment" was not printed. Please report this error! + +// Prettier 2.8.2 +const foo: bar = () => baz; +``` + +#### Add parentheses to head of `ExpressionStatement` instead of the whole statement ([#14077](https://github.com/prettier/prettier/pull/14077) by [@fisker](https://github.com/fisker)) + + +```jsx +// Input +({}).toString.call(foo) === "[object Array]" + ? foo.forEach(iterateArray) + : iterateObject(foo); + +// Prettier 2.8.1 +({}.toString.call(foo) === "[object Array]" + ? foo.forEach(iterateArray) + : iterateObject(foo)); + +// Prettier 2.8.2 +({}).toString.call(foo.forEach) === "[object Array]" + ? foo.forEach(iterateArray) + : iterateObject(foo); +``` + +#### Fix comments after directive ([#14081](https://github.com/prettier/prettier/pull/14081) by [@fisker](https://github.com/fisker)) + + +```jsx +// Input +"use strict" /* comment */; + +// Prettier 2.8.1 (with other js parsers except `babel`) +Error: Comment "comment" was not printed. Please report this error! + +// Prettier 2.8.2 + +``` + +#### Fix formatting for comments inside JSX attribute ([#14082](https://github.com/prettier/prettier/pull/14082) with by [@fisker](https://github.com/fisker)) + + +```jsx +// Input +function MyFunctionComponent() { + +} + +// Prettier 2.8.1 +Error: Comment "old" was not printed. Please report this error! + +// Prettier 2.8.2 +function MyFunctionComponent() { + ; +} +``` + +#### Quote numeric keys for json-stringify parser ([#14083](https://github.com/prettier/prettier/pull/14083) by [@fisker](https://github.com/fisker)) + + +```jsx +// Input +{0: 'value'} + +// Prettier 2.8.1 +{ + 0: "value" +} + +// Prettier 2.8.2 +{ + "0": "value" +} +``` + +#### Fix removing commas from function arguments in maps ([#14089](https://github.com/prettier/prettier/pull/14089) by [@sosukesuzuki](https://github.com/sosukesuzuki)) + + +```scss +/* Input */ +$foo: map-fn( + ( + "#{prop}": inner-fn($first, $second), + ) +); + +/* Prettier 2.8.1 */ +$foo: map-fn(("#{prop}": inner-fn($first $second))); + +/* Prettier 2.8.2 */ +$foo: map-fn( + ( + "#{prop}": inner-fn($first, $second), + ) +); + +``` + +#### Do not insert space in LESS property access ([#14103](https://github.com/prettier/prettier/pull/14103) by [@fisker](https://github.com/fisker)) + + +```less +// Input +a { + color: @colors[@white]; +} + +// Prettier 2.8.1 +a { + color: @colors[ @white]; +} + +// Prettier 2.8.2 + +``` + # 2.8.1 [diff](https://github.com/prettier/prettier/compare/2.8.0...2.8.1) diff --git a/changelog_unreleased/flow/14073.md b/changelog_unreleased/flow/14073.md deleted file mode 100644 index 8e6f00571..000000000 --- a/changelog_unreleased/flow/14073.md +++ /dev/null @@ -1,13 +0,0 @@ -#### Fix formatting of empty type parameters (#14073 by @fisker) - - -```jsx -// Input -const foo: bar = () => baz; - -// Prettier stable -Error: Comment "comment" was not printed. Please report this error! - -// Prettier main -const foo: bar = () => baz; -``` diff --git a/changelog_unreleased/handlebars/13930.md b/changelog_unreleased/handlebars/13930.md deleted file mode 100644 index 6e824a32e..000000000 --- a/changelog_unreleased/handlebars/13930.md +++ /dev/null @@ -1,42 +0,0 @@ -#### Allow custom "else if"-like blocks with block params (#13930 by @jamescdavis) - -#13507 added support for custom block keywords used with `else`, but failed to allow block params. This updates printer-glimmer to allow block params with custom "else if"-like blocks. - - -```hbs -{{! Input }} -{#when isAtWork as |work|}} - Ship that - {{work}}! -{{else when isReading as |book|}} - You can finish - {{book}} - eventually... -{{else}} - Go to bed! -{{/when}} - -{{! Prettier stable }} -{{#when isAtWork as |work|}} - Ship that - {{work}}! -{{else when isReading}} - You can finish - {{book}} - eventually... -{{else}} - Go to bed! -{{/when}} - -{{! Prettier main }} -{#when isAtWork as |work|}} - Ship that - {{work}}! -{{else when isReading as |book|}} - You can finish - {{book}} - eventually... -{{else}} - Go to bed! -{{/when}} -``` diff --git a/changelog_unreleased/javascript/14000.md b/changelog_unreleased/javascript/14000.md deleted file mode 100644 index 914800969..000000000 --- a/changelog_unreleased/javascript/14000.md +++ /dev/null @@ -1,19 +0,0 @@ -#### Fix missing parentheses when an expression statement starts with `let[` (#14000, #14044 by @fisker, @thorn0) - - -```jsx -// Input -(let[0] = 2); - -// Prettier stable -let[0] = 2; - -// Prettier stable (second format) -SyntaxError: Unexpected token (1:5) -> 1 | let[0] = 2; - | ^ - 2 | - -// Prettier main -(let)[0] = 2; -``` diff --git a/changelog_unreleased/javascript/14038.md b/changelog_unreleased/javascript/14038.md deleted file mode 100644 index b52a5aa34..000000000 --- a/changelog_unreleased/javascript/14038.md +++ /dev/null @@ -1,32 +0,0 @@ -#### Fix formatting for auto-accessors with comments (#14038 by @fisker) - - -```jsx -// Input -class A { - @dec() - // comment - accessor b; -} - -// Prettier stable -class A { - @dec() - accessor // comment - b; -} - -// Prettier stable (second format) -class A { - @dec() - accessor; // comment - b; -} - -// Prettier main -class A { - @dec() - // comment - accessor b; -} -``` diff --git a/changelog_unreleased/javascript/14047.md b/changelog_unreleased/javascript/14047.md deleted file mode 100644 index 9fbe38088..000000000 --- a/changelog_unreleased/javascript/14047.md +++ /dev/null @@ -1,27 +0,0 @@ -#### Fix displacing of comments in default switch case (#14047 by @thorn0) - -It was a regression in Prettier 2.6.0. - - -```jsx -// Input -switch (state) { - default: - result = state; // no change - break; -} - -// Prettier stable -switch (state) { - default: // no change - result = state; - break; -} - -// Prettier main -switch (state) { - default: - result = state; // no change - break; -} -``` diff --git a/changelog_unreleased/javascript/14077.md b/changelog_unreleased/javascript/14077.md deleted file mode 100644 index eb48a23b8..000000000 --- a/changelog_unreleased/javascript/14077.md +++ /dev/null @@ -1,19 +0,0 @@ -#### Add parentheses to head of `ExpressionStatement` instead of the whole statement (#14077 by @fisker) - - -```jsx -// Input -({}).toString.call(foo) === "[object Array]" - ? foo.forEach(iterateArray) - : iterateObject(foo); - -// Prettier stable -({}.toString.call(foo) === "[object Array]" - ? foo.forEach(iterateArray) - : iterateObject(foo)); - -// Prettier main -({}).toString.call(foo.forEach) === "[object Array]" - ? foo.forEach(iterateArray) - : iterateObject(foo); -``` diff --git a/changelog_unreleased/javascript/14082.md b/changelog_unreleased/javascript/14082.md deleted file mode 100644 index e56693154..000000000 --- a/changelog_unreleased/javascript/14082.md +++ /dev/null @@ -1,17 +0,0 @@ -#### Fix formatting for comments inside JSX attribute (#14082 with by @fisker) - - -```jsx -// Input -function MyFunctionComponent() { - -} - -// Prettier stable -Error: Comment "old" was not printed. Please report this error! - -// Prettier main -function MyFunctionComponent() { - ; -} -``` diff --git a/changelog_unreleased/json/14083.md b/changelog_unreleased/json/14083.md deleted file mode 100644 index 0ab6322f8..000000000 --- a/changelog_unreleased/json/14083.md +++ /dev/null @@ -1,17 +0,0 @@ -#### Quote numeric keys for json-stringify parser (#14083 by @fisker) - - -```jsx -// Input -{0: 'value'} - -// Prettier stable -{ - 0: "value" -} - -// Prettier main -{ - "0": "value" -} -``` diff --git a/changelog_unreleased/less/14007.md b/changelog_unreleased/less/14007.md deleted file mode 100644 index eed8b756d..000000000 --- a/changelog_unreleased/less/14007.md +++ /dev/null @@ -1,19 +0,0 @@ -#### Fix semicolon duplicated at the end of LESS file (#14007 by @mvorisek) - - -```less -// Input -@variable: { - field: something; -}; - -// Prettier stable -@variable: { - field: something; -}; ; - -// Prettier main -@variable: { - field: something; -}; -``` diff --git a/changelog_unreleased/less/14008.md b/changelog_unreleased/less/14008.md deleted file mode 100644 index d21456462..000000000 --- a/changelog_unreleased/less/14008.md +++ /dev/null @@ -1,43 +0,0 @@ -#### Fix no space after unary minus when followed by opening parenthesis in LESS (#14008 by @mvorisek) - - -```less -// Input -.unary_minus_single { - margin: -(@a); -} - -.unary_minus_multi { - margin: 0 -(@a); -} - -.binary_minus { - margin: 0 - (@a); -} - -// Prettier stable -.unary_minus_single { - margin: - (@a); -} - -.unary_minus_multi { - margin: 0 - (@a); -} - -.binary_minus { - margin: 0 - (@a); -} - -// Prettier main -.unary_minus_single { - margin: -(@a); -} - -.unary_minus_multi { - margin: 0 -(@a); -} - -.binary_minus { - margin: 0 - (@a); -} -``` diff --git a/changelog_unreleased/less/14034.md b/changelog_unreleased/less/14034.md deleted file mode 100644 index 02d0d2d5f..000000000 --- a/changelog_unreleased/less/14034.md +++ /dev/null @@ -1,19 +0,0 @@ -#### Do not change case of property name if inside a variable declaration in LESS (#14034 by @mvorisek) - - -```less -// Input -@var: { - preserveCase: 0; -}; - -// Prettier stable -@var: { - preservecase: 0; -}; - -// Prettier main -@var: { - preserveCase: 0; -}; -``` diff --git a/changelog_unreleased/markdown/13155.md b/changelog_unreleased/markdown/13155.md deleted file mode 100644 index ca3b25123..000000000 --- a/changelog_unreleased/markdown/13155.md +++ /dev/null @@ -1,20 +0,0 @@ -#### Don't lowercase link references (#13155 by @DerekNonGeneric & @fisker) - - -```markdown - -We now don't strictly follow the release notes format suggested by [Keep a Changelog]. - -[Keep a Changelog]: https://example.com/ - - -We now don't strictly follow the release notes format suggested by [Keep a Changelog]. - -[keep a changelog]: https://example.com/ - - - - -``` diff --git a/changelog_unreleased/scss/13931.md b/changelog_unreleased/scss/13931.md deleted file mode 100644 index 426d0c712..000000000 --- a/changelog_unreleased/scss/13931.md +++ /dev/null @@ -1,36 +0,0 @@ -#### Preserve empty lines between nested SCSS maps (#13931 by @jneander) - - -```scss -/* Input */ -$map: ( - 'one': ( - 'key': 'value', - ), - - 'two': ( - 'key': 'value', - ), -) - -/* Prettier stable */ -$map: ( - 'one': ( - 'key': 'value', - ), - 'two': ( - 'key': 'value', - ), -) - -/* Prettier main */ -$map: ( - 'one': ( - 'key': 'value', - ), - - 'two': ( - 'key': 'value', - ), -) -``` diff --git a/changelog_unreleased/typescript/14042.md b/changelog_unreleased/typescript/14042.md deleted file mode 100644 index 9b37741bb..000000000 --- a/changelog_unreleased/typescript/14042.md +++ /dev/null @@ -1,19 +0,0 @@ -#### Add parentheses for TSTypeQuery to improve readability (#14042 by @onishi-kohei) - - -```tsx -// Input -a as (typeof node.children)[number] -a as (typeof node.children)[] -a as ((typeof node.children)[number])[] - -// Prettier stable -a as typeof node.children[number]; -a as typeof node.children[]; -a as typeof node.children[number][]; - -// Prettier main -a as (typeof node.children)[number]; -a as (typeof node.children)[]; -a as (typeof node.children)[number][]; -``` diff --git a/changelog_unreleased/typescript/14049.md b/changelog_unreleased/typescript/14049.md deleted file mode 100644 index 28448fa96..000000000 --- a/changelog_unreleased/typescript/14049.md +++ /dev/null @@ -1,10 +0,0 @@ -#### Support type annotations on auto accessors via `babel-ts` (#14049 by @sosukesuzuki) - -[The bug that `@babel/parser` cannot parse auto accessors with type annotations](https://github.com/babel/babel/issues/15205) has been fixed. So we now support it via `babel-ts` parser. - - -```tsx -class Foo { - accessor prop: number; -} -``` diff --git a/docs/browser.md b/docs/browser.md index 0c03e728e..352c80ae4 100644 --- a/docs/browser.md +++ b/docs/browser.md @@ -29,8 +29,8 @@ See below for examples. ### Global ```html - - + + - + +