Biomejs,一个用于格式化和检查 Web 项目的工具链

我发现 t3-env 使用 biomejs 进行 linting 目的。本文概述了 biomejs 以及 t3-env 中的用法。

biome.js

biome.js 是一个适用于您的 web 项目的工具链。它有助于格式化和检查您的项目。

快速开始

安装

npm install - save-dev - save-exact @biomejs/biome

2.配置

npx @biomejs/biome init

当您运行上述命令时,它会自动创建 biome.json 文件。以下是运行

时默认生成的代码上面的命令在biome.json中。

{ "$schema": "https://biomejs.dev/schemas/1.9.4/schema.json", "vcs": { "enabled": false, "clientkind": "git", "useignorefile": false }, "files": { "ignoreunknown": false, "ignore": [] }, "formatter": { "enabled": true, "indentstyle": "tab" }, "organizeimports": { "enabled": true }, "linter": { "enabled": true, "rules": { "recommended": true } }, "javascript": { "formatter": { "quotestyle": "double" } }}

linter.enabled: true 启用linter 和rules.recommished: true 启用推荐规则。这对应于默认设置。

默认情况下启用格式化,但您可以通过显式使用 formatter.enabled: false 来禁用它。

3.生物群系命令

a.格式

您可以使用带有 — write 选项的 format 命令来格式化文件和目录:

npx @biomejs/biome format - write 

b.棉绒

您可以使用带有 — write 选项的 lint 命令对文件和目录进行 lint 和应用安全修复:

npx @biomejs/biome lint - write 

c.检查

您可以通过利用检查命令来运行格式和链接:

npx @biomejs/biome check - write 

biome.js 在 t3-env 中的使用

package.json 中的脚本

"lint": "biome check .","lint:fix": "biome check . - apply",

这被发现使用了应用格式和 linting 的 check cli 命令。不过有一个变体,lint 只检查 linting 问题,但是当你执行 lint:fix 时,它是用 — apply 执行的。

— apply — alias for — write,写入安全修复、格式化和导入排序(已弃用,使用 — write)

2.生物群落.json

{ "$schema": "https://biomejs.dev/schemas/1.5.3/schema.json", "organizeImports": { "enabled": true }, "formatter": { "enabled": true, "indentWidth": 2, "indentStyle": "space" }, "linter": { "enabled": true, "rules": { "recommended": true, "a11y": { "noSvgWithoutTitle": "off", "useButtonType": "off", "useAltText": "off" }, "complexity": { "noBannedTypes": "off" }, "style": { "useImportType": "error", "useExportType": "error" } } }, "overrides": [ { "include": ["**/*.test.ts"], "linter": { "rules": { "suspicious": { "noExplicitAny": "off" } } } } ], "vcs": { "enabled": true, "clientKind": "git", "useIgnoreFile": true }}

关于我们:

在 thinkthroo,我们研究大型开源项目并提供架构指南。我们开发了使用 tailwind 构建的可重用组件,您可以在项目中使用它们。我们提供 next.js、react 和 node 开发服务。

与我们预约会面讨论您的项目。

Biomejs,一个用于格式化和检查 Web 项目的工具链

参考资料:

1. https://biomejs.dev/

2. https://github.com/t3-oss/t3-env/blob/main/biome.json

3. https://github.com/t3-oss/t3-env/blob/main/package.json#l10

以上就是Biomejs,一个用于格式化和检查 Web 项目的工具链的详细内容,更多请关注创想鸟其它相关文章!

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 chuangxiangniao@163.com 举报,一经查实,本站将立刻删除。
发布者:程序猿,转转请注明出处:https://www.chuangxiangniao.com/p/1496965.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2025年12月19日 19:04:13
下一篇 2025年12月19日 19:04:25

相关推荐

发表回复

登录后才能评论
关注微信