You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何为Deno Fresh项目配置deno-fmt的换行符(LF/CRLF)行为?

解决Deno Fresh项目中deno-fmt换行符配置问题

deno-fmt的换行符行为由自身配置控制,和git的core.autocrlf无关(该设置仅处理Git提交/拉取时的换行符转换),你可以通过以下两种方式指定换行符:

1. 命令行参数临时指定

运行deno fmt时直接添加--newline参数,支持lf、crlf、auto三个选项:

  • 强制使用CRLF:deno fmt --newline crlf
  • 强制使用LF:deno fmt --newline lf
  • 自动适配系统默认换行符:deno fmt --newline auto

如果需要固定使用该配置,可以把命令添加到项目deno.json的tasks中:

{
  "tasks": {
    "fmt": "deno fmt --newline crlf"
  }
}

之后运行deno task fmt即可按配置格式化。

2. 通过deno配置文件全局指定

在项目根目录的deno.json或deno.jsonc中添加fmt配置块,定义默认换行符:

{
  "fmt": {
    "newline": "crlf"
  }
}

配置完成后,直接运行deno fmt就会自动使用你指定的换行符格式。

内容的提问来源于stack exchange,提问作者Shervin Ivari

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.05 08:22:06