Prettier 1.19 发布,前端代码格式化工具

Prettier 1.19 已经发布,主要更新内容如下:

CLI

  • 修复 1.19.0 版本中 --stdin 回归
// Prettier stable
$ echo "test" | prettier --stdin --parser babel
[error] regeneratorRuntime is not defined

// Prettier master
$ echo "test" | prettier --stdin --parser babel
test;

 TypeScript

  • 修复联合类型格式化为箭头函数返回类型
// 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
> => {};

请见发布说明

猜你喜欢

转载自www.oschina.net/news/111216/prettier-1-19-released