diff --git a/.github/ISSUE_TEMPLATE/formatting.md b/.github/ISSUE_TEMPLATE/formatting.md index 885dec4ab..1c5021189 100644 --- a/.github/ISSUE_TEMPLATE/formatting.md +++ b/.github/ISSUE_TEMPLATE/formatting.md @@ -26,7 +26,7 @@ Tip! Don't write this stuff manually. --> -**Prettier 2.0.2** +**Prettier 2.0.3** [Playground link](https://prettier.io/playground/#.....) ```sh diff --git a/.github/ISSUE_TEMPLATE/integration.md b/.github/ISSUE_TEMPLATE/integration.md index e5d498ce5..6f40ee4a1 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.0.2 +- Prettier Version: 2.0.3 - Running Prettier via: - Runtime: - Operating System: diff --git a/CHANGELOG.md b/CHANGELOG.md index 8951d877a..af1f4836a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,274 @@ +# 2.0.3 + +[diff](https://github.com/prettier/prettier/compare/2.0.2...2.0.3) + +### JavaScript + +#### Fix `prettier-ignore` inside JSX ([#7877](https://github.com/prettier/prettier/pull/7877) by [@fisker](https://github.com/fisker)) + + +```jsx +// Input +
+{ + /* prettier-ignore */ + x ? : +} +
; + +// Prettier 2.0.2 (first output) +
+ {/* prettier-ignore */ + x ? : } +
; + +// Prettier 2.0.2 (second output) +
{/* prettier-ignore */ x ? : }
; + +// Prettier 2.0.3 +
+ { + /* prettier-ignore */ + x ? : + } +
; +``` + +#### Fix regressions in styled-components template literals ([#7883](https://github.com/prettier/prettier/pull/7883) by [@thorn0](https://github.com/thorn0)) + + +```js +// 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](https://github.com/prettier/prettier/pull/7891) by [@sidharthv96](https://github.com/sidharthv96)) + + +``` +// Input +export const IAmIncredibleLongFunctionName = IAmAnotherFunctionName( + (_0: IAmIncredibleLongParameterType) => { + setTimeout(() => { + /* + Multiline comment + Multiline comment + Multiline comment + */ + console.log( + "Multiline string\ + Multiline string\ + Multiline string" + ); + }); + } +); + +// Prettier 2.0.2 +export const IAmIncredibleLongFunctionName = IAmAnotherFunctionName( + (_0: IAmIncredibleLongParameterType) => { + setTimeout(() => { + /* + Multiline comment + Multiline comment + Multiline comment + */ + console.log( + "Multiline string\ + Multiline string\ + Multiline string" + ); + }); + } +); + +// Prettier 2.0.3: same as input +``` + +#### Fix bug with holes in array literals ([#7911](https://github.com/prettier/prettier/pull/7911) by [@bakkot](https://github.com/bakkot)) + + +```jsx +// 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](https://github.com/prettier/prettier/pull/7869) by [@sosukesuzuki](https://github.com/sosukesuzuki)) + + +```ts +// 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](https://github.com/prettier/prettier/pull/7892) by [@sosukesuzuki](https://github.com/sosukesuzuki)) + + +```js +// 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](https://github.com/prettier/prettier/pull/7923) by [@DmitryGonchar](https://github.com/DmitryGonchar)) + + +```jsx +// 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](https://github.com/prettier/prettier/pull/7867) by [@fisker](https://github.com/fisker)) + + +```html + + +_ + + + +_ + + + +_ + + + +_ +``` + +#### Format `script` and `style` inside tags with a colon in the name ([#7916](https://github.com/prettier/prettier/pull/7916) by [@fisker](https://github.com/fisker)) + + +```html + + + + + + + + + + + + + + + + + +``` + +### Other changes + +- Workaround for `require.resolve` in prettier-vscode ([#7951](https://github.com/prettier/prettier/pull/7951) by [@thorn0](https://github.com/thorn0)) +- Fix unstable Angular expression binding ([#7924](https://github.com/prettier/prettier/pull/7924) by [@fisker](https://github.com/fisker)) +- Update `isSCSS` regex ([#7922](https://github.com/prettier/prettier/pull/7922) by [@fisker](https://github.com/fisker)) +- Fix formatting of empty files ([#7921](https://github.com/prettier/prettier/pull/7921) by [@fisker](https://github.com/fisker)) + # 2.0.2 [diff](https://github.com/prettier/prettier/compare/2.0.1...2.0.2) @@ -840,7 +1111,7 @@ export const getVehicleDescriptor = async ( - Fixed a bug for missing `.editorconfig` files (#3439 by josephfrazier) - Fix comments being moved in class methods and object properties with the babylon parser (#3441 by duailibe) - Better printing of member chains with a TSNonNullExpression (`!` character) (#3442 by duailibe) -- Fix missing commas in object properties when a `pretter-ignore` comment is present (#3448 by duailibe) +- Fix missing commas in object properties when a `prettier-ignore` comment is present (#3448 by duailibe) - Fix printing union types inside a function param type (#3446 by duailibe) - Fix closing parens on multi-line intersection/union type (#3436 by josephfrazier) - Don't break single argument destructuring arguments (for arrays and with simple default values) (#3443 by duailibe) @@ -901,7 +1172,7 @@ export const getVehicleDescriptor = async ( - Fix cosmiconfig in the built version of Prettier (#2930 by lydell) - Fix: ignore and show warning for unknown option from config file (#2929 by ikatyang) -- Don't use parens with optional chaining meber expressions (#2921 by azz) +- Don't use parens with optional chaining member expressions (#2921 by azz) # 1.7.2 @@ -921,7 +1192,7 @@ export const getVehicleDescriptor = async ( - Don't lowercase Less variables when parsed with SCSS parser (#2833 by lydell) - Don't lowercase `&class` in SCSS/Less selectors (#2834 by lydell) - Add support for ClassPrivateProperty (#2837 by existentialism) -- Upgrade cosmiconfig to v3, remove hardcoded combinatoric problem (#2843 by azz) +- Upgrade cosmiconfig to v3, remove hardcoded combinatorial problem (#2843 by azz) - Split Less and SCSS parsing into different parsers (#2844 by lydell) - feat: support detailed `--help` (#2847 by ikatyang) - Update cosmiconfig to 3.0.1 to avoid memory leak (#2848 by danez) @@ -1058,7 +1329,7 @@ Lots of small fixes, mainly for TypeScript. - Add TSParameterProperty, TSAbstractClassDeclaration and TSAbstractMethodDefinition (#1410) - Inline nullable in flow generics (#1426) - fixed method 'check' error 'format' of undefined (#1424) -- feat(typescript): add delcare modifier support for vars, classes and functions (#1436) +- feat(typescript): add declare modifier support for vars, classes and functions (#1436) - Allow flow declarations to break on StringLiteralTypeAnnotations (#1437) - Require '::a.b' to have a preceding ; in no-semi style (#1442) - Require '(a || b).c++' to have a preceding ; in no-semi style (#1443) @@ -1115,7 +1386,7 @@ Lots of small fixes, mainly for TypeScript. - Bail when traversing === groups (#1294) - Avoid breaking arguments for last arg expansion (#1305) - Add typescript as a valid parser value (#1318) -- Add jestbrains filewatcher docs (#1310) +- Add JetBrains File Watcher docs (#1310) - Add prettier_d to Related Projects (#1328) - Add parentheses for assignment as body of arrow (#1326) - Add information about Vim's other autocmd events (#1333) @@ -1197,7 +1468,7 @@ Lots of small fixes, mainly for TypeScript. - Run prettier 0.20.0 (#835) - [JSX] Don't wrap JSX Elements in parentheses in {} (#845) - Fix comment after the last argument of a function (#856) -- Fix travis build imag +- Fix travis build image - Do not break require calls (#841) - Stabilize import as comments (#855) - Fix jsx expression comment that break (#852) @@ -1571,7 +1842,7 @@ Now using minor versions instead of patch versions for the releases. - Fix issue with ArrowFunctionExpression parens (#236) - Add npm version badge (#240) - Consolidate badges in readme -- Fix parens issue with nested UrnaryExpressions (#237) +- Fix parens issue with nested UnaryExpressions (#237) - Escape strings using jsesc (#229) - Add newline for empty blocks {} (#205) - Fix empty export with from clause (#248) @@ -1631,7 +1902,7 @@ Now using minor versions instead of patch versions for the releases. - Update run_spec to support options - Add tests for bracketSpacing option - Add tests for quotes option -- Add tests for tabWiths option +- Add tests for tabWidth option - Add tests for trailingComma option - Fix for Node 4 - Add test for shebang and move to index.js (#170) diff --git a/changelog_unreleased/flow/pr-7892.md b/changelog_unreleased/flow/pr-7892.md deleted file mode 100644 index b03de6750..000000000 --- a/changelog_unreleased/flow/pr-7892.md +++ /dev/null @@ -1,19 +0,0 @@ -#### Print dangling comments for inexact object type ([#7892](https://github.com/prettier/prettier/pull/7892) by [@sosukesuzuki](https://github.com/sosukesuzuki)) - - -```js -// Input -type Foo = { - // comment - ..., -}; - -// Prettier stable -Error: Comment "comment" was not printed. Please report this error! - -// Prettier master -type Foo = { - // comment - ..., -}; -``` diff --git a/changelog_unreleased/flow/pr-7923.md b/changelog_unreleased/flow/pr-7923.md deleted file mode 100644 index 2fc110585..000000000 --- a/changelog_unreleased/flow/pr-7923.md +++ /dev/null @@ -1,52 +0,0 @@ -#### Do not add comma for explicit inexact object with indexer property or no properties ([#7923](https://github.com/prettier/prettier/pull/7923) by [@DmitryGonchar](https://github.com/DmitryGonchar)) - - -```jsx -// Input -type T = { - a: number, - ..., -} - -type T = { - [string]: number, - ..., -} - -type T = { - // comment - ..., -} - -// Prettier stable -type T = { - a: number, - ... -} - -type T = { - [string]: number, - ..., -} - -type T = { - // comment - ..., -} - -// Prettier master -type T = { - a: number, - ... -} - -type T = { - [string]: number, - ... -} - -type T = { - // comment - ... -} -``` diff --git a/changelog_unreleased/html/pr-7867.md b/changelog_unreleased/html/pr-7867.md deleted file mode 100644 index bc58f2fe0..000000000 --- a/changelog_unreleased/html/pr-7867.md +++ /dev/null @@ -1,23 +0,0 @@ -#### Fix ignored empty inline element print ([#7867](https://github.com/prettier/prettier/pull/7867) by [@fisker](https://github.com/fisker)) - - -```html - - -_ - - - -_ - - - -_ - - - -_ -``` diff --git a/changelog_unreleased/html/pr-7916.md b/changelog_unreleased/html/pr-7916.md deleted file mode 100644 index 8028e4508..000000000 --- a/changelog_unreleased/html/pr-7916.md +++ /dev/null @@ -1,34 +0,0 @@ -#### Format `script` and `style` content inside HTML tag with colon ([#7916](https://github.com/prettier/prettier/pull/7916) by [@fisker](https://github.com/fisker)) - - -```html - - - - - - - - - - - - - - - - - -``` diff --git a/changelog_unreleased/javascript/pr-7877.md b/changelog_unreleased/javascript/pr-7877.md deleted file mode 100644 index d24034112..000000000 --- a/changelog_unreleased/javascript/pr-7877.md +++ /dev/null @@ -1,29 +0,0 @@ -#### Fix `prettier-ignore` inside JSX ([#7877](https://github.com/prettier/prettier/pull/7877) by [@fisker](https://github.com/fisker)) - - -```jsx -// Input -
-{ - /* prettier-ignore */ - x ? : -} -
; - -// Prettier stable -
- {/* prettier-ignore */ - x ? : } -
; - -// Prettier stable (Second format) -
{/* prettier-ignore */ x ? : }
; - -// Prettier master -
- { - /* prettier-ignore */ - x ? : - } -
; -``` diff --git a/changelog_unreleased/javascript/pr-7883.md b/changelog_unreleased/javascript/pr-7883.md deleted file mode 100644 index 2334d5493..000000000 --- a/changelog_unreleased/javascript/pr-7883.md +++ /dev/null @@ -1,28 +0,0 @@ -#### Fix regressions in styled-components template literals ([#7883](https://github.com/prettier/prettier/pull/7883) by [@thorn0](https://github.com/thorn0)) - - -```js -// Input -const Icon = styled.div` - background: var(--${background}); - ${Link}:not(:first-child) { - fill: rebeccapurple; - } -`; - -// Prettier stable -const Icon = styled.div` - background: var(-- ${background}); - ${Link}:not (:first-child) { - fill: rebeccapurple; - } -`; - -// Prettier master -const Icon = styled.div` - background: var(--${background}); - ${Link}:not(:first-child) { - fill: rebeccapurple; - } -`; -``` diff --git a/changelog_unreleased/javascript/pr-7891.md b/changelog_unreleased/javascript/pr-7891.md deleted file mode 100644 index 75a7a2e1d..000000000 --- a/changelog_unreleased/javascript/pr-7891.md +++ /dev/null @@ -1,42 +0,0 @@ -#### Fix: line endings were not always converted properly in multiline strings and comments ([#7891](https://github.com/prettier/prettier/pull/7891) by [@sidharthv96](https://github.com/sidharthv96)) - - -``` -// Input -export const IAmIncredibleLongFunctionName = IAmAnotherFunctionName( - (_0: IAmIncredibleLongParameterType) => { - setTimeout(() => { - /* - Multiline comment - Multiline comment - Multiline comment - */ - console.log( - "Multiline string\ - Multiline string\ - Multiline string" - ); - }); - } -); - -// Prettier stable -export const IAmIncredibleLongFunctionName = IAmAnotherFunctionName( - (_0: IAmIncredibleLongParameterType) => { - setTimeout(() => { - /* - Multiline comment - Multiline comment - Multiline comment - */ - console.log( - "Multiline string\ - Multiline string\ - Multiline string" - ); - }); - } -); - -// Prettier master: same as input -``` diff --git a/changelog_unreleased/javascript/pr-7911.md b/changelog_unreleased/javascript/pr-7911.md deleted file mode 100644 index a6996241e..000000000 --- a/changelog_unreleased/javascript/pr-7911.md +++ /dev/null @@ -1,16 +0,0 @@ -#### Fix bug with holes in array literals ([#7911](https://github.com/prettier/prettier/pull/7911) by [@bakkot](https://github.com/bakkot)) - - -```jsx -// Input -new Test() - .test() - .test([, 0]) - .test(); - -// Prettier stable -[error] in.js: TypeError: Cannot read property 'type' of null - -// Prettier master -new Test().test().test([, 0]).test(); -``` diff --git a/changelog_unreleased/typescript/pr-7869.md b/changelog_unreleased/typescript/pr-7869.md deleted file mode 100644 index a242c4d32..000000000 --- a/changelog_unreleased/typescript/pr-7869.md +++ /dev/null @@ -1,14 +0,0 @@ -#### Wrap TSAsExpression ([#7869](https://github.com/prettier/prettier/pull/7869) by [@sosukesuzuki](https://github.com/sosukesuzuki)) - - -```ts -// Input -const varibale = foooooooooooooooooooooooooooooooooooooooooooooooooooo as SomeType; - -// Prettier stable -const varibale = foooooooooooooooooooooooooooooooooooooooooooooooooooo as SomeType; - -// Prettier master -const varibale = - foooooooooooooooooooooooooooooooooooooooooooooooooooo as SomeType; -``` diff --git a/cspell.json b/cspell.json index c48bf926f..67771de6e 100644 --- a/cspell.json +++ b/cspell.json @@ -168,6 +168,7 @@ "importmap", "indentable", "indexof", + "infc", "instanceof", "Intelli", "intrinsics", @@ -326,6 +327,7 @@ "serializer", "serviceworker", "setlocal", + "setq", "shellscape", "shellsession", "Shigeaki", diff --git a/docs/browser.md b/docs/browser.md index 130bd7566..11913ee92 100644 --- a/docs/browser.md +++ b/docs/browser.md @@ -16,8 +16,8 @@ See [Usage](#usage) below for examples. ### Global ```html - - + + - + +