prettier v2.0.3 Release Notes
Release Date: 2020-04-05 // about 4 years ago-
JavaScript
๐ 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