diff --git a/website/blog/2020-03-21-2.0.0.md b/website/blog/2020-03-21-2.0.0.md index 4b60a096661e..747dc15e3842 100644 --- a/website/blog/2020-03-21-2.0.0.md +++ b/website/blog/2020-03-21-2.0.0.md @@ -20,7 +20,7 @@ Previously, any method call chain of length three or longer would be automatical ```javascript -// Output (Prettier stable) +// Prettier 1.19 if ( foo .one() @@ -34,7 +34,7 @@ if ( // ... } -// Output (Prettier master) +// Prettier 2.0 if (foo.one().two().three() === bar.four().five().six()) { // ... } @@ -55,10 +55,10 @@ const nestedAssertions = /** @type {MyType} */ (/** @type {unknown} */ (x)); -// Prettier stable +// Prettier 1.19 const nestedAssertions /** @type {MyType} */ /** @type {unknown} */ = x; -// Prettier master +// Prettier 2.0 const nestedAssertions = /** @type {MyType} */ (/** @type {unknown} */ (x)); ``` @@ -133,10 +133,10 @@ In version 2.0, this behavior has become the default. // Input const fn = (x) => y => x + y; -// Prettier stable +// Prettier 1.19 const fn = x => y => x + y; -// Prettier master +// Prettier 2.0 const fn = (x) => (y) => x + y; ``` @@ -191,7 +191,7 @@ Previously, a space would be added after the `function` keyword in function decl ```ts -// Prettier stable +// Prettier 1.19 const identity = function(value) { return value; }; @@ -201,7 +201,7 @@ function identity(value) { const f = function(value: T) {}; const g = function*() {}; -// Prettier master +// Prettier 2.0 const identity = function (value) { return value; }; @@ -221,15 +221,15 @@ loop1: //test const i = 3; -// Prettier stable (first output) +// Prettier 1.19 (first output) loop1: //test const i = 3; -// Prettier stable (second output) +// Prettier 1.19 (second output) //test loop1: const i = 3; -// Prettier master (first output) +// Prettier 2.0 (first and second outputs) //test loop1: const i = 3; ``` @@ -243,7 +243,7 @@ loop1: const i = 3; `111111111 222222222 333333333 444444444 555555555 666666666 777777777 ${foo | bar}`; `111111111 222222222 333333333 444444444 555555555 666666666 777777777 ${(foo, bar)}`; -// Prettier stable +// Prettier 1.19 `111111111 222222222 333333333 444444444 555555555 666666666 777777777 ${foo || bar}`; `111111111 222222222 333333333 444444444 555555555 666666666 777777777 ${foo | @@ -251,7 +251,7 @@ loop1: const i = 3; `111111111 222222222 333333333 444444444 555555555 666666666 777777777 ${(foo, bar)}`; -// Prettier master +// Prettier 2.0 `111111111 222222222 333333333 444444444 555555555 666666666 777777777 ${ foo || bar }`; @@ -272,18 +272,18 @@ const averredBathersBoxroomBuggyNurl = bifornCringerMoshedPerplexSawder === 1 || (askTrovenaBeenaDependsRowans === 2 || glimseGlyphsHazardNoopsTieTie === 3); -// Prettier stable (first output) +// Prettier 1.19 (first output) const averredBathersBoxroomBuggyNurl = bifornCringerMoshedPerplexSawder === 1 || askTrovenaBeenaDependsRowans === 2 || glimseGlyphsHazardNoopsTieTie === 3; -// Prettier stable (second output) +// Prettier 1.19 (second output) const averredBathersBoxroomBuggyNurl = bifornCringerMoshedPerplexSawder === 1 || askTrovenaBeenaDependsRowans === 2 || glimseGlyphsHazardNoopsTieTie === 3; -// Prettier master (first and second outputs) +// Prettier 2.0 (first and second outputs) const averredBathersBoxroomBuggyNurl = bifornCringerMoshedPerplexSawder === 1 || askTrovenaBeenaDependsRowans === 2 || @@ -299,14 +299,14 @@ function foo() { throw this.hasPlugin("dynamicImports") && this.lookahead().type === tt.parenLeft.right; } -// Prettier stable +// Prettier 1.19 function foo() { throw this.hasPlugin("dynamicImports") && this.lookahead().type === tt.parenLeft.right; } -// Prettier master +// Prettier 2.0 function foo() { throw ( this.hasPlugin("dynamicImports") && @@ -324,14 +324,14 @@ const foo = (number % 10 >= 2 && (number % 100 < 10 || number % 100 >= 20) ? kochabCooieGameOnOboleUnweave : annularCooeedSplicesWalksWayWay) ? anodyneCondosMalateOverateRetinol : averredBathersBoxroomBuggyNurl; -// Prettier stable +// Prettier 1.19 const foo = (number % 10 >= 2 && (number % 100 < 10 || number % 100 >= 20) ? kochabCooieGameOnOboleUnweave : annularCooeedSplicesWalksWayWay) ? anodyneCondosMalateOverateRetinol : averredBathersBoxroomBuggyNurl; -// Prettier master +// Prettier 2.0 const foo = ( number % 10 >= 2 && (number % 100 < 10 || number % 100 >= 20) ? kochabCooieGameOnOboleUnweave @@ -357,7 +357,7 @@ export class Item { thing!: Thing; } -// Output (Prettier stable) +// Prettier 1.19 export class Item { @OneToOne( () => Thing, @@ -366,7 +366,7 @@ export class Item { thing!: Thing; } -// Output (Prettier master) +// Prettier 2.0 export class Item { @OneToOne(() => Thing, x => x.item) thing!: Thing; @@ -381,10 +381,10 @@ export class Item { return // comment ; -// Prettier stable +// Prettier 1.19 return // comment; -// Prettier master +// Prettier 2.0 return; // comment ``` @@ -399,7 +399,7 @@ This doesn't happen anymore unless `--html-whitespace-sensitivity ignore` option html`
`; html` TEXT `; -// Prettier stable +// Prettier 1.19 html`
`; @@ -407,7 +407,7 @@ html` TEXT `; -// Prettier master +// Prettier 2.0 html`
`; html` TEXT `; ``` @@ -421,12 +421,12 @@ function* f() { yield
generator
; } -// Prettier stable +// Prettier 1.19 function* f() { yield (
generator
); } -// Prettier master +// Prettier 2.0 function* f() { yield
generator
; } @@ -441,10 +441,10 @@ Omitting these parentheses makes the code invalid. // Input export default (1, 2); -// Prettier stable +// Prettier 1.19 export default 1, 2; -// Prettier master +// Prettier 2.0 export default (1, 2); ``` @@ -456,11 +456,11 @@ export default (1, 2); (foo?.bar)(); new (foo?.bar)(); -// Prettier stable +// Prettier 1.19 foo?.bar(); new foo?.bar(); -// Prettier master +// Prettier 2.0 (foo?.bar)(); new (foo?.bar)(); ``` @@ -477,7 +477,7 @@ undefined foo ? loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong jsx : null -// Prettier stable +// Prettier 1.19 foo ? ( loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong jsx @@ -491,7 +491,7 @@ foo ? ( ) : null; -// Prettier master +// Prettier 2.0 foo ? ( loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong jsx @@ -512,10 +512,10 @@ foo ? ( const foo = /* comments */ bar; -// Prettier stable +// Prettier 1.19 const foo /* comments */ = bar; -// Prettier master +// Prettier 2.0 const foo = /* comments */ bar; ``` @@ -536,13 +536,13 @@ export const getVehicleDescriptor = async ( Collections.Parts.PrintedCircuitBoardAssembly["attributes"] & undefined > => {}; -// Prettier stable +// Prettier 1.19 export const getVehicleDescriptor = async ( vehicleId: string ): Promise => {}; -// Prettier master +// Prettier 2.0 export const getVehicleDescriptor = async ( vehicleId: string ): Promise< @@ -559,10 +559,10 @@ Another fix related to error recovery. Should come in handy to those who migrate // Input function fromFlow(arg: ?Maybe) {} -// Prettier stable +// Prettier 1.19 Error: unknown type: "TSJSDocNullableType" -// Prettier master +// Prettier 2.0 function fromFlow(arg: ?Maybe) {} ``` @@ -583,7 +583,7 @@ type ValidateArgs = [ ...string[], ]; -// Prettier stable +// Prettier 1.19 type ValidateArgs = [ { [key: string]: any; @@ -592,7 +592,7 @@ type ValidateArgs = [ ...string[], ]; -// Prettier master +// Prettier 2.0 type ValidateArgs = [ { [key: string]: any; @@ -616,7 +616,7 @@ const foo = () => { // foo ;[1,2,3].forEach(bar) -// Prettier stable +// Prettier 1.19 const foo = () => { return; }; @@ -624,7 +624,7 @@ const foo = () => { // foo [1, 2, 3].forEach(bar); -// Prettier master +// Prettier 2.0 const foo = () => { return; }; @@ -643,13 +643,13 @@ type f1 = ( // TODO this is a very very very very long comment that makes it go > 80 columns ) => number; -// Prettier stable +// Prettier 1.19 type f1 = (currentRequest: { a: number; }) => // TODO this is a very very very very long comment that makes it go > 80 columns number; -// Prettier master +// Prettier 2.0 type f1 = ( currentRequest: { a: number } // TODO this is a very very very very long comment that makes it go > 80 columns @@ -677,7 +677,7 @@ type foo8 = /* foo */ (a: /* bar */ string) /* baz */ => void let foo9: new /* foo */ (/* bar */) /* baz */ => string; let foo10: new /* foo */ (a: /* bar */ string) /* baz */ => string; -// Prettier stable +// Prettier 1.19 interface foo1 { bar1 /* foo */ /* baz */(); // bat bar2 /* foo */ /* bar */ /* baz */ /* bat */?(); @@ -694,7 +694,7 @@ type foo8 = /* foo */ (a: /* bar */ string) => /* baz */ void; let foo9: new () => /* foo */ /* bar */ /* baz */ string; let foo10: new (/* foo */ a: /* bar */ string) => /* baz */ string; -// Prettier master +// Prettier 2.0 interface foo1 { bar1 /* foo */(/* baz */); // bat bar2 /* foo */ /* bar */?(/* baz */) /* bat */; @@ -720,10 +720,10 @@ abstract class Test { abstract foo13 /* foo */ (/* bar */) /* baz */ } -// Prettier stable +// Prettier 1.19 Error: Comment "foo" was not printed. Please report this error! -// Prettier master +// Prettier 2.0 abstract class Test { abstract foo12 /* foo */(a: /* bar */ string): /* baz */ void; abstract foo13 /* foo */(/* bar */); /* baz */ @@ -737,10 +737,10 @@ abstract class Test { // Input type A = { [key in B] }; -// Prettier stable +// Prettier 1.19 type A = { [key in B]: }; -// Prettier master +// Prettier 2.0 type A = { [key in B] }; ``` @@ -754,11 +754,11 @@ Even though index signatures without type annotations or with multiple parameter type A = { [key: string] }; type B = { [a: string, b: string]: string; }; -// Prettier stable +// Prettier 1.19 type A = { [key: string]: }; type B = { [a: stringb: string]: string }; -// Prettier master +// Prettier 2.0 type A = { [key: string] }; type B = { [a: string, b: string]: string }; ``` @@ -770,10 +770,10 @@ type B = { [a: string, b: string]: string }; // Input const a: T = 1; -// Prettier stable +// Prettier 1.19 Error: Comment "comment" was not printed. Please report this error! -// Prettier master +// Prettier 2.0 const a: T = 1; ``` @@ -791,7 +791,7 @@ const x: symbol = Symbol(); // Prettier after updating Flow, but without this fix Error: unknown type: "SymbolTypeAnnotation" -// Prettier master +// Prettier 2.0 const x: symbol = Symbol(); ``` @@ -811,10 +811,10 @@ class Foo { method2() {} } -// Prettier stable +// Prettier 1.19 SyntaxError: Unexpected token `@`, expected the token `class` (2:1) -// Prettier master +// Prettier 2.0 /* @flow */ @decorator4 class Foo { @@ -836,12 +836,12 @@ class Foo { #privateProp: number; } -// Prettier stable +// Prettier 1.19 class Foo { privateProp: number; } -// Prettier master +// Prettier 2.0 class Foo { #privateProp: number; } @@ -861,11 +861,11 @@ Prettier now always preserves original casing. Label { } -/* Prettier stable */ +/* Prettier 1.19 */ label { } -/* Prettier master */ +/* Prettier 2.0 */ Label { } ``` @@ -884,7 +884,7 @@ $my-map: ( 'bar': 2, // Comment ); -// Prettier stable +// Prettier 1.19 $my-map: ( "foo": 1, // Comment @@ -892,7 +892,7 @@ $my-map: ( // Comment, ); -// Prettier master +// Prettier 2.0 $my-map: ( "foo": 1, // Comment @@ -910,12 +910,12 @@ a { background-image: url($test-path + 'static/test.jpg'); } -// Prettier stable +// Prettier 1.19 a { background-image: url($test-path+"static/test.jpg"); } -// Prettier master +// Prettier 2.0 a { background-image: url($test-path + "static/test.jpg"); } @@ -942,14 +942,14 @@ a { - +
     
   
- +
     
@@ -975,7 +975,7 @@ e-wrap 
  inline  inline   inline  inline 
 
 
-
+
 
   
looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooog block @@ -991,7 +991,7 @@ e-wrap > inline - +
looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooog block @@ -1025,10 +1025,10 @@ e-wrap < - + TypeError: Cannot read property 'start' of null - +
<
``` @@ -1043,10 +1043,10 @@ srcset=" /media/examples/surfer-240-200.jpg "> - + Error: Mixed descriptor in srcset is not supported - + ``` @@ -1058,10 +1058,10 @@ Error: Mixed descriptor in srcset is not supported


- + TypeError: Cannot read property 'start' of null - +


``` @@ -1075,14 +1075,14 @@ TypeError: Cannot read property 'start' of null - + - +
Should not insert empty line before this div
- +
Should not insert empty line before this div
- +
@@ -1126,7 +1126,7 @@ even can not fit one line really a lot and lot of classes ">
- +
- +
- +
- +
export default { data: () => ({ @@ -1272,7 +1272,7 @@ export default { } - + - + - +