NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
npm · #256 most downloaded on npm
Prettier is an opinionated code formatter
Last release 6 days ago
23 Sep 2026
Release timing varies
gaps range from 8 days to 5 months
Nearly every release is documented
notes for 59 of the last 60 stable releases
1 version withdrawn
withdrawn after publishing
10 years old
198 releases · first in 2017
diff 🔗 Release note
Nothing published for this version
One column per quarter.
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Update .d.ts files of plugins to use export default ... by @fisker in https://github.com/prettier/prettier/pull/14435
.d.ts files of plugins to use export default ... by @fisker in https://github.com/prettier/prettier/pull/14435Other changes since v2, see 3.0.0-alpha.1 release notes
Full Changelog: https://github.com/prettier/prettier/compare/3.0.0-alpha.5...3.0.0-alpha.6
Add .d.ts files by @sosukesuzuki in https://github.com/prettier/prettier/pull/14212
.d.ts files by @sosukesuzuki in https://github.com/prettier/prettier/pull/14212babel-ts parser by @fisker in https://github.com/prettier/prettier/pull/14391Other changes since v2, see 3.0.0-alpha.1 release notes
Full Changelog: https://github.com/prettier/prettier/compare/3.0.0-alpha.4...3.0.0-alpha.5
Remove support for Flow comment types by @thorn0 in https://github.com/prettier/prettier/pull/13687
resolveParser work like v2 by @fisker in https://github.com/prettier/prettier/pull/13732__debug apis to cjs version by @fisker in https://github.com/prettier/prettier/pull/13731Other changes since v2, see 3.0.0-alpha.1 release notes
Full Changelog: https://github.com/prettier/prettier/compare/3.0.0-alpha.3...3.0.0-alpha.4
Fix exports field in package.json file
exports field in package.json fileOther changes since v2, see 3.0.0-alpha.1 release notes
Full Changelog: https://github.com/prettier/prettier/compare/3.0.0-alpha.2...3.0.0-alpha.3
Other changes since v2, see `3.0.0-alpha.1` release notes
index.cjs fileOther changes since v2, see 3.0.0-alpha.1 release notes
Full Changelog: https://github.com/prettier/prettier/compare/3.0.0-alpha.1...3.0.0-alpha.2
If you are a plugin developer, please try this version and send us feedback! Feel free to ping @fisker if you have any questions about v3 migration.
If you are a plugin developer, please try this version and send us feedback! Feel free to ping @fisker if you have any questions about v3 migration.
exports field added to package.json
https://unpkg.com/browse/prettier@3.0.0-alpha.1/trailingComma to "all"embed method of a printer has now to match a completely new signature, added getVisitorKeys methodparsers passed to parsers.parse has been removedprettier.doc.builders.concat has been removedtextToDoc trims trailing hard lines nowFull Changelog: https://github.com/prettier/prettier/compare/2.7.1...3.0.0-alpha.1
Support plugins with async parsers
trailingComma to "all"embed method of a printer has now to match a completely new signature, added getVisitorKeys methodparsers passed to parsers.parse has been removedprettier.doc.builders.concat has been removedtextToDoc trims trailing hard lines nowIf you are a plugin developer, please try this version and send us your feedback!
Full Changelog: https://github.com/prettier/prettier/compare/2.7.1...3.0.0-alpha.0
This version is a republished version of v2.8.7. A bad version was accidentally published and it can't be unpublished, apologies for the churn.
This version is a republished version of v2.8.7. A bad version was accidentally published and it can't be unpublished, apologies for the churn.
Allow multiple decorators on same getter/setter
<!-- prettier-ignore -->
// Input
class A {
@decorator()
get foo () {}
@decorator()
set foo (value) {}
}
// Prettier 2.8.6
SyntaxError: Decorators cannot be applied to multiple get/set accessors of the same name. (5:3)
3 | get foo () {}
4 |
> 5 | @decorator()
| ^^^^^^^^^^^^
6 | set foo (value) {}
7 | }
// Prettier 2.8.7
class A {
@decorator()
get foo() {}
@decorator()
set foo(value) {}
}
Allow decorators on private members and class expressions
<!-- prettier-ignore -->
// Input
class A {
@decorator()
#privateMethod () {}
}
// Prettier 2.8.5
SyntaxError: Decorators are not valid here. (2:3)
1 | class A {
> 2 | @decorator()
| ^^^^^^^^^^^^
3 | #privateMethod () {}
4 | }
// Prettier 2.8.6
class A {
@decorator()
#privateMethod() {}
}
- Support TypeScript 5.0 🔗 Changelog
TypeScript 5.0 introduces two new syntactic features:
const modifiers for type parametersexport type * declarations<!-- prettier-ignore -->
// Input
class Person {
@(myDecoratorArray[0])
greet() {}
}
// Prettier 2.8.4
class Person {
@myDecoratorArray[0]
greet() {}
}
// Prettier 2.8.5
class Person {
@(myDecoratorArray[0])
greet() {}
}
TypeofTypeAnnotation to improve readability (#14458 by @fisker)<!-- prettier-ignore -->
// Input
type A = (typeof node.children)[];
// Prettier 2.8.4
type A = typeof node.children[];
// Prettier 2.8.5
type A = (typeof node.children)[];
max_line_length=off when parsing .editorconfig (#14516 by @josephfrazier)If an .editorconfig file is in your project and it sets max_line_length=off for the file you're formatting,
it will be interpreted as a printWidth of Infinity rather than being ignored
(which previously resulted in the default printWidth of 80 being applied, if not overridden by Prettier-specific configuration).
<!-- prettier-ignore -->
<!-- Input -->
<div className='HelloWorld' title={`You are visitor number ${ num }`} onMouseOver={onMouseOver}/>
<!-- Prettier 2.8.4 -->
<div
className="HelloWorld"
title={`You are visitor number ${num}`}
onMouseOver={onMouseOver}
/>;
<!-- Prettier 2.8.5 -->
<div className="HelloWorld" title={`You are visitor number ${num}`} onMouseOver={onMouseOver} />;
🔗 Changelog
readonly (#13427 by @thorn0, @sosukesuzuki)<!-- prettier-ignore -->
// Input
type Type = {
// comment
readonly [key in Foo];
};
// Prettier 2.8.3
type Type = {
readonly // comment
[key in Foo];
};
// Prettier 2.8.4
type Type = {
// comment
readonly [key in Foo];
};
This is a follow-up to #13930 to establish wrapping consistency between opening block statements and else blocks by grouping params in opening blocks. This causes params to break to a new line together and not be split across lines unless the length of params exceeds the print width. This also updates the else block wrapping to behave exactly the same as opening blocks.
<!-- prettier-ignore -->
{{! Input }}
{{#block param param param param param param param param param param as |blockParam|}}
Hello
{{else block param param param param param param param param param param as |blockParam|}}
There
{{/block}}
{{! Prettier 2.8.3 }}
{{#block
param
param
param
param
param
param
param
param
param
param
as |blockParam|
}}
Hello
{{else block param
param
param
param
param
param
param
param
param
param}}
There
{{/block}}
{{! Prettier 2.8.4 }}
{{#block
param param param param param param param param param param
as |blockParam|
}}
Hello
{{else block
param param param param param param param param param param
as |blockParam|
}}
There
{{/block}}
.sl/ (#14206 by @bolinfest)In Sapling SCM, .sl/ is the folder where it stores its state, analogous to .git/ in Git. It should be ignored in Prettier like the other SCM folders.
@satisfies in Closure-style type casts (#14262 by @fisker)<!-- prettier-ignore -->
// Input
const a = /** @satisfies {Record<string, string>} */ ({hello: 1337});
const b = /** @type {Record<string, string>} */ ({hello: 1337});
// Prettier 2.8.3
const a = /** @satisfies {Record<string, string>} */ { hello: 1337 };
const b = /** @type {Record<string, string>} */ ({ hello: 1337 });
// Prettier 2.8.4
const a = /** @satisfies {Record<string, string>} */ ({hello: 1337});
const b = /** @type {Record<string, string>} */ ({hello: 1337});
extends (#14279 by @fisker)<!-- prettier-ignore -->
// Input
type Foo<T> = T extends ((a) => a is infer R extends string) ? R : never;
// Prettier 2.8.3 (First format)
type Foo<T> = T extends (a) => a is infer R extends string ? R : never;
// Prettier 2.8.3 (Second format)
SyntaxError: '?' expected.
// Prettier 2.8.4
type Foo<T> = T extends ((a) => a is infer R extends string) ? R : never;
Support Angular 15.1 🔗 Changelog
Support Angular 15.1
See Angular v15.1.0 release note for details.
<!-- prettier-ignore -->
// Input
<app-test/>
// Prettier 2.8.2
SyntaxError: Only void and foreign elements can be self closed "app-test" (1:1)
> 1 | <app-test/>
| ^^^^^^^^^
2 |
// Prettier 2.8.3
<app-test />
🔗 Changelog
<!-- prettier-ignore -->
<!-- Input -->
We now don't strictly follow the release notes format suggested by [Keep a Changelog].
[Keep a Changelog]: https://example.com/
<!-- Prettier 2.8.1 -->
We now don't strictly follow the release notes format suggested by [Keep a Changelog].
[keep a changelog]: https://example.com/
<!--
^^^^^^^^^^^^^^^^^^ lowercased
-->
<!-- Prettier 2.8.2 -->
<Same as input>
<!-- prettier-ignore -->
{{! Input }}
<div />
<div></div>
<custom-component />
<custom-component></custom-component>
<i />
<i></i>
<Component />
<Component></Component>
{{! Prettier 2.8.1 }}
<div></div>
<div></div>
<custom-component></custom-component>
<custom-component></custom-component>
<i></i>
<i></i>
<Component />
<Component />
{{! Prettier 2.8.2 }}
<div />
<div></div>
<custom-component />
<custom-component></custom-component>
<i />
<i></i>
<Component />
<Component />
#13507 added support for custom block keywords used with else, but failed to allow block params. This updates printer-glimmer to allow block params with custom "else if"-like blocks.
<!-- prettier-ignore -->
{{! Input }}
{{#when isAtWork as |work|}}
Ship that
{{work}}!
{{else when isReading as |book|}}
You can finish
{{book}}
eventually...
{{else}}
Go to bed!
{{/when}}
{{! Prettier 2.8.1 }}
{{#when isAtWork as |work|}}
Ship that
{{work}}!
{{else when isReading}}
You can finish
{{book}}
eventually...
{{else}}
Go to bed!
{{/when}}
{{! Prettier 2.8.2 }}
{{#when isAtWork as |work|}}
Ship that
{{work}}!
{{else when isReading as |book|}}
You can finish
{{book}}
eventually...
{{else}}
Go to bed!
{{/when}}
<!-- prettier-ignore -->
/* Input */
$map: (
'one': (
'key': 'value',
),
'two': (
'key': 'value',
),
)
/* Prettier 2.8.1 */
$map: (
'one': (
'key': 'value',
),
'two': (
'key': 'value',
),
)
/* Prettier 2.8.2 */
$map: (
'one': (
'key': 'value',
),
'two': (
'key': 'value',
),
)
let[ (#14000, #14044 by @fisker, @thorn0)<!-- prettier-ignore -->
// Input
(let[0] = 2);
// Prettier 2.8.1
let[0] = 2;
// Prettier 2.8.1 (second format)
SyntaxError: Unexpected token (1:5)
> 1 | let[0] = 2;
| ^
2 |
// Prettier 2.8.2
(let)[0] = 2;
<!-- prettier-ignore -->
// Input
@variable: {
field: something;
};
// Prettier 2.8.1
@variable: {
field: something;
}; ;
// Prettier 2.8.2
@variable: {
field: something;
};
<!-- prettier-ignore -->
// Input
.unary_minus_single {
margin: -(@a);
}
.unary_minus_multi {
margin: 0 -(@a);
}
.binary_minus {
margin: 0 - (@a);
}
// Prettier 2.8.1
.unary_minus_single {
margin: - (@a);
}
.unary_minus_multi {
margin: 0 - (@a);
}
.binary_minus {
margin: 0 - (@a);
}
// Prettier 2.8.2
.unary_minus_single {
margin: -(@a);
}
.unary_minus_multi {
margin: 0 -(@a);
}
.binary_minus {
margin: 0 - (@a);
}
<!-- prettier-ignore -->
// Input
@var: {
preserveCase: 0;
};
// Prettier 2.8.1
@var: {
preservecase: 0;
};
// Prettier 2.8.2
@var: {
preserveCase: 0;
};
<!-- prettier-ignore -->
// Input
class A {
@dec()
// comment
accessor b;
}
// Prettier 2.8.1
class A {
@dec()
accessor // comment
b;
}
// Prettier 2.8.1 (second format)
class A {
@dec()
accessor; // comment
b;
}
// Prettier 2.8.2
class A {
@dec()
// comment
accessor b;
}
<!-- prettier-ignore -->
// Input
a as (typeof node.children)[number]
a as (typeof node.children)[]
a as ((typeof node.children)[number])[]
// Prettier 2.8.1
a as typeof node.children[number];
a as typeof node.children[];
a as typeof node.children[number][];
// Prettier 2.8.2
a as (typeof node.children)[number];
a as (typeof node.children)[];
a as (typeof node.children)[number][];
It was a regression in Prettier 2.6.0.
<!-- prettier-ignore -->
// Input
switch (state) {
default:
result = state; // no change
break;
}
// Prettier 2.8.1
switch (state) {
default: // no change
result = state;
break;
}
// Prettier 2.8.2
switch (state) {
default:
result = state; // no change
break;
}
babel-ts (#14049 by @sosukesuzuki)The bug that @babel/parser cannot parse auto accessors with type annotations has been fixed. So we now support it via babel-ts parser.
<!-- prettier-ignore -->
class Foo {
accessor prop: number;
}
<!-- prettier-ignore -->
// Input
const foo: bar</* comment */> = () => baz;
// Prettier 2.8.1
Error: Comment "comment" was not printed. Please report this error!
// Prettier 2.8.2
const foo: bar</* comment */> = () => baz;
ExpressionStatement instead of the whole statement (#14077 by @fisker)<!-- prettier-ignore -->
// Input
({}).toString.call(foo) === "[object Array]"
? foo.forEach(iterateArray)
: iterateObject(foo);
// Prettier 2.8.1
({}.toString.call(foo) === "[object Array]"
? foo.forEach(iterateArray)
: iterateObject(foo));
// Prettier 2.8.2
({}).toString.call(foo.forEach) === "[object Array]"
? foo.forEach(iterateArray)
: iterateObject(foo);
<!-- prettier-ignore -->
// Input
"use strict" /* comment */;
// Prettier 2.8.1 (with other js parsers except `babel`)
Error: Comment "comment" was not printed. Please report this error!
// Prettier 2.8.2
<Same as input>
<!-- prettier-ignore -->
// Input
function MyFunctionComponent() {
<button label=/*old*/"new">button</button>
}
// Prettier 2.8.1
Error: Comment "old" was not printed. Please report this error!
// Prettier 2.8.2
function MyFunctionComponent() {
<button label=/*old*/ "new">button</button>;
}
<!-- prettier-ignore -->
// Input
{0: 'value'}
// Prettier 2.8.1
{
0: "value"
}
// Prettier 2.8.2
{
"0": "value"
}
<!-- prettier-ignore -->
/* Input */
$foo: map-fn(
(
"#{prop}": inner-fn($first, $second),
)
);
/* Prettier 2.8.1 */
$foo: map-fn(("#{prop}": inner-fn($first $second)));
/* Prettier 2.8.2 */
$foo: map-fn(
(
"#{prop}": inner-fn($first, $second),
)
);
<!-- prettier-ignore -->
// Input
a {
color: @colors[@white];
}
// Prettier 2.8.1
a {
color: @colors[ @white];
}
// Prettier 2.8.2
<Same as input>
🔗 Changelog
<!-- prettier-ignore -->
// Input
$display-breakpoints: map-deep-merge(
(
"print-only": "only print",
"screen-only": "only screen",
"xs-only": "only screen and (max-width: #{map-get($grid-breakpoints, "sm")-1})",
),
$display-breakpoints
);
// Prettier 2.8.0
$display-breakpoints: map-deep-merge(
(
"print-only": "only print",
"screen-only": "only screen",
"xs-only": "only screen and (max-width: #{map-get($grid-breakpoints, " sm
")-1})",
),
$display-breakpoints
);
// Prettier 2.8.1
$display-breakpoints: map-deep-merge(
(
"print-only": "only print",
"screen-only": "only screen",
"xs-only": "only screen and (max-width: #{map-get($grid-breakpoints, "sm")-1})",
),
$display-breakpoints
);
Support for Auto Accessors Syntax landed in TypeScript 4.9.
(Doesn't work well with babel-ts parser)
<!-- prettier-ignore -->
class Foo {
accessor foo: number = 3;
}
diff 🔗 Release note
🔗 Changelog
<!-- prettier-ignore -->
# Input
"""
First line
Second Line
"""
type Person {
name: String
}
# Prettier 2.7.0
"""
First line
Second Line
"""
type Person {
name: String
}
# Prettier 2.7.1
"""
First line
Second Line
"""
type Person {
name: String
}
diff 🔗 Release note
🔗 Changelog
<!-- prettier-ignore -->
// Input
.background-gradient(@cut) {
background: linear-gradient(
to right,
@white 0%,
@white (@cut - 0.01%),
@portal-background @cut,
@portal-background 100%
);
}
// Prettier 2.6.1
TypeError: Cannot read properties of undefined (reading 'endOffset')
// Prettier 2.6.2
.background-gradient(@cut) {
background: linear-gradient(
to right,
@white 0%,
@white (@cut - 0.01%),
@portal-background @cut,
@portal-background 100%
);
}
meriyah to fix several bugs (#12567 by @fisker, fixes in meriyah by @3cp)Fixes bugs when parsing following valid code:
foo(await bar());
const regex = /.*/ms;
const element = <p>{/w/.test(s)}</p>;
class A extends B {
#privateMethod() {
super.method();
}
}
🔗 Changelog
loglevel when printing information (#12477 by @fisker)<!-- prettier-ignore -->
# Prettier 2.6.0
prettier --loglevel silent --find-config-path index.js
# Nothing printed
# Prettier 2.6.1
prettier --loglevel silent --help no-color
# .prettierrc
Fixes two problems when bundling our UMD files with webpack:
"`....__exportStar` is not a function" throws when running the bundles."Critical dependency: the request of a dependency is an expression".<!-- prettier-ignore -->
// Input
const foo =
doSomething<{ foo1: "foo1", foo2: "foo2", foo3: "foo3", foo4: "foo4", foo5: "foo5" }>();
// Prettier 2.6.0 (first)
const foo =
doSomething<{
foo1: "foo1";
foo2: "foo2";
foo3: "foo3";
foo4: "foo4";
foo5: "foo5";
}>();
// Prettier 2.6.0 (second)
const foo = doSomething<{
foo1: "foo1";
foo2: "foo2";
foo3: "foo3";
foo4: "foo4";
foo5: "foo5";
}>();
// Prettier 2.6.1
const foo = doSomething<{
foo1: "foo1";
foo2: "foo2";
foo3: "foo3";
foo4: "foo4";
foo5: "foo5";
}>();
Details: Prototype Pollution
🔗 Release note
🔗 Changelog
<!-- prettier-ignore -->
// Input
type Foo =
Foooooooooooooooooooooooooooooooooooooooooooooooooooooooooo extends []
? Foo3
: Foo4;
// Prettier 2.5.0
type Foo = Foooooooooooooooooooooooooooooooooooooooooooooooooooooooooo extends [
]
? Foo3
: Foo4;
// Prettier 2.5.0 (tailingCommma = all)
// Invalid TypeScript code
type Foo = Foooooooooooooooooooooooooooooooooooooooooooooooooooooooooo extends [
,
]
? Foo3
: Foo4;
// Prettier 2.5.1
type Foo =
Foooooooooooooooooooooooooooooooooooooooooooooooooooooooooo extends []
? Foo3
: Foo4;
A internal change in Prettier@v2.5.0 accidentally breaks the Jest inline snapshot test.
Prettier already supported this feature, but it converted empty named blocks to self-closing, which is not supported by the Glimmer compiler.
See: Glimmer's named blocks.
<!-- prettier-ignore -->
// Input
<Component>
<:named></:named>
</Component>
// Prettier 2.5.0
<Component>
<:named />
</Component>
// Prettier 2.5.1
<Component>
<:named></:named>
</Component>
diff 🔗 Release note
🔗 Changelog
@forward (#11482) (#11487 by @niksy)<!-- prettier-ignore -->
// Input
@forward "library" as btn-*;
// Prettier 2.4.0
@forward "library" as btn- *;
// Prettier 2.4.1
@forward "library" as btn-*;
debug-print-ast (#11514 by @sosukesuzuki)A new --debug-print-ast CLI flag for debugging.
diff Release note
changelog
<!-- prettier-ignore -->
$ ls
1.js 1.unknown
# Prettier 2.3.1
$ prettier . -l
1.js
$ prettier ./ -l
[error] No supported files were found in the directory: "./".
# Prettier 2.3.2
$ prettier ./ -l
1.js
Add parens when required.
<!-- prettier-ignore -->
// Input
type A = (T & S)['bar'];
type B = (T | S)['bar'];
type C = (?T)['bar'];
type D = (typeof x)['bar'];
type E = (string => void)['bar'];
// Prettier 2.3.1
type A = T & S["bar"];
type B = T | S["bar"];
type C = ?T["bar"];
type D = typeof x["bar"];
type E = (string) => void["bar"];
// Prettier 2.3.2
type A = (T & S)["bar"];
type B = (T | S)["bar"];
type C = (?T)["bar"];
type D = (typeof x)["bar"];
type E = ((string) => void)["bar"];
<!-- prettier-ignore -->
// Input
class D extends B {
constructor(override foo: string) {
super();
}
}
// Prettier 2.3.1
class D extends B {
constructor(foo: string) {
super();
}
}
// Prettier 2.3.2
class D extends B {
constructor(override foo: string) {
super();
}
}
Changelog
override modifiers in class elementsclass Foo extends {
override method() {}
}
[key: KeyType]: ValueType) in classesclass Foo {
static [key: string]: Bar;
}
get / set in type declarationsinterface Foo {
set foo(value);
get foo(): string;
}
<!-- prettier-ignore -->
{{!-- Input --}}
<MyComponent
{{! this is a comment for arg 1}}
@arg1="hello"
{{on "click" this.modify}}
@arg2="hello"
{{! this is a comment for arg 3}}
@arg3="hello"
@arg4="hello"
{{! this is a comment for arg 5}}
@arg5="hello"
...arguments
/>
{{!-- Prettier stable --}}
<MyComponent
@arg1="hello"
@arg2="hello"
@arg3="hello"
@arg4="hello"
@arg5="hello"
...arguments
{{on "click" this.modify}}
{{! this is a comment for arg 1}}
{{! this is a comment for arg 3}}
{{! this is a comment for arg 5}}
/>
{{!-- Prettier main --}}
<MyComponent
{{! this is a comment for arg 1}}
@arg1="hello"
{{on "click" this.modify}}
@arg2="hello"
{{! this is a comment for arg 3}}
@arg3="hello"
@arg4="hello"
{{! this is a comment for arg 5}}
@arg5="hello"
...arguments
/>
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).
<!-- prettier-ignore -->
// 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: ^^^^^^^^^^^^^^^
<!-- prettier-ignore -->
// Input
type FieldLayoutWith<
T extends string,
S extends unknown = { width: string }
> = {
type: T;
code: string;
size: S;
};
// Prettier stable
type FieldLayoutWith<T extends string, S extends unknown = { width: string }> =
{
type: T;
code: string;
size: S;
};
// Prettier main
type FieldLayoutWith<
T extends string,
S extends unknown = { width: string }
> = {
type: T;
code: string;
size: S;
};
<!-- prettier-ignore -->
// Input
const map: Map<
Function,
Map<string | void, { value: UnloadedDescriptor }>
> = new Map();
// Prettier stable
const map: Map<Function, Map<string | void, { value: UnloadedDescriptor }>> =
new Map();
// Prettier main
const map: Map<
Function,
Map<string | void, { value: UnloadedDescriptor }>
> = new Map();
<!-- prettier-ignore -->
// Input
longfunctionWithCall12("bla", foo, (thing: string): complex<type<something>> => {
code();
});
// Prettier stable
longfunctionWithCall12("bla", foo, (thing: string): complex<
type<something>
> => {
code();
});
// Prettier main
longfunctionWithCall12(
"bla",
foo,
(thing: string): complex<type<something>> => {
code();
}
);
<!-- prettier-ignore -->
// 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;
}>();
override modifiers (#10961 by @sosukesuzuki)<!-- prettier-ignore -->
// Input
class Foo extends Bar {
abstract override foo: string;
}
// Prettier stable
class Foo extends Bar {
override abstract foo: string;
}
// Prettier main
class Foo extends Bar {
abstract override foo: string;
}
diff 🔗 Release Notes
🔗 Changelog
<!-- prettier-ignore -->
// 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");
}
};
# 2.2.0 diff 🔗 Release Notes
🔗Changelog
<!-- prettier-ignore -->
# Input
type Query {
someQuery(id: ID!, someOtherData: String!): String! @deprecated @isAuthenticated
versions: Versions!
}
# Prettier stable
type Query {
someQuery(id: ID!, someOtherData: String!): String!
@deprecated
@isAuthenticated
versions: Versions!
}
# Prettier master
type Query {
someQuery(id: ID!, someOtherData: String!): String!
@deprecated
@isAuthenticated
versions: Versions!
}
<!-- prettier-ignore -->
// Input
styled.div`
// prettier-ignore
@media (aaaaaaaaaaaaa) {
z-index: ${(props) => (props.isComplete ? '1' : '0')};
}
`;
styled.div`
${props => getSize(props.$size.xs)}
${props => getSize(props.$size.sm, 'sm')}
${props => getSize(props.$size.md, 'md')}
`;
// Prettier stable
styled.div`
// prettier-ignore
@media (aaaaaaaaaaaaa) {
z-index: ${(props) =>
props.isComplete ? "1" : "0"};
}
`;
styled.div`
${(props) => getSize(props.$size.xs)}
${(props) => getSize(props.$size.sm, "sm")}
${(props) =>
getSize(props.$size.md, "md")}
`;
// Prettier master
styled.div`
// prettier-ignore
@media (aaaaaaaaaaaaa) {
z-index: ${(props) => (props.isComplete ? "1" : "0")};
}
`;
styled.div`
${(props) => getSize(props.$size.xs)}
${(props) => getSize(props.$size.sm, "sm")}
${(props) => getSize(props.$size.md, "md")}
`;
yaml-unist-parser by @ikatyang)<!-- prettier-ignore -->
# Input
- a
# Should indent
- bb
---
- a: a
b: b
# Should print one empty line before
- another
# Prettier stable
- a
# Should indent
- bb
---
- a: a
b: b
# Should print one empty line before
- another
# Prettier master
- a
# Should indent
- bb
---
- a: a
b: b
# Should print one empty line before
- another
🔗Changelog
<!-- prettier-ignore -->
<!-- Input -->
---
layout: foo
---
Test <a
href="https://prettier.io">abc</a>.
<!-- Prettier stable -->
TypeError: Cannot read property 'end' of undefined
...
<!-- Prettier master -->
---
layout: foo
---
Test <a href="https://prettier.io">abc</a>.
...infer T (#9044 by @fisker)<!-- prettier-ignore -->
// Input
type Tail<T extends any[]> = T extends [infer U, ...infer R] ? R : never;
// Prettier stable
type Tail<T extends any[]> = T extends [infer U, ...(infer R)] ? R : never;
// Prettier master
type Tail<T extends any[]> = T extends [infer U, ...infer R] ? R : never;
style[lang="sass"] (#9051 by @fisker)<!-- prettier-ignore -->
<!-- Input -->
<style lang="sass">
.hero
@include background-centered
</style>
<!-- Prettier stable -->
<style lang="sass">
.hero @include background-centered;
</style>
<!-- Prettier master -->
<style lang="sass">
.hero
@include background-centered
</style>
src attribute format (#9052, #9055 by @fisker)<!-- prettier-ignore -->
<!-- Input -->
<custom lang="markdown" src="./foo.md"></custom>
<custom lang="markdown" src="./foo.md" />
<custom lang="markdown" />
<!-- Prettier stable -->
<custom lang="markdown" src="./foo.md">
</custom>
<custom lang="markdown" src="./foo.md"
/>
<custom lang="markdown"
/>
<!-- Prettier master -->
<custom lang="markdown" src="./foo.md"></custom>
<custom lang="markdown" src="./foo.md" />
<custom lang="markdown" />
diff 🔗 Release Notes
🔗 Changelog
:extend (#7984 by @fisker)<!-- prettier-ignore -->
// 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
);
}
resolve if builtin require.resolve is overridden (#8072 by @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.
🔗 Changelog
🔗 Changelog
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>;
<!-- 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;
}
`;
<!-- 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
<!-- 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();
<!-- 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;
<!-- 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
...,
};
<!-- 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
...
}
<!-- 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>
script and style 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>
🔗 Changelog
<!-- 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 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;
};
See #7846
prettier-ignore in union types (#7798 by @thorn0)<!-- prettier-ignore -->
// 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);
🔗 Changelog
diff 🔗 Release Notes
🔗 Changelog
--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;
<!-- 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
> => {};
🔗 Release Notes
🔗 Changelog
🔗 Changelog
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";
}
Config: Match dotfiles in config overrides (#6194 by @duailibe)
When using overrides in the config file, Prettier was not matching dotfiles (files that start with .). This was fixed in 1.18.1
🔗 Release Notes
🔗 Changelog
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}}
JavaScript: Improved multiline closure compiler typecast comment detection (#6070 by @yangsu)
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,
});
🔗 Release Notes
🔗 Changelog
API: Fix prettier.getSupportInfo() reporting babel parser for older versions of Prettier. (#5826 by @azz)
In version 1.16.0 of Prettier, the babylon parser was renamed to babel. Unfortunately this lead to a minor breaking change: prettier.getSupportInfo('1.15.0') would report that it supported babel, not babylon, which breaks text-editor integrations. This has now been fixed.
🔗 Changelog
TypeScript: Revert "Update typescript-estree to new package name" (#5818 by @ikatyang)
There's an internal change introduced in Prettier 1.16.2,
which updated typescript-estree to its new package name,
but unfortunately it broke the output
so we reverted it as a temporary workaround for now.
<!-- prettier-ignore -->
// Input
export default {
load<K, T>(k: K, t: T) {
return {k, t};
}
}
// Output (Prettier 1.16.2)
export default {
load(k: K, t: T) {
return { k, t };
}
};
// Output (Prettier 1.16.3)
export default {
load<K, T>(k: K, t: T) {
return { k, t };
}
};
🔗 Changelog
CLI: Fix CI detection to avoid unwanted TTY behavior (#5804 by @kachkaev)
In Prettier 1.16.0 and 1.16.1, --list-different and --check logged every file in some CI environments, instead of just unformatted files.
This unwanted behavior is now fixed.
HTML: Do not format non-normal whitespace as normal whitespace (#5797 by @ikatyang)
Previously, only non-breaking whitespaces (U+00A0) are marked as non-normal whitespace, which means other non-normal whitespaces such as non-breaking narrow whitespaces (U+202F) could be formatted as normal whitespaces, which breaks the output. We now follow the spec to exclude all non-ASCII whitespace from whitespace normalization.
(· represents a non-breaking narrow whitespace)
<!-- prettier-ignore -->
<!-- Input -->
Prix·:·32·€
<!-- Output (Prettier 1.16.1) -->
Prix : 32 €
<!-- Output (Prettier 1.16.2) -->
Prix·:·32·€
JavaScript: Fix record type cast comment detection (#5793 by @yangsu)
Previously, type cast comments with record types were ignored and prettier stripped the subsequent parens. Prettier 1.16.2 handles these cases correctly.
<!-- prettier-ignore -->
// Input
const v = /** @type {{key: number}} */ (value);
// Output (Prettier 1.16.1)
const v = /** @type {{key: number}} */ value;
// Output (Prettier 1.16.2)
const v = /** @type {{key: number}} */ (value);
🔗 Changelog
JavaScript: Do not format functions with arguments as react hooks (#5778 by @SimenB)
The formatting added in Prettier 1.16 would format any function receiving an arrow function and an array literal to match React Hook's documentation. Prettier will now format this the same as before that change if the arrow function receives any arguments.
<!-- prettier-ignore -->
// Input
["red", "white", "blue", "black", "hotpink", "rebeccapurple"].reduce(
(allColors, color) => {
return allColors.concat(color);
},
[]
);
// Output (Prettier 1.16.0)
["red", "white", "blue", "black", "hotpink", "rebeccapurple"].reduce((
allColors,
color
) => {
return allColors.concat(color);
}, []);
// Output (Prettier 1.16.1)
["red", "white", "blue", "black", "hotpink", "rebeccapurple"].reduce(
(allColors, color) => {
return allColors.concat(color);
},
[]
);
JavaScript: Add necessary parentheses for decorators (#5785 by @ikatyang)
Parentheses for decorators with nested call expressions are optional for legacy decorators but they're required for decorators in the current proposal.
<!-- prettier-ignore -->
// Input
class X {
@(computed().volatile())
prop
}
// Output (Prettier 1.16.0)
class X {
@computed().volatile()
prop
}
// Output (Prettier 1.16.1)
class X {
@(computed().volatile())
prop
}
TypeScript: Stable parentheses for function type in the return type of arrow function (#5790 by @ikatyang)
There's a regression introduced in 1.16 that parentheses for function type in the return type of arrow function were kept adding/removing. Their parentheses are always printed now.
<!-- prettier-ignore -->
// Input
const foo = (): (() => void) => (): void => null;
const bar = (): () => void => (): void => null;
// First Output (Prettier 1.16.0)
const foo = (): () => void => (): void => null;
const bar = (): (() => void) => (): void => null;
// Second Output (Prettier 1.16.0)
const foo = (): (() => void) => (): void => null;
const bar = (): () => void => (): void => null;
// Output (Prettier 1.16.1)
const foo = (): (() => void) => (): void => null;
const bar = (): (() => void) => (): void => null;
MDX: Correctly recognize inline JSX (#5783 by @ikatyang)
Previously, some inline JSXs are wrongly recognized as block HTML/JSX, which causes unexpected behaviors. This issue is now fixed.
<!-- prettier-ignore -->
<!-- Input -->
_foo <InlineJSX /> bar_
<!-- Output (Prettier 1.16.0) -->
_foo
<InlineJSX /> bar_
<!-- Output (Prettier 1.16.1) -->
_foo <InlineJSX /> bar_
[🔗 Release Notes]
🔗 Changelog
htm (#5565)html templates (#5544)module into namespace and break/hug their body correctly (#5551)// prettier-ignore (#5469)<! ... >/<? ... > (#5565)<script> (#5527)<textarea> are sensitive (#5468)<pre> correctly (#5473)then and else in *ngIf (#5542)slot-scope correctly (#5563)--- (#5502)ignored field correctly in .getFileInfo() with absolute filePath (#5570).js config files did not respect .clearConfigCache() (#5558)unset in .editorconfig (#5550)0 for --list-different + --write (#5512)🔗 Changelog
createSelector as function composition (#5430)extends (#5432)module and namespace correctly (#5432)<pre> with interpolation (#5400)<template> with unknown lang (#5388)+ (#5405)v-on attribute value (#5418)Your coding agent can read these notes before it upgrades. Set up the MCP server →