prettier/prettier
### [`v2.3.1`](https://togithub.com/prettier/prettier/blob/master/CHANGELOG.md#231)
[Compare Source](https://togithub.com/prettier/prettier/compare/2.3.0...2.3.1)
[diff](https://togithub.com/prettier/prettier/compare/2.3.0...2.3.1)
##### Support TypeScript 4.3 ([#10945](https://togithub.com/prettier/prettier/pull/10945) by [@sosukesuzuki](https://togithub.com/sosukesuzuki))
##### [`override` modifiers in class elements](https://devblogs.microsoft.com/typescript/announcing-typescript-4-3/#override)
```ts
class Foo extends {
override method() {}
}
```
##### [static index signatures (`[key: KeyType]: ValueType`) in classes](https://devblogs.microsoft.com/typescript/announcing-typescript-4-3/#static-index-signatures)
```ts
class Foo {
static [key: string]: Bar;
}
```
##### [`get` / `set` in type declarations](https://devblogs.microsoft.com/typescript/announcing-typescript-4-3/#separate-write-types)
```ts
interface Foo {
set foo(value);
get foo(): string;
}
```
##### Preserve attributes order for element node ([#10958](https://togithub.com/prettier/prettier/pull/10958) by [@dcyriller](https://github.comdcyriller))
```handlebars
{{!-- Input --}}
{{!-- Prettier stable --}}
{{!-- Prettier main --}}
```
##### Track cursor position properly when itβs at the end of the range to format ([#10938](https://togithub.com/prettier/prettier/pull/10938) by [@j-f1](https://togithub.com/j-f1))
Previously, if the cursor was at the end of the range to format, it would simply be placed back at the end of the updated range.
Now, it will be repositioned if Prettier decides to add additional code to the end of the range (such as a semicolon).
```jsx
// Input (<|> represents the cursor)
const someVariable = myOtherVariable<|>
// range to format: ^^^^^^^^^^^^^^^
// Prettier stable
const someVariable = myOtherVariable;<|>
// range to format: ^^^^^^^^^^^^^^^
// Prettier main
const someVariable = myOtherVariable<|>;
// range to format: ^^^^^^^^^^^^^^^
```
##### Break the LHS of type alias that has complex type parameters ([#10901](https://togithub.com/prettier/prettier/pull/10901) by [@sosukesuzuki](https://togithub.com/sosukesuzuki))
```ts
// Input
type FieldLayoutWith<
T extends string,
S extends unknown = { width: string }
> = {
type: T;
code: string;
size: S;
};
// Prettier stable
type FieldLayoutWith =
{
type: T;
code: string;
size: S;
};
// Prettier main
type FieldLayoutWith<
T extends string,
S extends unknown = { width: string }
> = {
type: T;
code: string;
size: S;
};
```
##### Break the LHS of assignments that has complex type parameters ([#10916](https://togithub.com/prettier/prettier/pull/10916) by [@sosukesuzuki](https://togithub.com/sosukesuzuki))
```ts
// Input
const map: Map<
Function,
Map
> = new Map();
// Prettier stable
const map: Map> =
new Map();
// Prettier main
const map: Map<
Function,
Map
> = new Map();
```
##### Fix incorrectly wrapped arrow functions with return types ([#10940](https://togithub.com/prettier/prettier/pull/10940) by [@thorn0](https://togithub.com/thorn0))
```ts
// Input
longfunctionWithCall12("bla", foo, (thing: string): complex> => {
code();
});
// Prettier stable
longfunctionWithCall12("bla", foo, (thing: string): complex<
type
> => {
code();
});
// Prettier main
longfunctionWithCall12(
"bla",
foo,
(thing: string): complex> => {
code();
}
);
```
##### Avoid breaking call expressions after assignments with complex type arguments ([#10949](https://togithub.com/prettier/prettier/pull/10949) by [@sosukesuzuki](https://togithub.com/sosukesuzuki))
```ts
// Input
const foo = call<{
prop1: string;
prop2: string;
prop3: string;
}>();
// Prettier stable
const foo =
call<{
prop1: string;
prop2: string;
prop3: string;
}>();
// Prettier main
const foo = call<{
prop1: string;
prop2: string;
prop3: string;
}>();
```
##### Fix order of `override` modifiers ([#10961](https://togithub.com/prettier/prettier/pull/10961) by [@sosukesuzuki](https://togithub.com/sosukesuzuki))
```ts
// Input
class Foo extends Bar {
abstract override foo: string;
}
// Prettier stable
class Foo extends Bar {
abstract override foo: string;
}
// Prettier main
class Foo extends Bar {
abstract override foo: string;
}
```
### [`v2.3.0`](https://togithub.com/prettier/prettier/blob/master/CHANGELOG.md#230)
[Compare Source](https://togithub.com/prettier/prettier/compare/2.2.1...2.3.0)
[diff](https://togithub.com/prettier/prettier/compare/2.2.1...2.3.0)
π [Release Notes](https://prettier.io/blog/2021/05/09/2.3.0.html)
### [`v2.2.1`](https://togithub.com/prettier/prettier/blob/master/CHANGELOG.md#221)
[Compare Source](https://togithub.com/prettier/prettier/compare/2.2.0...2.2.1)
[diff](https://togithub.com/prettier/prettier/compare/2.2.0...2.2.1)
##### Fix formatting for AssignmentExpression with ClassExpression ([#9741](https://togithub.com/prettier/prettier/pull/9741) by [@sosukesuzuki](https://togithub.com/sosukesuzuki))
```js
// Input
module.exports = class A extends B {
method() {
console.log("foo");
}
};
// Prettier 2.2.0
module.exports = class A extends (
B
) {
method() {
console.log("foo");
}
};
// Prettier 2.2.1
module.exports = class A extends B {
method() {
console.log("foo");
}
};
```
### [`v2.2.0`](https://togithub.com/prettier/prettier/blob/master/CHANGELOG.md#220)
[Compare Source](https://togithub.com/prettier/prettier/compare/2.1.2...2.2.0)
[diff](https://togithub.com/prettier/prettier/compare/2.1.2...2.2.0)
π [Release Notes](https://prettier.io/blog/2020/11/20/2.2.0.html)
### [`v2.1.2`](https://togithub.com/prettier/prettier/blob/master/CHANGELOG.md#212)
[Compare Source](https://togithub.com/prettier/prettier/compare/2.1.1...2.1.2)
[diff](https://togithub.com/prettier/prettier/compare/2.1.1...2.1.2)
##### Fix formatting for directives in fields ([#9116](https://togithub.com/prettier/prettier/pull/9116) by [@sosukesuzuki](https://togithub.com/sosukesuzuki))
```graphql
```
### [`v2.1.1`](https://togithub.com/prettier/prettier/blob/master/CHANGELOG.md#211)
[Compare Source](https://togithub.com/prettier/prettier/compare/2.1.0...2.1.1)
[diff](https://togithub.com/prettier/prettier/compare/2.1.0...2.1.1)
##### Fix format on html with frontMatter ([#9043](https://togithub.com/prettier/prettier/pull/9043) by [@fisker](https://togithub.com/fisker))
```html
---
layout: foo
---
Test abc.
TypeError: Cannot read property 'end' of undefined
...
---
layout: foo
---
Test abc.
```
##### Fix broken format for `...infer T` ([#9044](https://togithub.com/prettier/prettier/pull/9044) by [@fisker](https://togithub.com/fisker))
```typescript
// Input
type Tail = T extends [infer U, ...infer R] ? R : never;
// Prettier stable
type Tail = T extends [infer U, ...(infer R)] ? R : never;
// Prettier master
type Tail = T extends [infer U, ...infer R] ? R : never;
```
##### Fix format on `style[lang="sass"]` ([#9051](https://togithub.com/prettier/prettier/pull/9051) by [@fisker](https://togithub.com/fisker))
```jsx
```
##### Fix self-closing blocks and blocks with `src` attribute format ([#9052](https://togithub.com/prettier/prettier/pull/9052), [#9055](https://togithub.com/prettier/prettier/pull/9055) by [@fisker](https://togithub.com/fisker))
```vue
```
### [`v2.1.0`](https://togithub.com/prettier/prettier/blob/master/CHANGELOG.md#210)
[Compare Source](https://togithub.com/prettier/prettier/compare/2.0.5...2.1.0)
[diff](https://togithub.com/prettier/prettier/compare/2.0.5...2.1.0)
π [Release Notes](https://prettier.io/blog/2020/08/24/2.1.0.html)
### [`v2.0.5`](https://togithub.com/prettier/prettier/blob/master/CHANGELOG.md#205)
[Compare Source](https://togithub.com/prettier/prettier/compare/2.0.4...2.0.5)
[diff](https://togithub.com/prettier/prettier/compare/2.0.4...2.0.5)
##### Less: Fix formatting of `:extend` ([#7984](https://togithub.com/prettier/prettier/pull/7984) by [@fisker](https://togithub.com/fisker))
```less
// Input
.class {
&:extend(.some-class .some-other-class .some-very-loooooooooooooong-class all);
}
// Prettier 2.0.4
.class {
&:extend(
.some-class .some-other-class .some-very-loooooooooooooong-class all
);
}
// Prettier 2.0.4 (Second format)
.class {
&: extend(
.some-class .some-other-class .some-very-loooooooooooooong-class all
);
}
// Prettier 2.0.5
.class {
&:extend(
.some-class .some-other-class .some-very-loooooooooooooong-class all
);
}
```
##### Editor integration: Use [`resolve`](https://www.npmjs.com/package/resolve) if builtin `require.resolve` is overridden ([#8072](https://togithub.com/prettier/prettier/pull/8072) by [@fisker](https://togithub.com/fisker))
This fixes issues that the users of Atom and WebStorm faced with 2.0.4.
Prettier now switches to using the `resolve` module for resolving configuration files and plugins if it detects that `require.resolve` isn't Node's builtin function (doesn't support the second argument), which happens in environments like editor extensions. To force the fallback, set the `PRETTIER_FALLBACK_RESOLVE` environment variable to `true`.
### [`v2.0.4`](https://togithub.com/prettier/prettier/blob/master/CHANGELOG.md#204)
[Compare Source](https://togithub.com/prettier/prettier/compare/2.0.3...2.0.4)
[diff](https://togithub.com/prettier/prettier/compare/2.0.3...2.0.4)
##### Revert [#7869](https://togithub.com/prettier/prettier/pull/7869), "\[TypeScript] format TSAsExpression with same logic as BinaryExpression" ([#7958](https://togithub.com/prettier/prettier/pull/7958))
### [`v2.0.3`](https://togithub.com/prettier/prettier/blob/master/CHANGELOG.md#203)
[Compare Source](https://togithub.com/prettier/prettier/compare/2.0.2...2.0.3)
[diff](https://togithub.com/prettier/prettier/compare/2.0.2...2.0.3)
##### JavaScript
##### Fix `prettier-ignore` inside JSX ([#7877](https://togithub.com/prettier/prettier/pull/7877) by [@fisker](https://togithub.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://togithub.com/prettier/prettier/pull/7883) by [@thorn0](https://togithub.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://togithub.com/prettier/prettier/pull/7891) by [@sidharthv96](https://togithub.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://togithub.com/prettier/prettier/pull/7911) by [@bakkot](https://togithub.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://togithub.com/prettier/prettier/pull/7869) by [@sosukesuzuki](https://togithub.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://togithub.com/prettier/prettier/pull/7892) by [@sosukesuzuki](https://togithub.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://togithub.com/prettier/prettier/pull/7923) by [@DmitryGonchar](https://togithub.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://togithub.com/prettier/prettier/pull/7867) by [@fisker](https://togithub.com/fisker))
```html
____
```
##### Format `script` and `style` inside tags with a colon in the name ([#7916](https://togithub.com/prettier/prettier/pull/7916) by [@fisker](https://togithub.com/fisker))
```html
```
##### Other changes
- Workaround for `require.resolve` in prettier-vscode ([#7951](https://togithub.com/prettier/prettier/pull/7951) by [@thorn0](https://togithub.com/thorn0))
- Fix unstable Angular expression binding ([#7924](https://togithub.com/prettier/prettier/pull/7924) by [@fisker](https://togithub.com/fisker))
- Update `isSCSS` regex ([#7922](https://togithub.com/prettier/prettier/pull/7922) by [@fisker](https://togithub.com/fisker))
- Fix formatting of empty files ([#7921](https://togithub.com/prettier/prettier/pull/7921) by [@fisker](https://togithub.com/fisker))
### [`v2.0.2`](https://togithub.com/prettier/prettier/blob/master/CHANGELOG.md#202)
[Compare Source](https://togithub.com/prettier/prettier/compare/2.0.1...2.0.2)
[diff](https://togithub.com/prettier/prettier/compare/2.0.1...2.0.2)
##### 2.0 regressions
##### JavaScript: Fix formatting of pseudo-elements and pseudo-classes in styled-components template literals ([#7842](https://togithub.com/prettier/prettier/pull/7842) by [@thorn0](https://togithub.com/thorn0))
```jsx
// 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](https://togithub.com/prettier/prettier/pull/7836) by [@bakkot](https://togithub.com/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.
```ts
// 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](https://togithub.com/prettier/prettier/pull/7847))
See [#7846](https://togithub.com/prettier/prettier/issues/7846)
##### Other changes
##### TypeScript: Fix `prettier-ignore` in union types ([#7798](https://togithub.com/prettier/prettier/pull/7798) by [@thorn0](https://togithub.com/thorn0))
```ts
// Input
export type a =
// foo
| foo1&foo2
// prettier-ignore
| bar1&bar2
// baz
| baz1&baz2;
// Prettier 2.0.0
export type a =
// foo
| foo1&foo2
// prettier-ignore
// prettier-ignore
| (bar1 & bar2)
// baz
| (baz1 & baz2);
// Prettier 2.0.2
export type a =
// foo
| (foo1 & foo2)
// prettier-ignore
| bar1&bar2
// baz
| (baz1 & baz2);
```
### [`v2.0.1`](https://togithub.com/prettier/prettier/blob/master/CHANGELOG.md#201)
[Compare Source](https://togithub.com/prettier/prettier/compare/2.0.0...2.0.1)
[diff](https://togithub.com/prettier/prettier/compare/2.0.0...2.0.1)
##### API: Fix build script to not corrupt `import-fresh` module ([#7820](https://togithub.com/prettier/prettier/pull/7820) by [@thorn0](https://togithub.com/thorn0))
### [`v2.0.0`](https://togithub.com/prettier/prettier/blob/master/CHANGELOG.md#200)
[Compare Source](https://togithub.com/prettier/prettier/compare/1.19.1...2.0.0)
[diff](https://togithub.com/prettier/prettier/compare/1.19.1...2.0.0)
π [Release Notes](https://prettier.io/blog/2020/03/21/2.0.0.html)
Configuration
π Schedule: At any time (no schedule defined).
π¦ Automerge: Disabled by config. Please merge this manually once you are satisfied.
β» Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
π Ignore: Close this PR and you won't be reminded about this update again.
[ ] If you want to rebase/retry this PR, check this box.
This PR contains the following updates:
1.19.1
->2.3.1
Release Notes
prettier/prettier
### [`v2.3.1`](https://togithub.com/prettier/prettier/blob/master/CHANGELOG.md#231) [Compare Source](https://togithub.com/prettier/prettier/compare/2.3.0...2.3.1) [diff](https://togithub.com/prettier/prettier/compare/2.3.0...2.3.1) ##### Support TypeScript 4.3 ([#10945](https://togithub.com/prettier/prettier/pull/10945) by [@sosukesuzuki](https://togithub.com/sosukesuzuki)) ##### [`override` modifiers in class elements](https://devblogs.microsoft.com/typescript/announcing-typescript-4-3/#override) ```ts class Foo extends { override method() {} } ``` ##### [static index signatures (`[key: KeyType]: ValueType`) in classes](https://devblogs.microsoft.com/typescript/announcing-typescript-4-3/#static-index-signatures) ```ts class Foo { static [key: string]: Bar; } ``` ##### [`get` / `set` in type declarations](https://devblogs.microsoft.com/typescript/announcing-typescript-4-3/#separate-write-types) ```ts interface Foo { set foo(value); get foo(): string; } ``` ##### Preserve attributes order for element node ([#10958](https://togithub.com/prettier/prettier/pull/10958) by [@dcyriller](https://github.comdcyriller)) ```handlebars {{!-- Input --}}Configuration
π Schedule: At any time (no schedule defined).
π¦ Automerge: Disabled by config. Please merge this manually once you are satisfied.
β» Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
π Ignore: Close this PR and you won't be reminded about this update again.
This PR has been generated by WhiteSource Renovate. View repository job log here.