惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - Franky
N
Netflix TechBlog - Medium
Google Online Security Blog
Google Online Security Blog
月光博客
月光博客
量子位
酷 壳 – CoolShell
酷 壳 – CoolShell
V
V2EX
腾讯CDC
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 聂微东
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
M
MIT News - Artificial intelligence
Vercel News
Vercel News
The GitHub Blog
The GitHub Blog
Hugging Face - Blog
Hugging Face - Blog
博客园 - 【当耐特】
Apple Machine Learning Research
Apple Machine Learning Research
aimingoo的专栏
aimingoo的专栏
博客园 - 三生石上(FineUI控件)
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
MongoDB | Blog
MongoDB | Blog
H
Help Net Security
The Cloudflare Blog
Blog — PlanetScale
Blog — PlanetScale
F
Full Disclosure
G
Google Developers Blog
罗磊的独立博客
Jina AI
Jina AI
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Y
Y Combinator Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
J
Java Code Geeks
A
About on SuperTechFans
IT之家
IT之家
大猫的无限游戏
大猫的无限游戏
S
SegmentFault 最新的问题
有赞技术团队
有赞技术团队
GbyAI
GbyAI
雷峰网
雷峰网
T
The Blog of Author Tim Ferriss
The Register - Security
The Register - Security
U
Unit 42
D
Docker
Martin Fowler
Martin Fowler
L
LINUX DO - 热门话题
NISL@THU
NISL@THU
阮一峰的网络日志
阮一峰的网络日志
C
Cybersecurity and Infrastructure Security Agency CISA
博客园_首页
Google DeepMind News
Google DeepMind News

Prettier Blog

Prettier 3.8: Support for Angular v21.1 Prettier 3.7: Improved formatting consistency and new plugin features! Prettier 3.6: Experimental fast CLI and new OXC and Hermes plugins! Prettier 3.5: New objectWrap option, experimentalOperatorPosition option and TS config file support! Prettier 3.4: A lot of bug fixes Prettier 3.3: New Flow features and a lot of bug fixes Prettier 3.2: Support JSONC and Angular’s ICU expression Prettier's CLI: A Performance Deep Dive $20k Bounty was Claimed! Prettier 3.1: New experimental ternaries formatting and Angular control flow syntax! A curious case of the ternaries Prettier 3.0: Hello, ECMAScript Modules! Prettier 2.8: improve --cache CLI option and TypeScript 4.9 satisfies operator! Prettier 2.7: new --cache CLI option and TypeScript 4.7 syntax! Prettier 2.6: new singleAttributePerLine option and new JavaScript features! Prettier begins paying maintainers Prettier 2.5: TypeScript 4.5 and MDX v2 comment syntax! Prettier 2.3. In which assignments are consistent, short keys non-breaking, and Handlebars official Prettier for Ruby goes v1.0 🎉
Prettier 2.4: new bracketSameLine option and TypeScript 4.4 support!
Sosuke Suzuki · 2021-09-09 · via Prettier Blog

This release renames the jsxBracketSameLine option to bracketSameLine, which supports HTML, Vue, and Angular in addition to JSX. The old name has been deprecated.

We’ve also added support for TypeScript 4.4, including new syntax features such as class static blocks.

If you enjoy Prettier and would like to support our work, consider sponsoring us directly via our OpenCollective or by sponsoring the projects we depend on, including typescript-eslint, remark, and Babel.

Highlights

TypeScript

Support TypeScript 4.4 (#11426 by @sosukesuzuki)

Support TypeScript 4.4!

static Blocks in Classes

Class Static Blocks syntax is a Stage 4 ECMAScript proposal. See https://github.com/tc39/proposal-class-static-block for more details.

// Input

class Foo {

static count = 0;

// This is a static block:

static {

if (someCondition()) {

Foo.count++;

}

}

}

// Prettier 2.3

SyntaxError: Declaration expected. (5:9)

3 |

4 | // This is a static block:

> 5 | static {

| ^

6 | if (someCondition()) {

7 | Foo.count++;

8 | }

// Prettier 2.4

class Foo {

static count = 0;

// This is a static block:

static {

if (someCondition()) {

Foo.count++;

}

}

}

HTML

Replace jsxBracketSameLine option with bracketSameLine option (#11006 by @kurtztech)

Deprecate the jsxBracketSameLine option in favour of the new bracketSameLine option that will work for HTML, Angular, Vue, and JSX.

<!-- Input -->

<div id="foo-bar-baz"

class="bar-foo-baz"

title="a sample title"

data-foo="bar"

data-bar="baz">lorem ipsum dolor sit amet</div>

<!-- Prettier 2.3 -->

<div

id="foo-bar-baz"

class="bar-foo-baz"

title="a sample title"

data-foo="bar"

data-bar="baz"

>

lorem ipsum dolor sit amet

</div>

<!-- Prettier 2.4 -->

<!-- Options: `{bracketSameLine: true}` -->

<div

id="foo-bar-baz"

class="bar-foo-baz"

title="a sample title"

data-foo="bar"

data-bar="baz">

lorem ipsum dolor sit amet

</div>

Other Changes

JavaScript

Support parenthesized tagged template literals for styled components (#11246 by @sosukesuzuki)

// Input

const StyledComponent =

/** @type {import('styled-components').ThemedStyledFunction<'div',null,{overlap: boolean}>} */

(styled.div)`

position: fixed;

color: red;

`;

// Prettier 2.3

const StyledComponent =

/** @type {import('styled-components').ThemedStyledFunction<'div',null,{overlap: boolean}>} */

(styled.div)`

position: fixed;

color: red;

`;

// Prettier 2.4

const StyledComponent =

/** @type {import('styled-components').ThemedStyledFunction<'div',null,{overlap: boolean}>} */

(styled.div)`

position: fixed;

color: red;

`;

Count correctly regex literals in method chain arguments (#11299 by @sosukesuzuki)

// Input

foo1(/𠮟𠮟𠮟/).foo2(bar).foo3(baz);

foo1(/叱叱叱/).foo2(bar).foo3(baz);

// Prettier 2.3

foo1(/𠮟𠮟𠮟/)

.foo2(bar)

.foo3(baz);

foo1(/叱叱叱/).foo2(bar).foo3(baz);

// Prettier 2.4

foo1(/𠮟𠮟𠮟/)

.foo2(bar)

.foo3(baz);

foo1(/叱叱叱/)

.foo2(bar)

.foo3(baz);

Support hack-style pipeline proposal (#11335 by @sosukesuzuki)

The proposed hack-style pipeline syntax is now supported by Prettier. We are using % as the topic token, following the official explainer — although this may change in future releases as the proposal progresses.

As part of this change, support for the “smart” pipeline syntax has been removed. See our policy on non-standardized syntax for the rationale behind this decision.

// Input

const foo = fn() |> fn1(%) |> fn2(%);

// Prettier 2.3

SyntaxError: Unexpected token (1:25)

> 1 | const foo = fn() |> fn1(%) |> fn2(%);

| ^

2 |

// Prettier 2.4

const foo = fn() |> fn1(%) |> fn(%);

TypeScript

Fix formatting intersection types that include mapped types (#11247 by @sosukesuzuki)

// Input

type Example = {

[A in B]: T;

} & {

[A in B]: T;

};

// Prettier 2.3

type Example = {

[A in B]: T;

} &

{

[A in B]: T;

};

// Prettier 2.4

type Example = {

[A in B]: T;

} & {

[A in B]: T;

};

Flow

Always put a semicolon before Flow variance sigils (#11398 by @noppa)

// Input

class A {

+one = function() {};

-two = val();

+#privOne = val();

static +#privTwo = val();

}

// Prettier 2.3

class A {

+one = function() {}

-two = val()

+#privOne = val()

static +#privTwo = val()

}

// Prettier 2.4

class A {

+one = function() {};

-two = val();

+#privOne = val()

static +#privTwo = val()

}

SCSS

Consistently quote Sass modules strings (#11461 by @niksy)

// Input

@use "sass:math";

@forward "list";

// Prettier 2.3

@use "sass:math";

@forward "list";

// Prettier 2.4

@use 'sass:math';

@forward 'list';

CLI

Infer parser for .stylelintrc (#10924 by @SevenOutman)

A .stylelintrc file (without extension) is handled using json and yaml parsers.