Changelog History
Page 3
-
v2.0.3 Changes
April 05, 2020JavaScript
๐ Fix
prettier-ignore
inside JSX (#7877 by @fisker)<!-- prettier-ignore -->
// Input <div> { /* prettier-ignore */ x ? <Y/> : <Z/> } </div>; // Prettier 2.0.2 (first output) <div> {/* prettier-ignore */ x ? <Y/> : <Z/>} </div>; // Prettier 2.0.2 (second output) <div>{/* prettier-ignore */ x ? <Y/> : <Z/>}</div>; // Prettier 2.0.3 <div> { /* prettier-ignore */ x ? <Y/> : <Z/> } </div>;
๐ Fix regressions in styled-components template literals (#7883 by @thorn0)
<!-- prettier-ignore -->
// Input const Icon = styled.div` background: var(--${background}); ${Link}:not(:first-child) { fill: rebeccapurple; } `; // Prettier 2.0.2 const Icon = styled.div` background: var(-- ${background}); ${Link}:not (:first-child) { fill: rebeccapurple; } `; // Prettier 2.0.3 const Icon = styled.div` background: var(--${background}); ${Link}:not(:first-child) { fill: rebeccapurple; } `;
๐ Fix: line endings were not always converted properly in multiline strings and comments (#7891 by @sidharthv96)
<!-- prettier-ignore -->
// Input export const IAmIncredibleLongFunctionName = IAmAnotherFunctionName(<CRLF> (_0: IAmIncredibleLongParameterType) => {<CRLF> setTimeout(() => {<CRLF> /*<CRLF> Multiline comment<CRLF> Multiline comment<CRLF> Multiline comment<CRLF> */<CRLF> console.log(<CRLF> "Multiline string\<CRLF> Multiline string\<CRLF> Multiline string"<CRLF> );<CRLF> });<CRLF> }<CRLF> );<CRLF> // Prettier 2.0.2 export const IAmIncredibleLongFunctionName = IAmAnotherFunctionName(<CRLF> (_0: IAmIncredibleLongParameterType) => {<CRLF> setTimeout(() => {<CRLF> /*<LF> Multiline comment<LF> Multiline comment<LF> Multiline comment<LF> */<CRLF> console.log(<CRLF> "Multiline string\<LF> Multiline string\<LF> Multiline string"<CRLF> );<CRLF> });<CRLF> }<CRLF> );<CRLF> // Prettier 2.0.3: same as input
๐ Fix bug with holes in array literals (#7911 by @bakkot)
<!-- prettier-ignore -->
// Input new Test() .test() .test([, 0]) .test(); // Prettier 2.0.2 [error] in.js: TypeError: Cannot read property 'type' of null // Prettier 2.0.3 new Test().test().test([, 0]).test();
TypeScript
Wrap TSAsExpression (#7869 by @sosukesuzuki)
<!-- prettier-ignore -->
// Input const value = thisIsAnIdentifier as ThisIsAReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyLongInterface; // Prettier 2.0.2 const value = thisIsAnIdentifier as ThisIsAReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyLongInterface; // Prettier 2.0.3 const value = thisIsAnIdentifier as ThisIsAReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyLongInterface;
Flow
๐จ Print dangling comments for inexact object type (#7892 by @sosukesuzuki)
<!-- prettier-ignore -->
// Input type Foo = { // comment ..., }; // Prettier 2.0.2 Error: Comment "comment" was not printed. Please report this error! // Prettier 2.0.3 type Foo = { // comment ..., };
Do not add comma for explicit inexact object with indexer property or no properties (#7923 by @DmitryGonchar)
<!-- prettier-ignore -->
// Input type T = { [string]: number, ..., } type T = { // comment ..., } // Prettier 2.0.2 type T = { [string]: number, ..., } type T = { // comment ..., } // Prettier 2.0.3 type T = { [string]: number, ... } type T = { // comment ... }
HTML
๐ Fix printing of ignored empty inline elements (#7867 by @fisker)
<!-- prettier-ignore -->
<!-- Input--> <!--prettier-ignore--><span></span> <!--prettier-ignore--><span>_</span> <!-- Prettier 2.0.2 (first output) --> <!--prettier-ignore--><span ></span> <!--prettier-ignore--><span>_</span> <!-- Prettier 2.0.2 (second output) --> <!--prettier-ignore--><span ></span> <!--prettier-ignore--><span>_</span> <!-- Prettier 2.0.3 --> <!--prettier-ignore--><span></span> <!--prettier-ignore--><span>_</span>
๐ Format
script
andstyle
inside tags with a colon in the name (#7916 by @fisker)<!-- prettier-ignore -->
<!-- Input --> <with:colon> <script>function foo(){ return 1}</script> <style>a {color: #f00}</style> </with:colon> <!-- Prettier 2.0.2 --> <with:colon> <script> function foo(){ return 1} </script> <style> a {color: #f00} </style> </with:colon> <!-- Prettier 2.0.3 --> <with:colon> <script> function foo() { return 1; } </script> <style> a { color: #f00; } </style> </with:colon>
Other changes
-
v2.0.2 Changes
March 23, 2020๐ฑ ๐ Changelog
-
v2.0.1 Changes
March 21, 2020 -
v2.0 Changes
๐ JavaScript: Fix formatting of pseudo-elements and pseudo-classes in styled-components template literals (#7842 by @thorn0)
<!-- prettier-ignore -->
// Input const Foo = styled.div` ${media.smallDown}::before {} `; // Prettier 2.0.0 const Foo = styled.div` ${media.smallDown}: : before{ } `; // Prettier 2.0.2 const Foo = styled.div` ${media.smallDown}::before { } `;
TypeScript: Avoid trailing commas on index signatures with only one parameter (#7836 by @bakkot)
๐ TypeScript index signatures technically allow multiple parameters and trailing commas, but it's an error to have multiple parameters there, and Babel's TypeScript parser does not accept them. So Prettier now avoids putting a trailing comma there when you have only one parameter.
<!-- prettier-ignore -->
// Input export type A = { a?: { [ x: string ]: typeof SomeLongLongLongTypeName[keyof typeof SomeLongLongLongTypeName]; } | null; }; // Prettier 2.0.0 export type A = { a?: { [ x: string, ]: typeof SomeLongLongLongTypeName[keyof typeof SomeLongLongLongTypeName]; } | null; }; // Prettier 2.0.2 export type A = { a?: { [ x: string ]: typeof SomeLongLongLongTypeName[keyof typeof SomeLongLongLongTypeName]; } | null; };
โช Revert "markdown: fix redundant leading spaces in markdown list" (#7847)
๐ See #7846
-
v1.19.1 Changes
November 09, 2019CLI
๐ Fix
--stdin
regression in 1.19.0 (#6894 by @lydell)<!-- prettier-ignore -->
// Prettier stable $ echo "test" | prettier --stdin --parser babel [error] regeneratorRuntime is not defined // Prettier master $ echo "test" | prettier --stdin --parser babel test;
TypeScript
๐ Fix formatting of union type as arrow function return type (#6896 by @thorn0)
<!-- prettier-ignore -->
// Input export const getVehicleDescriptor = async ( vehicleId: string, ): Promise<Collections.Parts.PrintedCircuitBoardAssembly['attributes'] | undefined> => {} // Prettier stable export const getVehicleDescriptor = async ( vehicleId: string ): Promise<| Collections.Parts.PrintedCircuitBoardAssembly["attributes"] | undefined> => {}; // Prettier master export const getVehicleDescriptor = async ( vehicleId: string ): Promise< Collections.Parts.PrintedCircuitBoardAssembly["attributes"] | undefined > => {};
-
v1.19.0 Changes
November 09, 2019๐ ๐ Release Notes
-
v1.18.2 Changes
June 07, 2019 -
v1.18.1 Changes
June 07, 2019- TypeScript: Add trailing comma in tsx, only for arrow function (#6190 by @sosukesuzuki)
Prettier inserts a trailing comma to single type parameter for arrow functions in tsx, since v 1.18. But, this feature inserts a trailing comma to type parameter for besides arrow functions too (e.g, function , interface). This change fix it.
<!-- prettier-ignore -->
// Input interface Interface1<T> { one: "one"; } function function1<T>() { return "one"; } // Output (Prettier 1.18.0) interface Interface1<T,> { one: "one"; } function function1<T,>() { return "one"; } // Output (Prettier 1.18.1) interface Interface1<T> { one: "one"; } function function1<T>() { return "one"; }
When using
overrides
in the config file, Prettier was not matching dotfiles (files that start with.
). This was fixed in 1.18.1 -
v1.18.0 Changes
June 06, 2019๐ ๐ Release Notes
-
v1.17.1 Changes
May 13, 2019- Range: Fix ranged formatting not using the correct line width (#6050 by @mathieulj)
<!-- prettier-ignore -->
// Input function f() { if (true) { call("this line is 79 chars", "long", "it should", "stay as single line"); } } // Output (Prettier 1.17.0 run with --range-start 30 --range-end 110) function f() { if (true) { call( "this line is 79 chars", "long", "it should", "stay as single line" ); } } // Output (Prettier 1.17.0 run without range) function f() { if (true) { call("this line is 79 chars", "long", "it should", "stay as single line"); } } // Output (Prettier 1.17.1 with and without range) function f() { if (true) { call("this line is 79 chars", "long", "it should", "stay as single line"); } }
- JavaScript: Fix closure compiler typecasts ([#5947] by @jridgewell)
If a closing parenthesis follows after a typecast in an inner expression, the typecast would wrap everything to the that following parenthesis.
<!-- prettier-ignore -->
// Input test(/** @type {!Array} */(arrOrString).length); test(/** @type {!Array} */((arrOrString)).length + 1); // Output (Prettier 1.17.0) test(/** @type {!Array} */ (arrOrString.length)); test(/** @type {!Array} */ (arrOrString.length + 1)); // Output (Prettier 1.17.1) test(/** @type {!Array} */ (arrOrString).length); test(/** @type {!Array} */ (arrOrString).length + 1);
- JavaScript: respect parenthesis around optional chaining before await (#6087 by @evilebottnawi)
<!-- prettier-ignore -->
// Input async function myFunction() { var x = (await foo.bar.blah)?.hi; } // Output (Prettier 1.17.0) async function myFunction() { var x = await foo.bar.blah?.hi; } // Output (Prettier 1.17.1) async function myFunction() { var x = (await foo.bar.blah)?.hi; }
- ๐ Handlebars: Fix {{else}}{{#if}} into {{else if}} merging (#6080 by @dcyriller)
<!-- prettier-ignore -->
// Input {{#if a}} a {{else}} {{#if c}} c {{/if}} e {{/if}} // Output (Prettier 1.17.0) {{#if a}} a {{else if c}} c e {{/if}} // Output (Prettier 1.17.1) Code Sample {{#if a}} a {{else}} {{#if c}} c {{/if}} e {{/if}}
Previously, multiline closure compiler typecast comments with lines that start with * weren't flagged correctly and the subsequent parenthesis were stripped. Prettier 1.17.1 fixes this issue.
<!-- prettier-ignore -->
// Input const style =/** * @type {{ * width: number, * }} */({ width, }); // Output (Prettier 1.17.0) const style =/** * @type {{ * width: number, * }} */ { width, }; // Output (Prettier 1.17.1) const style =/** * @type {{ * width: number, * }} */({ width, });