更新日志
Biome 更新日志
Section titled “Biome 更新日志”¥Biome changelog
此项目遵循 语义版本控制。由于 Biome 作为工具链的性质,可能不清楚哪些更改被视为主要更改、次要更改或补丁。阅读我们的 变更分类指南。
¥This project follows Semantic Versioning. Due to the nature of Biome as a toolchain, it can be unclear what changes are considered major, minor, or patch. Read our guidelines to categorize a change.
新条目必须放置在名为 Unreleased 的部分中。阅读我们的 编写优秀变更日志条目的指南。
¥New entries must be placed in a section entitled
Unreleased. Read our guidelines for writing a good changelog entry.
v1.9.4(2024-10-17)
Section titled “v1.9.4(2024-10-17)”¥Analyzer
¥Bug fixes
-
实现 GraphQL 抑制操作。由 @vohoanglong0107 贡献
¥Implement GraphQL suppression action. Contributed by @vohoanglong0107
-
改进未使用的抑制注释的提示信息。贡献者:@dyc3
¥Improved the message for unused suppression comments. Contributed by @dyc3
-
修复 #4228,其中规则
a11y/noInteractiveElementToNoninteractiveRole错误地将非交互式元素报告为role。贡献者:@eryue0220¥Fix #4228, where the rule
a11y/noInteractiveElementToNoninteractiveRoleincorrectly reports arolefor non-interactive elements. Contributed by @eryue0220 -
noSuspiciousSemicolonInJsx现在会捕获 React 片段中可疑的分号。由 @vasucp1207 贡献¥
noSuspiciousSemicolonInJsxnow catches suspicious semicolons in React fragments. Contributed by @vasucp1207 -
语法规则
noTypeOnlyImportAttributes现在会忽略.cts文件(#4361)。¥The syntax rule
noTypeOnlyImportAttributesnow ignores.ctsfiles (#4361).自 TypeScript 5.3 起,类型限定的导入可以与启用 CommonJS 的文件中的 import 属性关联。查看 TypeScript 文档。
¥Since TypeScript 5.3, type-only imports can be associated to an import attribute in CommonJS-enabled files. See the TypeScript docs.
以下代码不再被报告为语法错误:
¥The following code is no longer reported as a syntax error:
import type { TypeFromRequire } from "pkg" with {"resolution-mode": "require"};请注意,此方法仅允许用于以
cts扩展名结尾的文件。¥Note that this is only allowed in files ending with the
ctsextension.贡献者:@Conaclos
¥Contributed by @Conaclos
¥Enhancements
-
--summary报告器现在也会报告解析诊断信息。贡献者:@ematipico¥The
--summaryreporter now reports parsing diagnostics too. Contributed by @ematipico -
GritQL 查询性能提升约 25-30%。贡献者:@arendjr
¥Improved performance of GritQL queries by roughly 25-30%. Contributed by @arendjr
¥Configuration
¥Bug fixes
-
修复了 JSON 模式将 lint 规则选项标记为必填的问题。贡献者:@ematipico
¥Fix an issue where the JSON schema marked lint rules options as mandatory. Contributed by @ematipico
¥Editors
¥Formatter
¥Bug fixes
-
修复 #4121。打印多行字符串时,注意行宽。贡献者:@ah-yu
¥Fix #4121. Respect line width when printing multiline strings. Contributed by @ah-yu
-
修复 #4384。在任何情况下,请将
@charset放在双引号内,以符合 CSS 语法规则。贡献者:@fireairforce¥Fix #4384. Keep
@charsetdobule quote under any situation for css syntax rule. Contributed by @fireairforce
JavaScript API
Section titled “JavaScript API”Linter
Section titled “Linter”¥New features
-
添加 useGuardForIn。贡献者:@fireairforce
¥Add useGuardForIn. Contributed by @fireairforce
-
添加 noDocumentCookie。贡献者: @tunamaguro
¥Add noDocumentCookie. Contributed by @tunamaguro
-
添加 noDocumentImportInPage。贡献者:@kaioduarte
¥Add noDocumentImportInPage. Contributed by @kaioduarte
-
添加 noDuplicateProperties。贡献者:@togami2864
¥Add noDuplicateProperties. Contributed by @togami2864
-
添加 noHeadElement。贡献者:@kaioduarte
¥Add noHeadElement. Contributed by @kaioduarte
-
添加 noHeadImportInDocument。贡献者:@kaioduarte
¥Add noHeadImportInDocument. Contributed by @kaioduarte
-
添加 noImgElement。贡献者:@kaioduarte
¥Add noImgElement. Contributed by @kaioduarte
-
添加 noUnknownTypeSelector。贡献者:@Kazuhiro-Mimaki
¥Add noUnknownTypeSelector. Contributed by @Kazuhiro-Mimaki
-
添加 useAtIndex。贡献者:@GunseiKPaseri
¥Add useAtIndex. Contributed by @GunseiKPaseri
-
添加 noUselessStringRaw。贡献者:@fireairforce
¥Add noUselessStringRaw. Contributed by @fireairforce
-
添加 nursery/useCollapsedIf。贡献者:@siketyan
¥Add nursery/useCollapsedIf. Contributed by @siketyan
-
添加 useGoogleFontDisplay。贡献者:@kaioduarte
¥Add useGoogleFontDisplay. Contributed by @kaioduarte
-
添加 useExportsLast。贡献者:@tommymorgan
¥Add useExportsLast. Contributed by @tommymorgan
¥Bug Fixes
-
Biome 现在不会在遇到包含多字节字符 (#4181) 的字符串时崩溃。
¥Biome no longer crashes when it encounters a string that contain a multibyte character (#4181).
此修复程序修复了 Biome 1.9.3 版本中引入的一个回归问题。该回归问题影响了以下代码检查规则:
¥This fixes a regression introduced in Biome 1.9.3 The regression affected the following linter rules:
-
nursery/useSortedClasses -
nursery/useTrimStartEnd -
style/useTemplate -
suspicious/noMisleadingCharacterClass
贡献者:@Conaclos
¥Contributed by @Conaclos
-
-
修复 #4190,该规则在
var()函数(该函数以换行符结尾)中使用时,错误地将变量报告为缺失。贡献者:@ematipico¥Fix #4190, where the rule
noMissingVarFunctionwrongly reported a variable as missing when used inside avar()function that was a newline. Contributed by @ematipico -
修复 #4041。现在如果
className仅由内联变量组成,则不会触发规则useSortedClasses。贡献者:@ematipico¥Fix #4041. Now the rule
useSortedClasseswon’t be triggered ifclassNameis composed only by inlined variables. Contributed by @ematipico -
useImportType 和 useExportType 现在会报告无用的内联类型限定符 (#4178)。
¥useImportType and useExportType now report useless inline type qualifiers (#4178).
现提出以下修复方案:
¥The following fix is now proposed:
import type { type A, B } from "";import type { A, B } from "";export type { type C, D };export type { C, D };贡献者:@Conaclos
¥Contributed by @Conaclos
-
useExportType 现在报告未分组的
export from。¥useExportType now reports ungrouped
export from.现提出以下修复方案:
¥The following fix is now proposed:
export { type A, type B } from "";export type { A, B } from "";贡献者:@Conaclos
¥Contributed by @Conaclos
-
noVoidTypeReturn 现在接受返回位置的
void表达式 (#4173)。¥noVoidTypeReturn now accepts
voidexpressions in return position (#4173).以下代码现在被接受:
¥The following code is now accepted:
function f(): void {return void 0;}贡献者:@Conaclos
¥Contributed by @Conaclos
-
noUselessFragments 现在能够正确处理包含 HTML 转义(例如
)的表达式转义片段 ({ ... }) (#4059)。¥noUselessFragments now correctly handles fragments containing HTML escapes (e.g.
) inside expression escapes{ ... }(#4059).以下代码不再被报告:
¥The following code is no longer reported:
function Component() {return (<div key={index}>{line || <> </>}</div>)}贡献者:@fireairforce
¥Contributed by @fireairforce
-
当另一个参数具有同名构造函数类型时,noUnusedFunctionParameters 和 noUnusedVariables 不再将某个参数报告为未使用 (#4227)。
¥noUnusedFunctionParameters and noUnusedVariables no longer reports a parameter as unused when another parameter has a constructor type with the same parameter name (#4227).
在以下代码中,
name参数不再被报告为未使用。¥In the following code, the
nameparameter is no longer reported as unused.export class Foo {bar(name: string, _class: new (name: string) => any) {return name}}贡献者:@Conaclos
¥Contributed by @Conaclos
-
noUndeclaredDependencies 现在支持使用点号的依赖名称。贡献者:@Conaclos
¥noUndeclaredDependencies now accepts dependency names with dots. Contributed by @Conaclos
-
useFilenamingConvention 现在可以正确处理重命名的导出类型 (#4254)。
¥useFilenamingConvention now correctly handles renamed exports (#4254).
该规则允许将文件名命名为模块的导出项之一。例如,包含以下导出的文件可以命名为
Button。¥The rule allows the filename to be named as one of the exports of the module. For instance, the file containing the following export can be named
Button.class Button {}export { Button }该规则现在可以正确处理导出对象的重命名。例如,包含以下导出项的文件只能命名为
Button。以前,该规则期望文件名为A。¥The rule now correctly handles the renaming of an export. For example, the file containing the following export can only be named
Button. Previously the rule expected the file to be namedA.class A {}export { A as Button }贡献者:@Conaclos
¥Contributed by @Conaclos
-
useConsistentMemberAccessibility 现在会忽略私有类成员,例如
#property(#4276)。贡献者:@Conaclos¥useConsistentMemberAccessibility now ignore private class members such as
#property(#4276). Contributed by @Conaclos -
noUnknownFunction 正确处理
calc-size函数(#4212)。¥noUnknownFunction correctly handles
calc-sizefunction (#4212).以下代码
calc-size不再被报告为未知代码:¥The following code
calc-sizeis no longer reported as unknown:.a { height: calc-size(0px); }贡献者:@fireairforce
¥Contributed by @fireairforce
-
useNamingConvention 现在允许配置只读索引签名的约定。
¥useNamingConvention now allows configuring conventions for readonly index signatures.
贡献者:@sepruko
¥Contributed by @sepruko
-
noDuplicateCustomProperties 现在能够正确处理自定义属性并忽略非自定义属性。之前,该规则错误地报告所有属性(包括非自定义属性)的重复项。贡献者:@togami2864
¥noDuplicateCustomProperties now correctly handles custom properties and ignores non-custom properties. Previously, the rule incorrectly reported duplicates for all properties, including non-custom ones. Contributed by @togami2864
¥Parser
¥Bug Fixes
-
CSS 解析器现在接受标识符中的更多 emoji 表情符号 (#3627)。
¥The CSS parser now accepts more emoji in identifiers (#3627).
浏览器支持的表情符号数量超过了标准允许的数量。Biome 现在接受这些额外的表情符号。
¥Browsers accept more emoji than the standard allows. Biome now accepts these additional emojis.
以下代码现在可以被正确解析:
¥The following code is now correctly parsed:
p {--✨-color: red;color: var(--✨-color);}贡献者:@Conaclos
¥Contributed by @Conaclos
-
新增对解析 Import Types(#2115) 中的 TypeScript
resolution-mode的支持:¥Add support for parsing typescript’s
resolution-modein Import Types(#2115)export type Fs = typeof import('fs', { with: { 'resolution-mode': 'import' } });export type TypeFromRequire =import("pkg", { with: { "resolution-mode": "require" } }).TypeFromRequire;export type TypeFromImport =import("pkg", { with: { "resolution-mode": "import" } }).TypeFromImport;贡献者:@fireairforce
¥Contributed by @fireairforce
v1.9.3(2024-10-01)
Section titled “v1.9.3(2024-10-01)”¥New features
-
匹配函数或方法的 GritQL 查询现在也将匹配异步函数或方法。
¥GritQL queries that match functions or methods will now match async functions or methods as well.
如果这不是你想要的结果,你可以将
async关键字(或其缺失)捕获到元变量中,并断言其为空:¥If this is not what you want, you can capture the
asynckeyword (or its absence) in a metavariable and assert its emptiness:$async function foo() {} where $async <: .贡献者:@arendjr
¥Contributed by @arendjr
¥Bug fixes
-
修复 #4077:Grit 查询不再需要匹配语句末尾的分号。贡献者:@arendjr
¥Fix #4077: Grit queries no longer need to match the statement’s trailing semicolon. Contributed by @arendjr
-
修复 #4102。现在,在使用
--write/--fix时,CLI 命令lint不会返回错误代码。贡献者:@ematipico¥Fix #4102. Now the CLI command
lintdoesn’t exit with an error code when using--write/--fix. Contributed by @ematipico
¥Configuration
¥Bug fixes
-
修复 #4125,其中
noLabelWithoutControl选项被错误地标记为必填项。贡献者:@ematipico¥Fix #4125, where
noLabelWithoutControloptions where incorrectly marked as mandatory. Contributed by @ematipico
¥Editors
-
修复了使用默认配置时 CSS 文件无法正确进行代码检查的问题。贡献者:@ematipico
¥Fix a case where CSS files weren’t correctly linted using the default configuration. Contributed by @ematipico
¥Bug fixes
-
修复 #4116。统一 LSP 代码操作类型。由 @vitallium 贡献
¥Fix #4116. Unify LSP code action kinds. Contributed by @vitallium
¥Formatter
¥Bug fixes
-
修复了 #3924 中导致 GraphQL 格式化程序在包含空行的块注释中崩溃的问题。由 @vohoanglong0107 贡献
¥Fix #3924 where GraphQL formatter panics in block comments with empty line. Contributed by @vohoanglong0107
-
修复 #3364 中
useSelfClosingElements规则强制script标签自闭合的问题。之前,此规则适用于所有元素,且无法对原生 HTML 元素禁用。¥Fix #3364 where the
useSelfClosingElementsrule forces thescripttag to be self-closing. Previously, this rule applies to all elements and cannot be disabled for native HTML elements.现在,该规则接受一个
ignoreHtmlElements选项,当设置为true时,它会忽略原生 HTML 元素,并允许它们不是自闭合的。¥Now, this rule accepts a
ignoreHtmlElementsoption, which when set totrue, ignores native HTML elements and allows them to be non-self-closing.贡献者:@abidjappie
¥Contributed by @abidjappie
-
修复了
url()函数内部原始值未被正确修剪的问题。¥Fix a case where raw values inside
url()functions weren’t properly trimmed..value {background: url(whitespace-around-string);background: url(whitespace-around-string);}贡献者:@ematipico
¥Contributed by @ematipico
-
修复 #4076 中媒体查询格式不正确的问题:
¥Fixed #4076, where a media query wasn’t correctly formatted:
.class {@media (1024px <= width <=1280px) {@media (1024px <= width <= 1280px) {color: red;}}贡献者:@blaze-d83
¥Contributed by @blaze-d83
JavaScript API
Section titled “JavaScript API”¥Bug fixes
-
修复 #3881,更新 API 以使用最新的 WASM 更改。贡献者:@ematipico
¥Fix #3881, by updating the APIs to use the latest WASM changes. Contributed by @ematipico
Linter
Section titled “Linter”¥New features
-
添加 noDescendingSpecificity。贡献者: @tunamaguro
¥Add noDescendingSpecificity. Contributed by @tunamaguro
-
添加 noNestedTernary。贡献者:@kaykdm
¥Add noNestedTernary. Contributed by @kaykdm
-
添加 noTemplateCurlyInString。贡献者:@fireairforce
¥Add noTemplateCurlyInString. Contributed by @fireairforce
-
添加 noOctalEscape。贡献者:@fireairforce
¥Add noOctalEscape. Contributed by @fireairforce
¥Enhancements
-
为 useExhaustiveDependencies 添加选项
reportUnnecessaryDependencies。¥Add an option
reportUnnecessaryDependenciesto useExhaustiveDependencies.默认为 true。设置为 false 时,将抑制声明了依赖但未使用这些依赖的 React Hook 的错误。
¥Defaults to true. When set to false, errors will be suppressed for React hooks that declare dependencies but do not use them.
贡献者:@simon-paris
¥Contributed by @simon-paris
-
为 useExhaustiveDependencies 添加选项
reportMissingDependenciesArray。贡献者:@simon-paris¥Add an option
reportMissingDependenciesArrayto useExhaustiveDependencies. Contributed by @simon-paris
¥Bug fixes
-
noControlCharactersInRegex 不再因包含不完整转义序列的正则表达式而引发 panic。贡献者:@Conaclos
¥noControlCharactersInRegex no longer panics on regexes with incomplete escape sequences. Contributed by @Conaclos
-
noMisleadingCharacterClass 不再报告字符类之外的问题。
¥noMisleadingCharacterClass no longer reports issues outside of character classes.
以下代码不再被报告:
¥The following code is no longer reported:
/[a-z]👍/;贡献者:@Conaclos
¥Contributed by @Conaclos
-
noUndeclaredDependencies 不再将 Node.js 内置模块报告为未声明的依赖。
¥noUndeclaredDependencies no longer reports Node.js builtin modules as undeclared dependencies.
该规则不再将以下代码报告为未使用:
¥The rule no longer reports the following code:
import * as fs from "fs";贡献者:@Conaclos
¥Contributed by @Conaclos
-
noUnusedVariables 不再因建议重命名文件开头的变量而引发 panic (#4114)。贡献者:@Conaclos
¥noUnusedVariables no longer panics when suggesting the renaming of a variable at the start of a file (#4114). Contributed by @Conaclos
-
noUselessEscapeInRegex 不再因以空字符类开头的正则表达式而引发 panic。贡献者:@Conaclos
¥noUselessEscapeInRegex no longer panics on regexes that start with an empty character class. Contributed by @Conaclos
-
noUselessStringConcat 不再因遇到格式错误的代码而引发 panic。贡献者:@Conaclos
¥noUselessStringConcat no longer panics when it encounters malformed code. Contributed by @Conaclos
-
noUnusedFunctionParameters 不再报告带有剩余参数的对象模式中未使用的参数。
¥noUnusedFunctionParameters no longer reports unused parameters inside an object pattern with a rest parameter.
在以下代码中,该规则不再将
a报告为未使用。¥In the following code, the rule no longer reports
aas unused.function f({ a, ...rest }) {return rest;}这与 noUnusedVariables 的行为一致。
¥This matches the behavior of noUnusedVariables.
贡献者:@Conaclos
¥Contributed by @Conaclos
-
useButtonType 不再报告具有有效类型的动态创建的按钮 (#4072)。
¥useButtonType no longer reports dynamically created button with a valid type (#4072).
以下代码不再被报告:
¥The following code is no longer reported:
React.createElement("button", { type: "button" }, "foo")贡献者:@Conaclos
¥Contributed by @Conaclos
-
useSemanticElements 现在会忽略带有
img角色的元素 (#3994)。¥useSemanticElements now ignores elements with the
imgrole (#3994).MDN 推荐 使用
role="img"对图片进行分组或从其他元素创建图片。以下代码不再被报告:¥MDN recommends using
role="img"for grouping images or creating an image from other elements. The following code is no longer reported:<div role="img" aria-label="That cat is so cute"><p>🐈 😂</p></div>贡献者:@Conaclos
¥Contributed by @Conaclos
-
useSemanticElements 现在会忽略
alert和alertdialog角色 (#3858)。贡献者:@Conaclos¥useSemanticElements now ignores
alertandalertdialogroles (#3858). Contributed by @Conaclos -
当 Fragments 子元素包含 JSX 表达式且位于 LogicalExpression 中时,noUselessFragments 不会生成无效的 JSX 代码。贡献者:@fireairforce
¥noUselessFragments don’t create invalid JSX code when Fragments children contains JSX Expression and in a LogicalExpression. Contributed by @fireairforce
¥Parser
¥Bug fixes
-
禁止 TypeScript 解析器使用 undefined 作为类型名称。贡献者:@fireairforce
¥Forbid undefined as type name for typescript parser. Contributed by @fireairforce
v1.9.2 (2024-09-19)
Section titled “v1.9.2 (2024-09-19)”¥New features
-
添加了对自定义 GritQL 定义的支持,包括:
¥Added support for custom GritQL definitions, including:
-
模式和谓词定义:https://docs.grit.io/guides/patterns
¥Pattern and predicate definitions: https://docs.grit.io/guides/patterns
-
函数定义:https://docs.grit.io/language/functions#function-definitions
¥Function definitions: https://docs.grit.io/language/functions#function-definitions
贡献者:@arendjr
¥Contributed by @arendjr
-
¥Bug fixes
-
修复 #3917,其中修复后的文件计算不正确。贡献者:@ematipico
¥Fix #3917, where the fixed files were incorrectly computed. Contributed by @ematipico
-
修复了当匹配的节点出现在同级节点内时,GritQL
contains查询会报告误报的问题。贡献者:@arendjr¥Fixed an issue that caused GritQL
containsqueries to report false positives when the matched node appeared inside a sibling node. Contributed by @arendjr
¥Editors
¥Bug fixes
-
修复 #3923。现在,LSP 可以正确解析
.editorconfig,并且在触发格式化时,选项也能正确应用于文件。此外,Biome LSP 现在会监视.editorconfig的任何更改,并更新格式设置。¥Fix #3923. Now the
.editorconfigis correctly parsed by the LSP, and the options are correctly applied to files when formatting is triggered. Plus, the Biome LSP now watches for any change to the.editorconfig, and updates the formatting settings. -
减少了 LSP 服务器生成的日志文件数量。现在磁盘上保存的日志数量上限为7。贡献者:@ematipico
¥Reduced the number of log files generated by the LSP server. Now the maximum number of logs saved on disk is **seven **. Contributed by @ematipico
-
修复 LSP Biome 服务器中可用的代码操作功能。之前,LSP 使用的是默认功能,即使编辑器禁用了某些操作,它仍然会执行代码拉取操作。
¥Fix the code actions capabilities available in the LSP Biome server. Before, the LSP was using the default capabilities, which resulted in pulling code actions even when they were disabled by the editor.
这意味着只有当编辑器启用
quickfix.biome、source.organizeImports.biome和source.fixAll.biome时,客户端才会获取代码操作。¥This means that the code actions are pulled by the client only when the editor enables
quickfix.biome,source.organizeImports.biomeandsource.fixAll.biome.现在,如果你在
biome.json中启用organizeImports.enabled: true,然后使用以下代码操作source.organizeImports.biome: false配置编辑器,则编辑器不会对导入进行排序。¥Now, if you enable
organizeImports.enabled: truein thebiome.json, and then you configure your editor with the following code actionsource.organizeImports.biome: false, the editor won’t sort the imports.贡献者:@ematipico
¥Contributed by @ematipico
Linter
Section titled “Linter”¥New features
-
添加 nursery/noMissingVarFunction。贡献者:@michellocana
¥Add nursery/noMissingVarFunction. Contributed by @michellocana
-
添加 nursery/useComponentExportOnlyModules。在 React 项目中使用此规则强制执行符合 React Refresh 规范的代码样式。贡献者:@GunseiKPaseri
¥Add nursery/useComponentExportOnlyModules. Use this rule in React projects to enforce a code styling that fits React Refresh. Contributed by @GunseiKPaseri
¥Bug fixes
-
noLabelWithoutControl 现在接受 JSX 表达式作为标签值 (#3875)。贡献者:@Conaclos
¥noLabelWithoutControl now accept JSX expression as label value (#3875). Contributed by @Conaclos
-
useFilenamingConvention 不再建议包含不允许命名规则的名称 (#3952)。贡献者:@Conaclos
¥useFilenamingConvention no longer suggests names with a disallowed case (#3952). Contributed by @Conaclos
-
useFilenamingConvention 现在会将以 ASCII 数字开头的文件名识别为小写 (#3952)。
¥useFilenamingConvention now recognizes file names starting with ASCII digits as lowercase (#3952).
因此,
2024-09-17-filename、2024_09_17_filename和20240917FileName分别位于kebab-case、snake_case和camelCase中。¥Thus,
2024-09-17-filename,2024_09_17_filenameand20240917FileNameare inkebab-case,snake_case, andcamelCaserespectively.贡献者:@Conaclos
¥Contributed by @Conaclos
-
useFilenamingConvention 现在会将配置的格式应用于文件扩展名(#3650)。贡献者:@Conaclos
¥useFilenamingConvention now applies the configured formats to the file extensions (#3650). Contributed by @Conaclos
¥Parser
¥Bug fixes
-
useStrictMode 现在会报告包含某些指令但不包含
use strict指令的脚本文件。贡献者:@Conaclos¥useStrictMode now reports Script files with some directives, but without the
use strictdirective. Contributed by @Conaclos -
CSS 解析器现在接受标识符中的字符 U+FFDCF 和 U+FFFD。贡献者:@Conaclos
¥The CSS parser now accepts the characters U+FFDCF and U+FFFD in identifiers. Contributed by @Conaclos
v1.9.1 (2024-09-15)
Section titled “v1.9.1 (2024-09-15)”¥Bug fixes
-
useEditorConfig现在会在运行biome ci和 #3864 时加载 editorconfig。贡献者:@dyc3¥
useEditorConfignow loads the editorconfig when runningbiome ci#3864. Contributed by @dyc3
¥Editors
¥Bug fixes
-
恢复 #3731 以修复损坏的快速修复和代码操作。贡献者:@nhedger
¥Revert #3731 to fix broken quick fixes and code actions. Contributed by @nhedger
Linter
Section titled “Linter”¥New Features
-
添加 nursery/noProcessEnv。由 @unvalley 提供
¥Add nursery/noProcessEnv. Contributed by @unvalley
¥Bug fixes
-
noUndeclaredDependencies 现在会忽略
@/导入,并识别来自 Definitely Typed 的类型导入和bun导入。贡献者:@Conaclos¥noUndeclaredDependencies now ignores
@/imports and recognizes type imports from Definitely Typed andbunimports. Contributed by @Conaclos
v1.9.0 (2024-09-12)
Section titled “v1.9.0 (2024-09-12)”¥Analyzer
-
实现 CSS 语义模型。贡献者:@togami2864
¥Implement the semantic model for CSS. Contributed by @togami2864
¥New features
-
添加
--graphql-linter-enabled选项,用于控制是否为 GraphQL 文件启用代码检查器。贡献者:@ematipico¥Add
--graphql-linter-enabledoption, to control whether the linter should be enabled or not for GraphQL files. Contributed by @ematipico -
新增 EXPERIMENTAL
search命令。搜索命令允许你使用 GritQL 语法 搜索 Biome 项目。¥New EXPERIMENTAL
searchcommand. The search command allows you to search a Biome project using GritQL syntax.GritQL 是一种强大的语言,允许你对代码库进行结构化搜索。这意味着在搜索查询中,空格甚至字符串类型(例如使用的引号)等细节都将被忽略。它也提供了许多用于查询代码结构的功能,使其在代码搜索方面比正则表达式更加优雅。
¥GritQL is a powerful language that lets you do structural searches on your codebase. This means that trivia such as whitespace or even the type of strings quotes used will be ignored in your search query. It also has many features for querying the structure of your code, making it much more elegant for searching code than regular expressions.
我们相信这条命令在某些情况下可能对用户有用(尤其是在集成到 IDE 扩展程序中时!),但我们添加这条命令还有另一个目的:我们计划在插件开发中使用 GritQL,并通过允许用户在第一个版本中进行试用,希望了解你希望执行的查询类型以及我们需要重点关注的错误。
¥While we believe this command may already be useful to users in some situations (especially when integrated in the IDE extensions!), we also had an ulterior motive for adding this command: We intend to utilize GritQL for our plugin efforts, and by allowing our users to try it out in a first iteration, we hope to gain insight in the type of queries you want to do, as well as the bugs we need to focus on.
目前,由于仍存在许多错误,
search命令被明确标记为“实验性”。尝试时请牢记这些规则,并请将你遇到的问题提交到 告知我们!¥For now, the
searchcommand is explicitly marked as EXPERIMENTAL, since many bugs remain. Keep this in mind when you try it out, and please let us know your issues!注意:GritQL 使用反引号转义代码片段,但大多数 shell 将反引号解释为命令调用。为避免这种情况,最好在 Grit 查询周围加上单引号。
¥Note: GritQL escapes code snippets using backticks, but most shells interpret backticks as command invocations. To avoid this, it’s best to put single quotes around your Grit queries.
Terminal window biome search '`console.log($message)`' # find all `console.log` invocations由 @arendjr 和 @BackupMiles 贡献
¥Contributed by @arendjr and @BackupMiles
-
选项
--max-diagnostics现在接受none值,这将解除显示的诊断信息限制。贡献者:@ematipico¥The option
--max-diagnosticsnow accept anonevalue, which lifts the limit of diagnostics shown. Contributed by @ematipico-
新增报告器
--reporter=gitlab,用于在使用 GitLab 代码质量报告 时发出诊断信息。¥Add a new reporter
--reporter=gitlab, that emits diagnostics for using the GitLab Code Quality report.[{"description": "Use === instead of ==. == is only allowed when comparing against `null`","check_name": "lint/suspicious/noDoubleEquals","fingerprint": "6143155163249580709","severity": "critical","location": {"path": "main.ts","lines": {"begin": 4}}}]贡献者:@NiclasvanEyk
¥Contributed by @NiclasvanEyk
-
-
为命令
lsp-proxy和start添加新选项:¥Add new options to the
lsp-proxyandstartcommands:-
--log-path:用于存储守护进程日志的目录。这些命令也接受环境变量BIOME_LOG_PATH。¥
--log-path: a directory where to store the daemon logs. The commands also accepts the environment variableBIOME_LOG_PATH. -
--log-prefix-name:添加到日志文件名的前缀。默认使用server.log。这些命令也接受环境变量BIOME_LOG_PREFIX_NAME。¥
--log-prefix-name: a prefix that’s added to the file name of the logs. It defaults toserver.log. The commands also accepts the environment variableBIOME_LOG_PREFIX_NAME.
@Contributed by @ematipico
-
¥Enhancements
-
当提供
--reporter且其值与默认值不同时。第一,通过--max-diagnostics提供的值将被忽略,限制将被解除。贡献者:@ematipico¥When a
--reporteris provided, and it’s different from the default one, the value provided by via--max-diagnosticsis ignored and the limit is lifted. Contributed by @ematipico
biome init 现在会生成一个包含更多选项的新配置文件。此更改旨在提高选项的可发现性,并将常用选项设置为默认值。贡献者:@Conaclos
¥biome init now generates a new config file with more options set. This change intends to improve discoverability of the options and to set the more commonly used options to their default values. Contributed by @Conaclos
-
--verbose标志现在会报告已评估的文件列表和已修复的文件列表。** * 已评估 ** 文件是指 Biome 可以处理的文件,被忽略、没有扩展名或扩展名 Biome 无法评估的文件均不在此列表中。已修复的文件是指由 Biome 处理并已更改的文件。处理后保持不变的文件将从列表中排除。¥The
--verboseflag now reports the list of files that were evaluated, and the list of files that were fixed. The * *evaluated ** files are the those files that can be handled by Biome, files that are ignored, don’t have an extension or have an extension that Biome can’t evaluate are excluded by this list. The fixed files are those files that were handled by Biome and changed. Files that stays the same after the process are excluded from this list.Terminal window VERBOSE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ℹ Files processed:- biome/biome.json- biome/packages/@biomejs/cli-win32-arm64/package.json- biome/packages/tailwindcss-config-analyzer/package.jsonVERBOSE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ℹ Files fixed:- biome/biome/packages/tailwindcss-config-analyzer/src/generate-tailwind-preset.ts贡献者:@ematipico
¥Contributed by @ematipico
-
允许将
nursery传递给--only和--skip过滤器。¥Allow passing
nurseryto the--onlyand--skipfilters.--only选项允许你运行指定的规则或规则组。--skip选项允许你跳过执行指定的规则组或规则。¥The
--onlyoption allows you to run a given rule or rule group. The--skipoption allows you to skip the execution of a given group or a given rule.之前,无法传递
nursery。此限制现已移除,因为跳过项目已启用的初始规则可能更有意义。¥Previously, it was not possible to pass
nursery. This restriction is now removed, as it may make sense to skip the nursery rules that a project has enabled.贡献者:@Conaclos
¥Contributed by @Conaclos
-
现在,在
stdin模式下调用命令时,CLI 会返回错误代码,并且文件内容不会被固定。例如,以下示例将导致错误代码1,因为lint命令触发了一些代码检查规则:¥The CLI now returns an error code when calling a command in
stdinmode, and the contents of the files aren’t fixed. For example, the following example will result in an error code of1because thelintcommand triggers some lint rules:Terminal window echo "let x = 1" | biome lint --stdin-file-path=stdin.js贡献者:@ematipico
¥Contributed by @ematipico
¥Bug fixes
-
biome lint --write现在同时考虑--only和--skip(#3470)。贡献者:@Conaclos¥
biome lint --writenow takes--onlyand--skipinto account (#3470). Contributed by @Conaclos -
修复 #3368,现在报告器
github会跟踪与格式化和组织导入相关的诊断信息。贡献者:@ematipico¥Fix #3368, now the reporter
githubtracks the diagnostics that belong to formatting and organize imports. Contributed by @ematipico -
修复 #3545,当 Fragment 仅包含一个位于新行的子元素时,显示警告 ‘避免使用不必要的 Fragment,‘。贡献者:@satojin219
¥Fix #3545, display a warning, ‘Avoid using unnecessary Fragment,’ when a Fragment contains only one child element that is placed on a new line. Contributed by @satojin219
-
从 Prettier 或 ESLint 迁移后,不再会覆盖配置中的
overrides字段(#3544)。贡献者:@Conaclos¥Migrating from Prettier or ESLint no longer overwrite the
overridesfield from the configuration (#3544). Contributed by @Conaclos -
修复
noAriaHiddenOnFocusable(#3708) 的 JSX 表达式。贡献者:@anthonyshew¥Fix JSX expressions for
noAriaHiddenOnFocusable(#3708). Contributed by @anthonyshew -
修复了使用
role="img"的<canvas>元素 (#3728) 的极端情况。贡献者:@anthonyshew¥Fix edge case for
<canvas>elements that userole="img"(#3728). Contributed by @anthonyshew -
修复 #3633,其中代码存在错误时,诊断信息打印不正确。贡献者:@ematipico
¥Fix #3633, where diagnostics where incorrectly printed if the code has errors. Contributed by @ematipico
-
允许在标题中使用
aria-label以防止useHeadingContent诊断(#3767)。贡献者:@anthonyshew¥Allow
aria-labelon heading to preventuseHeadingContentdiagnostic (#3767). Contributed by @anthonyshew -
修复了规则
noFocusedTests与非字符串类表达式 (#3793) 一起使用时 #3791 的极端情况。贡献者:@h-a-n-a¥Fix edge case #3791 for rule
noFocusedTestsbeing used with non-string-like expressions (#3793). Contributed by @h-a-n-a -
修复
useAriaPropsForRole(#3856) 中role="separator"的可选 ARIA 属性。贡献者:@anthonyshew¥Fix optional ARIA properties for
role="separator"inuseAriaPropsForRole(#3856). Contributed by @anthonyshew
¥Configuration
-
添加对从
.editorconfig文件(#1724)加载配置的支持。¥Add support for loading configuration from
.editorconfigfiles (#1724)..editorconfig中提供的配置将被biome.json中的配置覆盖。默认情况下禁用此功能,可通过在biome.json的格式化程序配置中添加以下内容来启用:¥Configuration supplied in
.editorconfigwill be overridden by the configuration inbiome.json. Support is disabled by default and can be enabled by adding the following to your formatter configuration inbiome.json:{"formatter": {"useEditorconfig": true}}贡献者:@dyc3
¥Contributed by @dyc3
-
扩展配置中的
overrides现在已与扩展的overrides合并。¥
overridesfrom an extended configuration is now merged with theoverridesof the extension.给定以下共享配置
biome.shared.json:¥Given the following shared configuration
biome.shared.json:{"overrides": [{"include": ["**/*.json"],// ...}]}以及以下配置:
¥and the following configuration:
{"extends": ["./biome.shared.json"],"overrides": [{"include": ["**/*.ts"],// ...}]}之前,
biome.shared.json会覆盖overrides。现在已合并,配置如下:¥Previously, the
overridesfrombiome.shared.jsonwas overwritten. It is now merged and results in the following configuration:{"extends": ["./biome.shared.json"],"overrides": [{"include": ["**/*.json"],// ...},{"include": ["**/*.ts"],// ...}]}贡献者:@Conaclos
¥Contributed by @Conaclos
¥Editors
-
修复 #3577,修复了更新配置文件导致创建新内部项目的问题。贡献者:@ematipico
¥Fix #3577, where the update of the configuration file was resulting in the creation of a new internal project. Contributed by @ematipico
-
修复 #3696,其中
biome.jsonc被错误解析,使用了错误的选项。贡献者:@ematipico¥Fix #3696, where
biome.jsoncwas incorrectly parsed with incorrect options. Contributed by @ematipico
¥Formatter
-
CSS 格式化程序默认启用。这意味着你不再需要使用配置文件
biome.json来启用此功能:¥The CSS formatter is enabled by default. Which means that you don’t need to opt-in anymore using the configuration file
biome.json:{"css": {"formatter": {"enabled": true}}}贡献者:@ematipico
¥Contributed by @ematipico
-
添加括号以在三元运算符中合并空值。
¥Add parentheses for nullcoalescing in ternaries.
此更改与 Prettier 3.3.3 保持一致。这增强了运算符优先级的清晰度。
¥This change aligns on Prettier 3.3.3. This adds clarity to operator precedence.
foo ? bar ?? foo : baz;foo ? (bar ?? foo) : baz;贡献者:@Conaclos
¥Contributed by @Conaclos
-
在类型联合和类型交集 (#3419) 中,请将
infer ... extends声明用括号括起来。贡献者:@Conaclos¥Keep the parentheses around
infer ... extendsdeclarations in type unions and type intersections (#3419). Contributed by @Conaclos -
在类型断言中,请将
yield表达式用括号括起来。¥Keep parentheses around a
yieldexpression inside a type assertion.之前,Biome 会移除类型断言中某些需要括号的表达式周围的括号。例如,在以下代码中,Biome 现在可以保留括号。
¥Previously, Biome removed parentheses around some expressions that require them inside a type assertion. For example, in the following code, Biome now preserves the parentheses.
function* f() {return <T>(yield 0);}贡献者:@Conaclos
¥Contributed by @Conaclos
-
移除装饰器中不需要括号的表达式周围的括号。
¥Remove parentheses around expressions that don’t need them inside a decorator.
Biome 现在在以下情况下与 Prettier 保持一致:
¥Biome now matches Prettier in the following cases:
class {@(decorator)@decoratormethod() {}},class {@(decorator())@decorator()method() {}},class {@(decorator?.())method() {}},贡献者:@Conaclos
¥Contributed by @Conaclos
-
在带有
@satisfies注释的对象周围,请用括号括起来。¥Keep parentheses around objects preceded with a
@satisfiescomment.在以下示例中,不再移除括号。
¥In the following example, parentheses are no longer removed.
export const PROPS = /** @satisfies {Record<string, string>} */ ({prop: 0,});贡献者:@Conaclos
¥Contributed by @Conaclos
Linter
Section titled “Linter”¥Promoted rules
新规则在 nursery 组中进行孵化。一旦稳定下来,我们就将它们提升为稳定规则。
¥New rules are incubated in the nursery group. Once stable, we promote them to a stable group.
以下 CSS 规则已生效:
¥The following CSS rules are promoted:
以下 JavaScript 规则已生效:
¥The following JavaScript rules are promoted:
已弃用的规则
Section titled “已弃用的规则”¥Deprecated rules
correctness/noInvalidNewBuiltin 已弃用。请改用 correctness/noInvalidBuiltinInstantiation。
Section titled “correctness/noInvalidNewBuiltin 已弃用。请改用 correctness/noInvalidBuiltinInstantiation。”¥correctness/noInvalidNewBuiltin is deprecated. Use correctness/noInvalidBuiltinInstantiation instead.
style/useSingleCaseStatement 已弃用。请改用 correctness/noSwitchDeclarations。
Section titled “style/useSingleCaseStatement 已弃用。请改用 correctness/noSwitchDeclarations。”¥style/useSingleCaseStatement is deprecated. Use correctness/noSwitchDeclarations instead.
suspicious/noConsoleLog 已弃用。请改用 suspicious/noConsole。
¥suspicious/noConsoleLog is deprecated. Use suspicious/noConsole instead.
¥New features
-
实现 CSS 抑制操作。贡献者:@togami2864
¥Implement css suppression action. Contributed by @togami2864
-
添加对 GraphQL 代码检查的支持。贡献者:@ematipico
¥Add support for GraphQL linting. Contributed by @ematipico
-
添加 nursery/noCommonJs。贡献者:@minht11
¥Add nursery/noCommonJs. Contributed by @minht11
-
添加 nursery/noDuplicateCustomProperties。贡献者:@chansuke
¥Add nursery/noDuplicateCustomProperties. Contributed by @chansuke
-
添加 nursery/noEnum。贡献者:@nickfla1
¥Add nursery/noEnum. Contributed by @nickfla1
-
添加 nursery/noDynamicNamespaceImportAccess。贡献者:@minht11
¥Add nursery/noDynamicNamespaceImportAccess. Contributed by @minht11
-
添加 nursery/noIrregularWhitespace。贡献者:@michellocana
¥Add nursery/noIrregularWhitespace. Contributed by @michellocana
-
添加 nursery/noRestrictedTypes。贡献者:@minht11
¥Add nursery/noRestrictedTypes. Contributed by @minht11
-
添加 nursery/noSecrets。贡献者:@SaadBazaz
¥Add nursery/noSecrets. Contributed by @SaadBazaz
-
添加 nursery/noUselessEscapeInRegex。贡献者:@Conaclos
¥Add nursery/noUselessEscapeInRegex. Contributed by @Conaclos
-
添加 nursery/noValueAtRule。贡献者:@rishabh3112
¥Add nursery/noValueAtRule. Contributed by @rishabh3112
-
添加 nursery/useAriaPropsSupportedByRole。贡献者:@ryo-ebata
¥Add nursery/useAriaPropsSupportedByRole. Contributed by @ryo-ebata
-
添加 nursery/useConsistentMemberAccessibility。贡献者:@seitarof
¥Add nursery/useConsistentMemberAccessibility. Contributed by @seitarof
-
添加 nursery/useStrictMode。贡献者:@ematipico
¥Add nursery/useStrictMode. Contributed by @ematipico
-
添加 nursery/useTrimStartEnd。贡献者:@chansuke
¥Add nursery/useTrimStartEnd. Contributed by @chansuke
-
添加 nursery/noIrregularWhitespace。贡献者:@DerTimonius
¥Add nursery/noIrregularWhitespace. Contributed by @DerTimonius
¥Enhancements
-
将
nursery/noUnknownSelectorPseudoElement重命名为nursery/noUnknownPseudoElement。贡献者:@togami2864¥Rename
nursery/noUnknownSelectorPseudoElementtonursery/noUnknownPseudoElement. Contributed by @togami2864 -
CSS 代码检查器现在默认启用。这意味着你不再需要使用配置文件
biome.json来启用此功能:¥The CSS linter is now enabled by default. Which means that you don’t need to opt-in anymore using the configuration file
biome.json:{"css": {"linter": {"enabled": true}}}贡献者:@ematipico
¥Contributed by @ematipico
-
JavaScript 代码检查器可以识别 TypeScript 5.5 和 5.6 的全局变量。贡献者:@Conaclos
¥The JavaScript linter recognizes TypeScript 5.5 and 5.6 globals. Contributed by @Conaclos
-
noBlankTarget 现在支持允许的域名数组。
¥noBlankTarget now supports an array of allowed domains.
以下配置允许将
example.com和example.org设置为空目标。¥The following configuration allows
example.comandexample.orgas blank targets."linter": {"rules": {"a11y": {"noBlankTarget": {"level": "error","options": {"allowDomains": ["example.com", "example.org"]}}}}}贡献者:@Jayllyz
¥Contributed by @Jayllyz
-
noConsole 现在接受一个选项,用于指定对
console的某些允许调用。贡献者:@Conaclos¥noConsole now accepts an option that specifies some allowed calls on
console. Contributed by @Conaclos -
为 noDoubleEquals 添加
ignoreNull选项。¥Add an
ignoreNulloption for noDoubleEquals.默认情况下,该规则允许与
null进行宽松比较。选项ignoreNull可以设置为false,以便报告与null的宽松比较。¥By default the rule allows loose comparisons against
null. The optionignoreNullcan be set tofalsefor reporting loose comparison againstnull.贡献者:@peaBerberian
¥Contributed by @peaBerberian.
-
noDuplicateObjectKeys 现在支持 JSON 和 JSONC 文件。贡献者:@ematipico
¥noDuplicateObjectKeys now works for JSON and JSONC files. Contributed by @ematipico
-
noInvalidUseBeforeDeclaration 现在会报告在枚举成员声明之前直接使用该枚举成员的情况。
¥noInvalidUseBeforeDeclaration now reports direct use of an enum member before its declaration.
在以下代码中,
A被报告为未声明就已使用。¥In the following code,
Ais reported as use before its declaration.enum E {B = A << 1,A = 1,}贡献者:@Conaclos
¥Contributed by @Conaclos
-
noNodejsModules 现在会忽略与 Node.js 模块同名的包的导入。贡献者:@Conaclos
¥noNodejsModules now ignores imports of a package which has the same name as a Node.js module. Contributed by @Conaclos
-
noNodejsModules 现在会忽略仅类型导入 (#1674)。
¥noNodejsModules now ignores type-only imports (#1674).
该规则不再报告仅包含类型的导入,例如:
¥The rule no longer reports type-only imports such as:
import type assert from "assert";import type * as assert2 from "assert";贡献者:@Conaclos
¥Contributed by @Conaclos
-
当
package.json使用字段"type": "commonjs"显式地将文件标记为脚本时,noRedundantUseStrict 不再报告"use strict"指令。贡献者:@ematipico¥noRedundantUseStrict no longer reports
"use strict"directives when thepackage.jsonmarks explicitly the file as a script using the field"type": "commonjs". Contributed by @ematipico -
noStaticOnlyClass 不再报告继承自其他类的类 (#3612)。贡献者:@errmayank
¥noStaticOnlyClass no longer reports a class that extends another class (#3612). Contributed by @errmayank
-
noUndeclaredVariables 不再报告对枚举成员的直接引用 (#2974)。
¥noUndeclaredVariables no longer reports a direct reference to an enum member (#2974).
在以下代码中,
A引用不再被报告为未声明的变量。¥In the following code, the
Areference is no longer reported as an undeclared variable.enum E {A = 1,B = A << 1,}贡献者:@Conaclos
¥Contributed by @Conaclos
-
noUndeclaredVariables 可以识别 Svelte 组件和 Svelte 文件中的 Svelte 5 符文。
¥noUndeclaredVariables recognized Svelte 5 runes in Svelte components and svelte files.
Svelte 5 引入了 runes。该规则现在可以识别以
.svelte、.svelte.js或.svelte.ts扩展名结尾的 Svelte 5 符文。¥Svelte 5 introduced runes. The rule now recognizes Svelte 5 runes in files ending with the
.svelte,.svelte.jsor.svelte.tsextensions.贡献者:@Conaclos
¥Contributed by @Conaclos
-
noUnusedVariables 现在会检查 TypeScript 声明文件。
¥noUnusedVariables now checks TypeScript declaration files.
这允许报告未使用的、未导出的类型。全局声明文件(不包含导出和导入的声明文件)仍将被忽略。
¥This allows to report a type that is unused because it isn’t exported. Global declarations files (declarations files without exports and imports) are still ignored.
贡献者:@Conaclos
¥Contributed by @Conaclos
-
useFilenamingConvention 现在支持 unicase 字母。
¥useFilenamingConvention now supports unicase letters.
unicase 的字符只有一种大小写形式:它们既不是大写也不是小写。Biome 现在接受大小写统一的文件名。例如,文件名
안녕하세요现在被接受。¥unicase letters have a single case: they are neither uppercase nor lowercase. Biome now accepts filenames in unicase. For example, the filename
안녕하세요is now accepted.我们仍然拒绝混合使用大小写字母的名称。例如,文件名
A안녕하세요被拒绝。¥We still reject a name that mixes unicase characters with lowercase or uppercase characters. For example, the filename
A안녕하세요is rejected.此更改也修复了 #3353。现在接受仅由数字组成的文件名。
¥This change also fixes #3353. Filenames consisting only of numbers are now accepted.
贡献者:@Conaclos
¥Contributed by @Conaclos
-
useFilenamingConvention 现在支持 Next.js/Nuxt/Astro 动态路由 (#3465)。
¥useFilenamingConvention now supports Next.js/Nuxt/Astro dynamic routes (#3465).
Next.js、SolidStart、Nuxt 和 Astro 支持动态路由,例如
[...slug].js和[[...slug]].js。¥Next.js, SolidStart, Nuxt, and Astro support dynamic routes such as
[...slug].jsand[[...slug]].js.Biome 现在可以识别此语法。
slug必须仅包含字母数字字符。¥Biome now recognizes this syntax.
slugmust contain only alphanumeric characters.贡献者:@Conaclos
¥Contributed by @Conaclos
-
useExportType 不再报告空的
export(#3535)。¥useExportType no longer reports empty
export(#3535).空的
export {}允许你强制 TypeScript 将没有导入和导出的文件视为 EcmaScript 模块。虽然export type {}是有效的,但更常用的是export {}。用户可能会对代码检查工具要求将其转换为export type {}感到困惑。此外,打包工具应该能够移除export {}和export type {}。因此,报告export {}意义不大。¥An empty
export {}allows you to force TypeScript to consider a file with no imports and exports as an EcmaScript module. Whileexport type {}is valid, it is more common to useexport {}. Users may find it confusing that the linter asks them to convert it toexport type {}. Also, a bundler should be able to removeexport {}as well asexport type {}. So it is not so useful to reportexport {}.贡献者:@Conaclos
¥Contributed by @Conaclos
¥Bug fixes
-
noControlCharactersInRegex 现在可以正确处理支持 Unicode 的正则表达式中的
\u转义。¥noControlCharactersInRegex now corretcly handle
\uescapes in unicode-aware regexes.之前,规则没有将带有
v标志的正则表达式视为支持 Unicode 的正则表达式。此外,之前 Unicode 感知正则表达式无法处理\uhhhh。¥Previously, the rule didn’t consider regex with the
vflags as unicode-aware regexes. Moreover,\uhhhhwas not handled in unicode-aware regexes.贡献者:@Conaclos
¥Contributed by @Conaclos
-
noControlCharactersInRegex 现在会报告字符串正则表达式中的控制字符及其转义序列。贡献者:@Conaclos
¥noControlCharactersInRegex now reports control characters and escape sequence of control characters in string regexes. Contributed by @Conaclos
noExcessiveNestedTestSuites:修复规则在嵌套过深的 zod schema 上发出警报的极端情况。贡献者:@dyc3
¥noExcessiveNestedTestSuites: fix an edge case where the rule would alert on heavily nested zod schemas. Contributed by @dyc3
noExtraNonNullAssertion 不再报告用括号括起来的单个非空断言 (#3352)。贡献者:@Conaclos
¥noExtraNonNullAssertion no longer reports a single non-null assertion enclosed in parentheses (#3352). Contributed by @Conaclos
-
当使用 Unicode 字符时,noMultipleSpacesInRegularExpressionLiterals 现在可以正确提供代码修复。贡献者:@Conaclos
¥noMultipleSpacesInRegularExpressionLiterals now correctly provides a code fix when Unicode characters are used. Contributed by @Conaclos
-
noRedeclare 不再报告词法作用域函数声明的重复声明 (#3664)。
¥noRedeclare no longer report redeclartions for lexically scoped function declarations #3664.
在 JavaScript 严格模式下,函数声明是词法作用域的:它们无法在声明它们的代码块之外访问。
¥In JavaScript strict mode, function declarations are lexically scoped: they cannot be accessed outside the block where they are declared.
在非严格模式下,函数声明会被提升到包含它的函数或全局作用域的顶部。
¥In non-strict mode, function declarations are hoisted to the top of the enclosing function or global scope.
以前,Biome 总是会提升函数声明。现在,会考虑代码处于严格模式还是非严格模式。
¥Previously Biome always hoisted function declarations. It now takes into account whether the code is in strict or non strict mode.
贡献者:@Conaclos
¥Contributed by @Conaclos
-
noUndeclaredDependencies 现在会忽略自身包的导入。
¥noUndeclaredDependencies now ignores self package imports.
给定以下
package.json:¥Given teh following
package.json:{"name": "my-package","main": "index.js"}以下导入不再被规则报告:
¥The following import is no longer reported by the rule:
import * as mod from "my-package";贡献者:@Conaclos
¥Contributed by @Conaclos
-
修复 [#3149],修复了在某些情况下应用
noUselessFragments不安全修复时发生的崩溃问题。由 @unvalley 提供¥Fix [#3149] crashes that occurred when applying the
noUselessFragmentsunsafe fixes in certain scenarios. Contributed by @unvalley -
noRedeclare 不再报告声明时名称与函数表达式相同的变量。贡献者:@Conaclos
¥noRedeclare no longer reports a variable named as the function expression where it is declared. Contributed by @Conaclos
-
useAdjacentOverloadSignatures不再报告同名的类成员和公共类成员 (#3309)。¥
useAdjacentOverloadSignaturesno longer reports a#privateclass member and a public class member that share the same name (#3309).以下代码不再被报告:
¥The following code is no longer reported:
class C {#f() {}g() {}f() {}}贡献者:@Conaclos
¥Contributed by @Conaclos
-
useAltText 不再请求对辅助技术隐藏的元素(#3316)的替代文本。贡献者:@robintown
¥useAltText n olonger requests alt text for elements hidden from assistive technologies (#3316). Contributed by @robintown
-
useNamingConvention 现在支持对抽象类应用自定义约定。贡献者:@Conaclos
¥useNamingConvention now accepts applying custom convention on abstract classes. Contributed by @Conaclos
-
当名称不符合严格的 Pascal 命名规则时,useNamingConvention 不再建议空修复 (#3561)。
¥useNamingConvention no longer suggests an empty fix when a name doesn’t match strict Pascal case (#3561).
以前,以下代码会导致
useNamingConvention建议一个空的修复。该规则不再针对这种情况提供修复。¥Previously the following code led
useNamingConventionto suggest an empty fix. The rule no longer provides a fix for this case.type AAb = any贡献者:@Conaclos
¥Contributed by @Conaclos
-
useNamingConvention 不再为全局 TypeScript 声明文件提供修复。
¥useNamingConvention no longer provides fixes for global TypeScript declaration files.
全局 TypeScript 声明文件不包含导出和导入。所有声明的类型在项目的所有文件中都可用。因此,仅在声明文件中建议重命名是不安全的。
¥Global TypeScript declaration files have no epxorts and no imports. All the declared types are available in all files of the project. Thus, it is not safe to propose renaming only in the declaration file.
贡献者:@Conaclos
¥Contributed by @Conaclos
-
模板字面量(#3394)的 useSortedClasses lint 错误。贡献者:@hangaoke1
¥useSortedClasses lint error with Template literals (#3394). Contributed by @hangaoke1
-
useValidAriaValues 现在能够正确检查属性类型 (3748)。
¥useValidAriaValues now correctly check property types (3748).
现在,需要字符串的属性可以接受任意文本。标识符现在可以由除 ASCII 空格以外的任何字符组成。标识符列表现在可以用任意 ASCII 空格分隔。
¥Properties that expect a string now accept arbitrary text. An identifiers can now be made up of any characters except ASCII whitespace. An identifier list can now be separated by any ASCII whitespace.
贡献者:@Conaclos
¥Contributed by @Conaclos
¥Parser
¥Enhancements
-
JSON 解析器现在支持
turbo.json和jest.config.json文件中的注释。由 @Netail 和 @Conaclos 贡献¥The JSON parser now allows comments in
turbo.jsonandjest.config.json. Contributed by @Netail and @Conaclos -
JSON 解析器现在支持
.vscode和.zed目录下扩展名为.json的文件中的注释。¥The JSON parser now allows comments in files with the
.jsonextension under the.vscodeand.zeddirectories.Biome 识别允许注释和/或尾随逗号的常见 JSON 文件。之前,Biome 无法识别
.vscode和.zed目录下的 JSON 文件,这些文件不支持注释。你需要配置 Biome 来识别他们:¥Biome recognizes are well known JSON files that allows comments and/or trailing commas. Previously, Biome did not recognize JSON files under the
.vscodeand the.zeddirectories as JSON files that allow comments. You had to configure Biome to recognize them:{"overrides": [{"include": ["**/.vscode/*.json", "**/.zed/*.json"],"json": { "parser": { "allowComments": true } }}]}此重写不再需要!请注意,
.vscode和.zed目录下的 JSON 文件不接受尾随逗号。¥This override is no longer needed! Note that JSON files under the
.vscodeand the.zeddirectories don’t accept trailing commas.贡献者:@Conaclos
¥Contributed by @Conaclos
¥Bug fixes
-
CSS 解析器现在接受标识符中的 emoji 表情符号 (3627)。
¥The CSS parser now accepts emoji in identifiers (3627).
以下代码现在可以被正确解析:
¥The following code is now correctly parsed:
p {--🥔-color: red;color: var(--🥔-color);}贡献者:@Conaclos
¥Contributed by @Conaclos
-
修复 #3287 中带有伪类的嵌套选择器问题。贡献者:@denbezrukov
¥Fix #3287 nested selectors with pseudo-classes. Contributed by @denbezrukov
-
修复 #3349 支持 CSS 多个 & 符号。贡献者:@denbezrukov
¥Fix #3349 allow CSS multiple ampersand support. Contributed by @denbezrukov
.class {&& {color: red;}} -
修复 #3410,正确解析包含关键字的 break 语句。
¥Fix #3410 by correctly parsing break statements containing keywords.
out: while (true) {break out;}贡献者:@ah-yu
¥Contributed by @ah-yu
-
修复 #3464 问题,在使用了
lang='jsx'或lang='tsx'属性的.vue文件中启用 JSX。贡献者:@ematipico¥Fix #3464 by enabling JSX in
.vuefiles that use thelang='jsx'orlang='tsx'attribute. Contributed by @ematipico
v1.8.3 (2024-06-27)
Section titled “v1.8.3 (2024-06-27)”¥Bug fixes
-
修复 #3104,在使用
biome migrate时抑制节点警告。贡献者:@SuperchupuDev¥Fix #3104 by suppressing node warnings when using
biome migrate. Contributed by @SuperchupuDev -
使用 GitHub 报告器在 GitHub Actions 中正确创建注解时,强制关闭颜色显示 (#3148)。贡献者:@Sec-ant
¥Force colors to be off when using the GitHub reporter to properly create annotations in GitHub actions (#3148). Contributed by @Sec-ant
¥Parser
¥Bug fixes
-
实现 CSS Unicode 范围。贡献者:@denbezrukov
¥Implement CSS unicode range. Contributed by @denbezrukov
¥Formatter
¥Bug fixes
-
修复 #3184,CSS 格式化程序会将自定义标识符转换为小写。贡献者:@denbezrukov
¥Fix #3184 CSS formatter converts custom identifiers to lowercase. Contributed by @denbezrukov
-
修复 #3256 在编辑 CSS 文件时常量崩溃的问题 #3256。贡献者:@denbezrukov
¥Fix #3256 constant crashes when editing css files #3256. Contributed by @denbezrukov
Linter
Section titled “Linter”¥New features
-
添加
nursery/useDeprecatedReason规则。由 @vohoanglong0107 贡献¥Add
nursery/useDeprecatedReasonrule. Contributed by @vohoanglong0107. -
添加 nursery/noExportedImports。贡献者:@Conaclos
¥Add nursery/noExportedImports. Contributed by @Conaclos
¥Enhancements
-
实现 suggestedExtensions 选项 的
useImportExtensions规则。贡献者: @drdaemos¥Implement suggestedExtensions option for
useImportExtensionsrule. Contributed by @drdaemos
¥Bug fixes
-
useConsistentArrayType和useShorthandArrayType现在忽略extends和implements子句中的Array。修复 #3247。贡献者:@Conaclos¥
useConsistentArrayTypeanduseShorthandArrayTypenow ignoreArrayin theextendsandimplementsclauses. Fix #3247. Contributed by @Conaclos -
通过考虑
package.json中声明的依赖来修复 #3066。贡献者:@ematipico¥Fixes #3066 by taking into account the dependencies declared in the
package.json. Contributed by @ematipico -
当箭头函数中只有一个类型参数且启用了 JSX 时,
useArrowFunction规则的代码操作现在会保留尾随逗号。修复 #3292。贡献者:@Sec-ant¥The code action of the
useArrowFunctionrule now preserves a trailing comma when there is only a single type parameter in the arrow function and JSX is enabled. Fixes #3292. Contributed by @Sec-ant
¥Enhancements
-
增强 Tailwind 排序 lint 规则 #1274 的变体支持。
¥Enhance tailwind sorting lint rule #1274 with variant support.
每个预配置的变体都会被分配一个
weight,用于确定输出排序顺序。由于可以对同一实用程序类嵌套变体,因此生成的weight是该类所有变体权重的按位异或结果。动态变体(例如has-[.custom-class]、group-[:checked])也受支持,它们会在其基本变体名称的weight之后附加自定义值(例如,has-[.custom-class]的权重为has)。任意变体(例如[&nth-child(2)])没有权重,它们会被放置在每个已知变体之后。具有相同数量的任意变体的类遵循字典序。嵌套任意变体数量最多的类会被放在最后。目前尚不支持屏幕变体(例如sm:、max-md:、min-lg:)。¥Every preconfigured variant is assigned a
weightthat concurs on establishing the output sorting order. Since nesting variants on the same utility class is possible, the resultingweightis the Bitwise XOR of all the variants weight for that class. Dynamic variants (e.g.has-[.custom-class],group-[:checked]) are also supported and they take theweightof their base variant name the custom value attached (e.g.has-[.custom-class]takeshasweight). Arbitrary variants (e.g.[&nth-child(2)]) don’t have a weight assigned and they are placed after every known variant. Classes with the same amount of arbitrary variants follow lexicographical order. The class that has the highest number of nested arbitrary variants is placed last. Screen variants (e.g.sm:,max-md:,min-lg:) are not supported yet.贡献者:@lutaok
¥Contributed by @lutaok
v1.8.2 (2024-06-20)
Section titled “v1.8.2 (2024-06-20)”¥Bug fixes
-
修复 #3201,在打印诊断信息时正确注入文件的源代码。贡献者:@ematipico
¥Fix #3201 by correctly injecting the source code of the file when printing the diagnostics. Contributed by @ematipico
-
修复了 #3179 中运行
biome migrate后逗号分隔符未被正确移除,导致解析器崩溃的问题。贡献者:@Sec-ant¥Fix #3179 where comma separators are not correctly removed after running
biome migrateand thus choke the parser. Contributed by @Sec-ant -
修复 #3232 问题,正确使用用户设置的颜色。贡献者:@ematipico
¥Fix #3232 by correctly using the colors set by the user. Contributed by @ematipico
¥Enhancement
-
将报告消息
No fixes needed修改为No fixes applied。¥Reword the reporter message
No fixes neededtoNo fixes applied.如果文件中仍然存在需要手动处理的错误或警告,则上述消息具有误导性。例如:
¥The former message is misleading when there’re still errors or warnings in the files that should be taken care of manually. For example:
Checked 2 files in <TIME>. No fixes needed.Found 2 errors.在这些情况下,新消息更合适。
¥The new message suits better in these cases.
贡献者:@Sec-ant
¥Contributed by @Sec-ant
¥Configuration
¥Bug fixes
-
不要隐藏之前的覆盖设置 (#3176)。
¥Don’t conceal previous overrides (#3176).
之前,每个重写都会继承基本配置的未设置配置。这意味着在覆盖中设置的配置可以被继承自基础配置值的后续覆盖所隐藏。
¥Previously, each override inherited the unset configuration of the base configuration. This means that setting a configuration in an override can be concealed by a subsequent override that inherits of the value from the base configuration.
例如,在下一个示例中,
noDebugger已针对index.js文件禁用。¥For example, in the next example,
noDebuggerwas disabled for theindex.jsfile.{"linter": {"rules": {"suspicious": { "noDebugger": "off" }}},"overrides": [{"include": ["index.js"],"linter": {"rules": {"suspicious": { "noDebugger": "warn" }}}}, {"include": ["index.js"],"linter": {"rules": {"suspicious": { "noDoubleEquals": "off" }}}}]}该规则现在已正确启用,适用于
index.js文件。¥The rule is now correctly enabled for the
index.jsfile.贡献者:@Conaclos
¥Contributed by @Conaclos
¥Formatter
¥Bug fixes
-
修复 #3103 问题,正确解析 CSS 格式化选项。贡献者:@ah-yu
¥Fix #3103 by correctly resolving CSS formatter options. Contributed by @ah-yu
-
修复 #3192 不会在 :has 中添加额外的空格的问题。贡献者:@denbezrukov
¥Fix #3192 don’t add an extra whitespace within :has. Contributed by @denbezrukov
JavaScript API
Section titled “JavaScript API”¥Bug fixes
-
修复了
v1.8.0版本引入的回归问题。¥Fix a regression introduced by the release of
v1.8.0
Linter
Section titled “Linter”¥New features
-
添加 nursery/noSubstr。贡献者:@chansuke
¥Add nursery/noSubstr. Contributed by @chansuke
-
添加 nursery/useConsistentCurlyBraces。贡献者:@dyc3
¥Add nursery/useConsistentCurlyBraces. Contributed by @dyc3
-
添加 nursery/useValidAutocomplete。由 @unvalley 提供
¥Add nursery/useValidAutocomplete. Contributed by @unvalley
¥Enhancements
-
为 noUselessCatch 添加代码操作。贡献者:@chansuke
¥Add a code action for noUselessCatch. Contributed by @chansuke
¥Bug fixes
-
添加 nursery/noShorthandPropertyOverrides。#2958 由 @neokidev 贡献
¥Add nursery/noShorthandPropertyOverrides. #2958 Contributed by @neokidev
-
修复 [#3084],修复了正确识别带括号的 return 语句导致的误报问题。由 @unvalley 提供
¥Fix [#3084] false positive by correctly recognize parenthesized return statement. Contributed by @unvalley
-
useImportExtensions 现在会针对
import '.'和import './.'提供正确的修复建议。贡献者:@minht11¥useImportExtensions now suggests a correct fix for
import '.'andimport './.'. Contributed by @minht11 -
修复 useDateNow 在新 Date 对象带有参数
new Date(0).getTime()时出现的误报问题。贡献者:@minht11¥Fix useDateNow false positive when new Date object has arguments
new Date(0).getTime(). Contributed by @minht11. -
noUnmatchableAnbSelector规则现在能够捕获不匹配的an+b选择器,例如0n+0或-0n+0。贡献者:@Sec-ant。¥The
noUnmatchableAnbSelectorrule is now able to catch unmatchablean+bselectors like0n+0or-0n+0. Contributed by @Sec-ant. -
useHookAtTopLevel规则现在可以识别名称为钩子(如foo.useFoo())的属性。贡献者:@ksnyder9801¥The
useHookAtTopLevelrule now recognizes properties named as hooks likefoo.useFoo(). Contributed by @ksnyder9801 -
修复 #3092,防止
Custom properties (--*)发出警告。贡献者:@chansuke¥Fix #3092, prevent warning for
Custom properties (--*). Contributed by @chansuke -
修复了
useLiteralKeys规则中的误报问题。(#3160)¥Fix a false positive in the
useLiteralKeysrule. (#3160)此规则现在忽略以下类型的计算成员名称:
¥This rule now ignores the following kind of computed member name:
const a = {[`line1line2`]: true,};贡献者:@Sec-ant
¥Contributed by @Sec-ant
-
noUnknownProperty 规则现在会忽略 CSS 模块中常用的
composes属性。#3000 由 @chansuke 贡献¥The noUnknownProperty rule now ignores the
composesproperty often used in css modules. #3000 Contributed by @chansuke -
修复了 useExhaustiveDependencies 规则的误报。
¥Fix false positives of the useExhaustiveDependencies rule.
当组件在其内部定义的钩子闭包中递归使用时,该组件本身被认为是稳定的:
¥The component itself is considered stable when it is used recursively inside a hook closure defined inside of it:
import { useMemo } from "react";function MyRecursiveComponent() {// MyRecursiveComponent is stable, we don't need to add it to the dependencies list.const children = useMemo(() => <MyRecursiveComponent />, []);return <div>{children}</div>;}此外,由于
export default function和export default class现在只能出现在模块的顶层,因此被认为是稳定的。¥Also,
export default functionandexport default classare considered stable now because they can only appear at the top level of a module.贡献者:@Sec-ant
¥Contributed by @Sec-ant
-
修复 Vue 文件中全局变量缺少
withDefaults宏的问题。贡献者:@Shyam-Chen¥Fix missing
withDefaultsmacro in vue files for globals variables. Contributed by @Shyam-Chen
¥Parser
¥Bug fixes
-
修复 CSS 模块设置映射。贡献者:@denbezrukov
¥Fix CSS modules settings mapping. Contributed by @denbezrukov
v1.8.1 (2024-06-10)
Section titled “v1.8.1 (2024-06-10)”¥Bug fixes
-
修复 #3069,防止在使用
--staged或--changed选项时覆盖路径。由 @unvalley 提供¥Fix #3069, prevent overwriting paths when using
--stagedor--changedoptions. Contributed by @unvalley -
修复了在 VSCode 运行的终端中,诊断信息中的文件链接显示不正确的问题。由 @uncenter 提供
¥Fix a case where the file link inside a diagnostic wasn’t correctly displayed inside a terminal run by VSCode. Contributed by @uncenter
¥Configuration
¥Bug fixes
-
修复 #3067,为
indentWidth分配正确的默认值。贡献者:@ematipico¥Fix #3067, by assigning the correct default value to
indentWidth. Contributed by @ematipico
¥Formatter
¥Bug fixes
-
修复 CSS 嵌套中 & 字符后的空格被错误修剪的错误,确保正确定位子类 #3061。贡献者:@denbezrukov
¥Fix the bug where whitespace after the & character in CSS nesting was incorrectly trimmed, ensuring proper targeting of child classes #3061. Contributed by @denbezrukov
-
修复了 #3068 中 CSS 格式化程序错误地将变量声明和函数调用转换为小写的问题。贡献者:@denbezrukov
¥Fix #3068 where the CSS formatter was inadvertently converting variable declarations and function calls to lowercase. Contributed by @denbezrukov
-
修复 CSS 网格布局属性的格式。贡献者:@denbezrukov
¥Fix the formatting of CSS grid layout properties. Contributed by @denbezrukov
Linter
Section titled “Linter”¥New features
-
添加 noUnknownPseudoClass。贡献者:@tunamaguro
¥Add noUnknownPseudoClass. Contributed by @tunamaguro
¥Bug fixes
-
noEmptyBlockCSS lint 规则现在会将包含注释的空块视为有效块。贡献者:@Sec-ant¥The
noEmptyBlockcss lint rule now treats empty blocks containing comments as valid ones. Contributed by @Sec-ant -
useLiteralKeys 不再报告带引号的成员名称(#3085)。
¥useLiteralKeys no longer reports quoted member names (#3085).
以前,useLiteralKeys 会报告可以取消引号的带引号的成员名称。例如,该规则建议以下修复:
¥Previously useLiteralKeys reported quoted member names that can be unquoted. For example, the rule suggested the following fix:
const x = { "prop": 0 };const x = { prop: 0 };这与我们的格式化程序的 quoteProperties 选项冲突。
¥This conflicted with the option quoteProperties of our formatter.
该规则现在会忽略带引号的成员名称。
¥The rule now ignores quoted member names.
贡献者:@Conaclos
¥Contributed by @Conaclos
-
noEmptyInterface 现在会忽略环境模块 (#3110) 中的空接口。贡献者:@Conaclos
¥noEmptyInterface now ignores empty interfaces in ambient modules (#3110). Contributed by @Conaclos
-
noUnusedVariables 和 noUnusedFunctionParameters 不再报告构造函数类型的参数 (#3135)。
¥noUnusedVariables and noUnusedFunctionParameters no longer report the parameters of a constructor type (#3135).
之前,在类似这样的构造函数类型中,
arg被报告为未使用:¥Previously,
argwas reported as unused in a constructor type like:export type Classlike = new (arg: unknown) => string;贡献者:@Conaclos
¥Contributed by @Conaclos
-
noStringCaseMismatch 现在会忽略转义序列 (#3134)。
¥noStringCaseMismatch now ignores escape sequences (#3134).
以下代码不再被该规则报告:
¥The following code is no longer reported by the rule:
s.toUpperCase() === "\u001b";贡献者:@Conaclos
¥Contributed by @Conaclos
¥Parser
¥Bug fixes
-
实现 CSS 未知 at 规则解析,允许解析器优雅地处理不支持或无法识别的 CSS at 规则。贡献者:@denbezrukov
¥Implemented CSS Unknown At-Rule parsing, allowing the parser to gracefully handle unsupported or unrecognized CSS at-rules. Contributed by @denbezrukov
-
修复 #3055 CSS:现在,使用命名网格线的布局可以正确解析。贡献者:@denbezrukov
¥Fix #3055 CSS: Layout using named grid lines is now correctly parsed. Contributed by @denbezrukov
-
修复 #3091。允许解析器正确处理嵌套样式规则和 at 规则,从而增强解析器与 CSS 嵌套模块的兼容性。贡献者:@denbezrukov
¥Fix #3091. Allows the parser to handle nested style rules and at-rules properly, enhancing the parser’s compatibility with the CSS Nesting Module. Contributed by @denbezrukov
1.8.0 (2024-06-04)
Section titled “1.8.0 (2024-06-04)”¥Analyzer
¥New features
-
允许使用抑制注释来抑制规则的个别实例。这用于 lint 规则
useExhaustiveDependencies,该规则现在可以抑制特定的依赖。修复 #2509。贡献者:@arendjr¥Allow suppression comments to suppress individual instances of rules. This is used for the lint rule
useExhaustiveDependencies, which is now able to suppress specific dependencies. Fixes #2509. Contributed by @arendjr
¥Enhancements
-
处理
.astro文件时,假设Astro对象始终是全局变量。贡献者:@minht11¥Assume
Astroobject is always a global when processing.astrofiles. Contributed by @minht11 -
处理
.vue文件时,假设 Vue 编译器宏是全局变量。(#2771)贡献者:@dyc3¥Assume Vue compiler macros are globals when processing
.vuefiles. (#2771) Contributed by @dyc3
¥New features
-
新增
clean命令。使用此新命令清理biome-logs目录,并删除所有日志文件。¥New
cleancommand. Use this new command to clean after thebiome-logsdirectory, and remove all the log files.Terminal window biome clean -
向命令
biome lint(#58) 新增两个选项--only和--skip:¥Add two new options
--onlyand--skipto the commandbiome lint(#58).--only选项允许你运行指定的规则或规则组。例如,以下命令仅运行style/useNamingConvention和style/noInferrableTypes规则。如果在配置中禁用规则,则其严重性级别设置为推荐规则的error,否则设置为warn。¥The
--onlyoption allows you to run a given rule or rule group, For example, the following command runs only thestyle/useNamingConventionandstyle/noInferrableTypesrules. If the rule is disabled in the configuration, then its severity level is set toerrorfor a recommended rule orwarnotherwise.Terminal window biome lint --only=style/useNamingConvention --only=style/noInferrableTypes传递组不会改变组中规则的严重级别。组中所有已禁用的规则将保持禁用状态。要确保运行该组,请启用该组的
recommended字段。由于默认未在 nursery 组中启用任何规则,因此无法传递nursery组。¥Passing a group does not change the severity level of the rules in the group. All the disabled rules in the group will remain disabled. To ensure that the group is run, the
recommendedfield of the group is enabled. Thenurserygroup cannot be passed, as no rules are enabled by default in the nursery group.--skip选项允许你跳过执行指定的规则组或规则。例如,以下命令跳过style组和规则suspicious/noExplicitAny。¥The
--skipoption allows you to skip the execution of a given group or a given rule. For example, the following command skips thestylegroup and thesuspicious/noExplicitAnyrule.Terminal window biome lint --skip=style --skip=suspicious/noExplicitAny你还可以同时使用
--only和--skip。--skip会覆盖--only。以下命令仅执行style组中的规则,但不包括style/useNamingConvention规则。¥You can also use
--onlyand--skiptogether.--skipoverrides--only. The following command executes only the rules from thestylegroup, but thestyle/useNamingConventionrule.Terminal window biome lint --only=style --skip=style/useNamingConvention这些选项与其他选项(例如
--write(以前称为--apply)和--reporter)兼容。¥These options are compatible with other options such as
--write(previously--apply), and--reporter.贡献者:@Conaclos
¥Contributed by @Conaclos
-
添加新命令
biome clean。使用此命令可清除 Biome 守护程序发出的所有日志。此命令非常有用,因为 Biome 守护进程在其生命周期内往往会记录大量文件和内容。这意味着,如果你的编辑器长时间(甚至几天)保持打开状态,则biome-logs文件夹可能会变得非常大。贡献者:@ematipico¥Add new command
biome clean. Use this command to purge all the logs emitted by the Biome daemon. This command is really useful, because the Biome daemon tends log many files and contents during its lifecycle. This means that if your editor is open for hours (or even days), thebiome-logsfolder could become quite heavy. Contributed by @ematipico -
添加对通过 CLI 格式化和检查 CSS 文件的支持。这些操作目前是可选的。
¥Add support for formatting and linting CSS files from the CLI. These operations are opt-in for the time being.
如果你没有配置文件,可以使用
--css-formatter-enabled和--css-linter-enabled启用以下功能:¥If you don’t have a configuration file, you can enable these features with
--css-formatter-enabledand--css-linter-enabled:Terminal window biome check --css-formatter-enabled=true --css-linter-enabled=true ./贡献者:@ematipico
¥Contributed by @ematipico
-
新增 CLI 选项,用于控制 CSS 格式。查看 CLI 参考页面 以了解更多详情。贡献者:@ematipico
¥Add new CLI options to control the CSS formatting. Check the CLI reference page for more details. Contributed by @ematipico
-
为命令
biome lint和biome check添加新选项--write、--fix(--write的别名)和--unsafe。向命令biome format和biome migrate添加一个新的选项--fix(--write的别名)。¥Add new options
--write,--fix(alias of--write) and--unsafeto the commandbiome lintandbiome check. Add a new option--fix(alias of--write) to the commandbiome formatandbiome migrate.Terminal window biome <lint|check> --<write|fix> [--unsafe]biome format --<write|fix>biome migrate --<write|fix>biome <lint|check> --<write|fix>的行为与biome <lint|check> --apply相同。biome <lint|check> --<write|fix> --unsafe的行为与biome <lint|check> --apply-unsafe相同。biome format --fix的行为与biome format --write相同。biome migrate --fix的行为与biome migrate --write相同。¥The
biome <lint|check> --<write|fix>has the same behavior asbiome <lint|check> --apply. Thebiome <lint|check> --<write|fix> --unsafehas the same behavior asbiome <lint|check> --apply-unsafe. Thebiome format --fixhas the same behavior asbiome format --write. Thebiome migrate --fixhas the same behavior asbiome migrate --write.此更改允许这些命令在相同的选项中写入修改。此次更改后,
--apply和--apply-unsafe选项将被弃用。¥This change allows these commands to write modifications in the same options. With this change, the
--applyand--apply-unsafeoptions are deprecated.由 @unvalley 提供
¥Contributed by @unvalley
¥Enhancements
-
Biome 现在默认在工作目录上执行命令(lint、format、check 和 ci)。#2266 由 @unvalley 提供
¥Biome now executes commands (lint, format, check and ci) on the working directory by default. #2266 Contributed by @unvalley
biome check .biome check # You can run the command without the path -
biome migrate eslint现在尝试将 ESLint 忽略模式转换为 Biome 忽略模式。¥
biome migrate eslintnow tries to convert ESLint ignore patterns into Biome ignore patterns.ESLint 使用 gitignore 模式。Biome 现在会尝试将这些模式转换为 Biome 忽略模式。
¥ESLint uses gitignore patterns. Biome now tries to convert these patterns into Biome ignore patterns.
例如,.gitignore 模式
/src是它所在文件的相对路径。Biome 现在可以识别此模式并将其转换为./src。¥For example, the gitignore pattern
/srcis a relative path to the file in which it appears. Biome now recognizes this and translates this pattern to./src.贡献者:@Conaclos
¥Contributed by @Conaclos
-
biome migrate eslint现在支持package.json中的eslintIgnore字段。¥
biome migrate eslintnow supports theeslintIgnorefield inpackage.json.ESLint 允许使用
package.json作为 ESLint 配置文件。ESLint 支持两个字段:eslintConfig和eslintIgnore。Biome 之前仅支持第一个命令。现在同时支持两者。¥ESLint allows the use of
package.jsonas an ESLint configuration file. ESLint supports two fields:eslintConfigandeslintIgnore. Biome only supported the former. It now supports both.贡献者:@Conaclos
¥Contributed by @Conaclos
-
biome migrate eslint现在会将 NodeJS 错误传递给用户。¥
biome migrate eslintnow propagates NodeJS errors to the user.这将帮助用户确定 Biome 无法加载某些 ESLint 配置的原因。
¥This will help users to identify why Biome is unable to load some ESLint configurations.
贡献者:@Conaclos
¥Contributed by @Conaclos
-
添加一个名为
summary的新--reporter。此报告器将根据执行的工具(格式化程序、代码检查器等)以不同的方式打印诊断信息。导入排序和格式化功能会显示需要格式化的文件的名称。相反,代码检查器会将触发的规则数量和错误/警告数量分组:¥Add a new
--reportercalledsummary. This reporter will print diagnostics in a different way, based on the tools (formatter, linter, etc.) that are executed. Import sorting and formatter shows the name of the files that require formatting. Instead, the linter will group the number of rules triggered and the number of errors/warnings:Formatter ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━The following files needs to be formatted:main.tsindex.tsOrganize Imports ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━The following files needs to have their imports sorted:main.tsindex.tsAnalyzer ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━Some analyzer rules were triggeredRule Name Diagnosticslint/suspicious/noImplicitAnyLet 12 (12 error(s), 0 warning(s), 0 info(s))lint/suspicious/noDoubleEquals 8 (8 error(s), 0 warning(s), 0 info(s))lint/suspicious/noRedeclare 12 (12 error(s), 0 warning(s), 0 info(s))lint/suspicious/noDebugger 20 (20 error(s), 0 warning(s), 0 info(s))贡献者:@ematipico
¥Contributed by @ematipico
-
biome ci现在强制使用颜色打印输出。如果你之前使用过--colors=force,则可以将其删除,因为它会自动设置。贡献者:@ematipico¥
biome cinow enforces printing the output using colours. If you were previously using--colors=force, you can remove it because it’s automatically set. Contributed by @ematipico -
添加一个名为
github的新--reporter。此报告器将使用 GitHub 工作流命令 严重级别打印诊断信息:¥Add a new
--reportercalledgithub. This reporter will print diagnostics using GitHub workflow commands:::error title=lint/suspicious/noDoubleEquals,file=main.ts,line=4,endLine=4,col=3,endColumn=5::Use === instead of ==::error title=lint/suspicious/noDebugger,file=main.ts,line=6,endLine=6,col=1,endColumn=9::This is an unexpected use of the debugger statement.::error title=lint/nursery/noEvolvingAny,file=main.ts,line=8,endLine=8,col=5,endColumn=6::This variable's type is not allowed to evolve implicitly, leading to potential any types.贡献者:@ematipico
¥Contributed by @ematipico
-
添加一个名为
junit的新--reporter。此报告器将使用 GitHub 工作流命令 严重级别打印诊断信息:¥Add a new
--reportercalledjunit. This reporter will print diagnostics using GitHub workflow commands:<?xml version="1.0" encoding="UTF-8"?><testsuites name="Biome" tests="16" failures="16" errors="20" time="<TIME>"><testsuite name="main.ts" tests="1" disabled="0" errors="0" failures="1" package="org.biome"><testcase name="org.biome.lint.suspicious.noDoubleEquals" line="4" column="3"><failure message="Use === instead of ==. == is only allowed when comparing against `null`">line 3, col 2, Use === instead of ==. == is only allowed when comparing against `null`</failure></testcase></testsuite><testsuite name="main.ts" tests="1" disabled="0" errors="0" failures="1" package="org.biome"><testcase name="org.biome.lint.suspicious.noDebugger" line="6" column="1"><failure message="This is an unexpected use of the debugger statement.">line 5, col 0, This is an unexpected use of the debugger statement.</failure></testcase></testsuite><testsuite name="main.ts" tests="1" disabled="0" errors="0" failures="1" package="org.biome"><testcase name="org.biome.lint.nursery.noEvolvingAny" line="8" column="5"><failure message="This variable's type is not allowed to evolve implicitly, leading to potential any types.">line 7, col 4, This variable's type is not allowed to evolve implicitly, leading to potential any types.</failure></testcase></testsuite></testsuites>贡献者:@ematipico
¥Contributed by @ematipico
¥Bug fixes
-
修复 #3024,即运行
biome init时即使biome.jsonc已存在也会创建biome.json。贡献者:@minht11¥Fix #3024, where running
biome initwould createbiome.jsoneven ifbiome.jsoncalready exists. Contributed by @minht11
¥Configuration
¥New features
-
新增规则选项
fix,用于覆盖代码修复规则 (#2882)。¥Add an rule option
fixto override the code fix kind of a rule (#2882).规则可以提供安全或不安全的代码操作。现在,你可以借助
fix选项调整代码操作的类型。此规则选项的值可以是:¥A rule can provide a safe or an unsafe code action. You can now tune the kind of code actions thanks to the
fixoption. This rule option takes a value among:-
none:该规则不再发出代码操作。¥
none: the rule no longer emits code actions. -
safe:该规则发出安全的代码操作。¥
safe: the rule emits safe code action. -
unsafe:该规则发出不安全的代码操作。¥
unsafe: the rule emits unsafe code action.
以下配置禁用
noUnusedVariables的代码操作,并将style/useConst和style/useTemplate生成的代码操作分别标记为不安全和安全。¥The following configuration disables the code actions of
noUnusedVariables, makes the emitted code actions ofstyle/useConstandstyle/useTemplateunsafe and safe respectively.{"linter": {"rules": {"correctness": {"noUnusedVariables": {"level": "error","fix": "none"},"style": {"useConst": {"level": "warn","fix": "unsafe"},"useTemplate": {"level": "warn","fix": "safe"}}}}}}贡献者:@Conaclos
¥Contributed by @Conaclos
-
-
添加选项
javascript.linter.enabled,用于控制 JavaScript(及其上级语言)文件的代码检查器。贡献者:@ematipico¥Add option
javascript.linter.enabledto control the linter for JavaScript (and its super languages) files. Contributed by @ematipico -
添加选项
json.linter.enabled,用于控制 JSON(及其上级语言)文件的代码检查器。贡献者:@ematipico¥Add option
json.linter.enabledto control the linter for JSON (and its super languages) files. Contributed by @ematipico -
添加选项
css.linter.enabled,用于控制 CSS(及其上级语言)文件的代码检查器。贡献者:@ematipico¥Add option
css.linter.enabledto control the linter for CSS (and its super languages) files. Contributed by @ematipico -
添加选项
css.formatter,用于控制 CSS(及其上级语言)文件的格式化选项。贡献者:@ematipico¥Add option
css.formatter, to control the formatter options for CSS (and its super languages) files. Contributed by @ematipico -
现在,你可以将 lint 规则的严重级别降低到
"info"。"info"严重级别不会发出错误代码,并且不受其他选项(例如--error-on-warnings)的影响:¥You can now change the severity of lint rules down to
"info". The"info"severity doesn’t emit error codes, and it isn’t affected by other options like--error-on-warnings:{"linter": {"rules": {"suspicious": {"noDebugger": "info"}}}}贡献者:@ematipico
¥Contributed by @ematipico
¥Enhancements
-
javascript.formatter.trailingComma选项已弃用并重命名为javascript.formatter.trailingCommas。对应的 CLI 选项--trailing-comma也已弃用并重命名为--trailing-commas。详情请参阅 #2492。贡献者:@Sec-ant¥The
javascript.formatter.trailingCommaoption is deprecated and renamed tojavascript.formatter.trailingCommas. The corresponding CLI option--trailing-commais also deprecated and renamed to--trailing-commas. Details can be checked in #2492. Contributed by @Sec-ant
¥Bug fixes
-
修复了如果格式化程序在语言级别被禁用,则可能由于未指定格式化程序部分的覆盖而错误地启用格式化程序的问题。贡献者:@dyc3
¥Fix a bug where if the formatter was disabled at the language level, it could be erroneously enabled by an override that did not specify the formatter section #2924. Contributed by @dyc3
-
修复 #2990,现在 Biome 在格式化
biome.json时不会添加尾随逗号。贡献者:@dyc3¥Fix #2990, now Biome doesn’t add a trailing comma when formatting
biome.json. Contributed by @dyc3
¥Editors
¥New features
-
添加对 LSP 工作区的支持。
¥Add support for LSP Workspaces
¥Enhancements
-
当配置文件包含错误时,LSP 不再崩溃。如果配置包含错误,Biome 现在会向用户显示弹出窗口,并且只会使用默认配置解析文件。在配置文件修复之前,格式化和代码检查功能将被禁用。贡献者:@ematipico
¥The LSP doesn’t crash anymore when the configuration file contains errors. If the configuration contains errors, Biome now shows a pop-up to the user, and it will only parse files using the default configuration. Formatting and linting is disabled until the configuration file is fixed. Contributed by @ematipico
¥Bug fixes
-
通过正确计算要应用于特定文件的配置来修复 #2781。贡献者:@ematipico
¥Fixes #2781, by correctly computing the configuration to apply to a specific file. Contributed by @ematipico
¥Formatter
¥Bug fixes
-
修复 #2470,避免在单行字符串插值中引入换行符。贡献者:@ah-yu
¥Fix #2470 by avoid introducing linebreaks in single line string interpolations. Contributed by @ah-yu
-
通过缩小锁的作用域来解决死锁问题。贡献者:@mechairoi
¥Resolve deadlocks by narrowing the scope of locks. Contributed by @mechairoi
-
修复 #2782,考虑覆盖设置来计算启用的规则。贡献者:@ematipico
¥Fix #2782 by computing the enabled rules by taking the override settings into consideration. Contributed by @ematipico
-
修复 [https://github.com/biomejs/biome/issues/2877],修复了正确处理 JSX 字符串中的行终止符的问题。贡献者:@ah-yu
¥Fix [https://github.com/biomejs/biome/issues/2877] by correctly handling line terminators in JSX string. Contributed by @ah-yu
Linter
Section titled “Linter”¥Promoted rules
新规则在 nursery 组中进行孵化。一旦稳定下来,我们就将它们提升为稳定规则。以下规则已推广:
¥New rules are incubated in the nursery group. Once stable, we promote them to a stable group. The following rules are promoted:
¥New features
-
添加 nursery/useDateNow。贡献者:@minht11
¥Add nursery/useDateNow. Contributed by @minht11
-
添加 nursery/useErrorMessage。贡献者:@minht11
¥Add nursery/useErrorMessage. Contributed by @minht11
-
添加 nursery/useThrowOnlyError。贡献者:@minht11
¥Add nursery/useThrowOnlyError. Contributed by @minht11
-
添加 nursery/useImportExtensions。贡献者:@minht11
¥Add nursery/useImportExtensions. Contributed by @minht11
-
useNamingConvention 现在支持强制执行自定义约定的选项 (#1900)。
¥useNamingConvention now supports an option to enforce custom conventions (#1900).
例如,你可以强制私有类成员使用前缀:
¥For example, you can enforce the use of a prefix for private class members:
{"linter": {"rules": {"style": {"useNamingConvention": {"level": "error","options": {"conventions": [{"selector": {"kind": "classMember","modifiers": ["private"]},"match": "_(.*)","formats": ["camelCase"]}]}}}}}}更多详情请参阅 规则文档。
¥Please, find more details in the rule documentation.
贡献者:@Conaclos
¥Contributed by @Conaclos
-
添加 nursery/useNumberToFixedDigitsArgument。贡献者:@minht11
¥Add nursery/useNumberToFixedDigitsArgument. Contributed by @minht11
-
添加 nursery/useThrowNewError。贡献者:@minht11
¥Add nursery/useThrowNewError. Contributed by @minht11
-
添加 nursery/useTopLevelRegex,强制在模块的顶层定义正则表达式。#2148 由 @dyc3 贡献。
¥Add nursery/useTopLevelRegex, which enforces defining regular expressions at the top level of a module. #2148 Contributed by @dyc3.
-
添加 nursery/noCssEmptyBlock。#2513 由 @togami2864 贡献
¥Add nursery/noCssEmptyBlock. #2513 Contributed by @togami2864
-
添加 nursery/noDuplicateAtImportRules。#2658 由 @DerTimonius 贡献
¥Add nursery/noDuplicateAtImportRules. #2658 Contributed by @DerTimonius
-
添加 nursery/noDuplicateFontNames。#2308 由 @togami2864 贡献
¥Add nursery/noDuplicateFontNames. #2308 Contributed by @togami2864
-
添加 nursery/noDuplicateSelectorsKeyframeBlock。#2534 由 @isnakode 贡献
¥Add nursery/noDuplicateSelectorsKeyframeBlock. #2534 Contributed by @isnakode
-
添加 nursery/noImportantInKeyframe。#2542 由 @isnakode 贡献
¥Add nursery/noImportantInKeyframe. #2542 Contributed by @isnakode
-
添加 nursery/noInvalidPositionAtImportRule。#2717 由 @t-shiratori 贡献
¥Add nursery/noInvalidPositionAtImportRule. #2717 Contributed by @t-shiratori
-
添加 nursery/noUnknownFunction。#2570 由 @neokidev 贡献
¥Add nursery/noUnknownFunction. #2570 Contributed by @neokidev
-
添加 nursery/noUnknownMediaFeatureName。#2751 由 @Kazuhiro-Mimaki 贡献
¥Add nursery/noUnknownMediaFeatureName. #2751 Contributed by @Kazuhiro-Mimaki
-
添加 nursery/noUnknownProperty。#2755 由 @chansuke 贡献
¥Add nursery/noUnknownProperty. #2755 Contributed by @chansuke
-
添加 nursery/noUnknownPseudoElement。#2655 由 @keita-hino 贡献
¥Add nursery/noUnknownPseudoElement. #2655 Contributed by @keita-hino
-
添加 nursery/noUnknownUnit。#2535 由 @neokidev 贡献
¥Add nursery/noUnknownUnit. #2535 Contributed by @neokidev
-
添加 nursery/noUnmatchableAnbSelector。#2706 由 @togami2864 贡献
¥Add nursery/noUnmatchableAnbSelector. #2706 Contributed by @togami2864
-
添加 nursery/useGenericFontNames。#2573 由 @togami2864 贡献
¥Add nursery/useGenericFontNames. #2573 Contributed by @togami2864
-
添加 nursery/noYodaExpression。贡献者:@michellocana
¥Add nursery/noYodaExpression. Contributed by @michellocana
-
添加 nursery/noUnusedFunctionParameters 选项,由 @printfn 贡献
¥Add nursery/noUnusedFunctionParameters Contributed by @printfn
-
添加 nursery/UseSemanticElements。贡献者:@fujiyamaorange
¥Add nursery/UseSemanticElements. Contributed by @fujiyamaorange
¥Enhancements
-
为 noConfusingVoidType 添加代码操作并改进诊断功能。
¥Add a code action for noConfusingVoidType and improve the diagnostics.
该规则现在建议在容易混淆的地方使用
undefined而不是void。诊断信息也更加清晰。¥The rule now suggests using
undefinedinstead ofvoidin confusing places. The diagnosis is also clearer.贡献者:@Conaclos
¥Contributed by @Conaclos
-
改进 nursery/noUselessUndefinedInitialization 的代码操作以处理注释。
¥Improve code action for nursery/noUselessUndefinedInitialization to handle comments.
该规则现在会在声明语句后添加行内注释,而不是将其删除。现在可以安全地应用此代码操作。
¥The rule now places inline comments after the declaration statement, instead of removing them. The code action is now safe to apply.
贡献者:@lutaok
¥Contributed by @lutaok
-
使 useExhaustiveDependencies 报告重复依赖。贡献者: @tunamaguro
¥Make useExhaustiveDependencies report duplicate dependencies. Contributed by @tunamaguro
-
将
noEvolvingAny重命名为noEvolvingTypes(#48)。贡献者:@Conaclos¥Rename
noEvolvingAnyintonoEvolvingTypes(#48). Contributed by @Conaclos
¥Bug fixes
-
noUndeclaredVariables 和 noUnusedImports 现在可以正确处理导入命名空间 (#2796)。
¥noUndeclaredVariables and noUnusedImports now correctly handle import namespaces (#2796).
之前,Biome 会将未限定的类型绑定到导入命名空间。导入命名空间只能在类型(环境)上下文中用作限定名称。
¥Previously, Biome bound unqualified type to import namespaces. Import namespaces can only be used as qualified names in a type (ambient) context.
// Unused importimport * as Ns1 from "";// This doesn't reference the import namespace `Ns1`type T1 = Ns1; // Undeclared variable `Ns1`// Unused importimport type * as Ns2 from "";// This doesn't reference the import namespace `Ns2`type T2 = Ns2; // Undeclared variable `Ns2`import type * as Ns3 from "";// This references the import namespace because it is a qualified name.type T3 = Ns3.Inner;// This also references the import namespace.export type { Ns3 }贡献者:@Conaclos
¥Contributed by @Conaclos
-
noUndeclaredVariables 现在能够正确处理环境计算成员名称 (#2975)。
¥noUndeclaredVariables now correctly handle ambient computed member names (#2975).
常量可以作为类型导入,并在成员签名的计算成员名称中使用。之前,Biome 无法将作为类型导入的值绑定到计算成员名称。
¥A constant can be imported as a type and used in a computed member name of a member signature. Previously, Biome was unable to bind the value imported as a type to the computed member name.
import type { NAME } from "./constants.js";type X = { [NAME]: number };贡献者:@Conaclos
¥Contributed by @Conaclos
-
noUndeclaredVariables 现在会忽略 JSX 组件中的
this(#2636)。¥noUndeclaredVariables now ignores
thisin JSX components (#2636).该规则不再将以下代码中的
this报告为未声明。¥The rule no longer reports
thisas undeclared in following code.import { Component } from 'react';export class MyComponent extends Component {render() {return <this.foo />}}由 @printfn 和 @Conaclos 贡献
¥Contributed by @printfn and @Conaclos
-
useJsxKeyInIterable现在支持更多涉及片段的情况。请参阅以下片段。贡献者:@dyc3¥
useJsxKeyInIterablenow handles more cases involving fragments. See the snippets below. Contributed by @dyc3
// valid[].map((item) => { return <>{item.condition ? <div key={item.id}/> : <div key={item.id}>foo</div>}</>;});
// invalid[].map((item) => { return <>{item.condition ? <div/> : <div>foo</div>}</>;});-
noExcessiveNestedTestSuites不再对未调用全局describe函数的describe调用发出错误警报。#2599 由 @dyc3 贡献¥
noExcessiveNestedTestSuitesno longer erroneously alerts ondescribecalls that are not invoking the globaldescribefunction. #2599 Contributed by @dyc3
// now validz.object({}) .describe('') .describe('') .describe('') .describe('') .describe('') .describe('');noEmptyBlockStatements 不再报告使用 TypeScript 参数属性的空构造函数。#3005 由 @dyc3 贡献
¥noEmptyBlockStatements no longer reports empty constructors using typescript parameter properties. #3005 Contributed by @dyc3
-
noEmptyBlockStatements不再报告空的私有或受保护构造函数。贡献者:@dyc3¥
noEmptyBlockStatementsno longer reports empty private or protected constructors. Contributed by @dyc3 -
noExportsInTest 规则不再将包含源代码内测试的文件视为测试文件 (https://github.com/biomejs/biome/issues/2859)。贡献者:@ah-yu
¥noExportsInTest rule no longer treats files with in-source testing as test files https://github.com/biomejs/biome/issues/2859. Contributed by @ah-yu
-
useSortedClasses 现在会在模板字面量中应用代码操作时保留前导和尾随空格。
¥useSortedClasses now keeps leading and trailing spaces when applying the code action inside template literals:
i Unsafe fix: Sort the classes.1 1 │ <>2 │ - → <div·class={`${variable}·px-2·foo·p-4·bar`}/>2 │ + → <div·class={`${variable}·foo·bar·p-4·px-2`}/>3 3 │ <div class={`px-2 foo p-4 bar ${variable}`}/>4 4 │ </> -
运行
biome ci时,noUndeclaredDependencies 会被正确触发。贡献者:@ematipico¥noUndeclaredDependencies is correctly triggered when running
biome ci. Contributed by @ematipico -
noUnusedVariables 不再因输入特定字符组合而引发 panic。贡献者:@ematipico
¥noUnusedVariables no longer panics when a certain combination of characters is typed. Contributed by @ematipico
-
noUndeclaredVariables 不再对函数作用域中的
arguments对象发出日志记录警报。贡献者:@ah-yu¥noUndeclaredVariables no logger alerts on
argumentsobject in a function scope. Contributed by @ah-yu
¥Parser
¥Enhancements
Vue 单文件组件现已支持 lang="tsx"。#2765 由 @dyc3 贡献
¥lang="tsx" is now supported in Vue Single File Components. #2765 Contributed by @dyc3
¥Bug fixes
-
TypeScript
new签名(#2825)现在接受类型参数的const修饰符。¥The
constmodifier for type parameters is now accepted for TypeScriptnewsignatures (#2825).以下代码现在可以被正确解析:
¥The following code is now correctly parsed:
interface I {new<const T>(x: T): T}贡献者:@Conaclos
¥Contributed by @Conaclos
-
一些无效的 TypeScript 语法导致 Biome 解析器崩溃。
¥Some invalid TypeScript syntax caused the Biome parser to crash.
以下无效语法不再导致 Biome 解析器崩溃:
¥The following invalid syntax no longer causes the Biome parser to crash:
declare using x: null;declare qwait using x: null;贡献者:@Conaclos
¥Contributed by @Conaclos
1.7.3 (2024-05-06)
Section titled “1.7.3 (2024-05-06)”¥Bug fixes
-
stdin-file-path 选项现在可以正确处理 Astro/Svelte/Vue 文件 (#2686)。
¥The stdin-file-path option now works correctly for Astro/Svelte/Vue files (#2686)
修复了 #2225 中 Vue 文件的 lint 输出为空的问题。
¥Fix #2225 where lint output become empty for Vue files.
贡献者:@tasshi-me
¥Contributed by @tasshi-me
-
biome migrate eslint现在可以正确解析@scope/eslint-config(#2705)。贡献者:@Conaclos¥
biome migrate eslintnow correctly resolve@scope/eslint-config(#2705). Contributed by @Conaclos
Linter
Section titled “Linter”¥New features
-
添加 nursery/useExplicitLengthCheck。贡献者:@minht11
¥Add nursery/useExplicitLengthCheck. Contributed by @minht11
useExhaustiveDependencies 现在能够识别每次渲染都会更改的(某些)依赖 (#2374)。贡献者:@arendjr
¥useExhaustiveDependencies now recognizes (some) dependencies that change on every render (#2374). Contributed by @arendjr
¥Bug fixes
-
noBlankTarget 在应用代码修复 (#2675) 时不再挂起。
¥noBlankTarget no longer hangs when applying a code fix (#2675).
之前,以下代码会导致 Biome 在应用代码修复时挂起。
¥Previously, the following code made Biome hangs when applying a code fix.
<a href="https://example.com" rel="" target="_blank"></a>贡献者:@Conaclos
¥Contributed by @Conaclos
-
noRedeclare 不再因条件类型 (#2659) 而引发 panic。
¥noRedeclare no longer panics on conditional type (#2659).
这是 #2394 引入的一个回归问题。此回归导致
noRedeclare在所有使用infer绑定的条件类型上都引发 panic。¥This is a regression introduced by #2394. This regression makes
noRedeclarepanics on every conditional types withinferbindings.贡献者:@Conaclos
¥Contributed by @Conaclos
-
noUnusedLabels 和 noConfusingLabels 现在忽略 Svelte 响应式语句 (#2571)。
¥noUnusedLabels and noConfusingLabels now ignore svelte reactive statements (#2571).
这些规则现在会忽略 Svelte 组件中的响应式 Svelte 代码块。
¥The rules now ignore reactive Svelte blocks in Svelte components.
<script>$: { /* reactive block */ }</script>贡献者:@Conaclos
¥Contributed by @Conaclos
-
useExportType 不再移除前导注释 (#2685)。
¥useExportType no longer removes leading comments (#2685).
之前,
useExportType在分解type限定符时会移除前导注释。现在,会提供一个代码修复方案,保留前导注释:¥Previously,
useExportTyperemoved leading comments when it factorized thetypequalifier. It now provides a code fix that preserves the leading comments:export {export type {/**leading comment*/type TT}贡献者:@Conaclos
¥Contributed by @Conaclos
-
useJsxKeyInIterable 不再报告迭代非 JSX 项时的误报 (#2590)。
¥useJsxKeyInIterable no longer reports false positive when iterating on non-jsx items (#2590).
以下代码片段不再触发此规则:
¥The following snippet of code no longer triggers the rule:
<>{data.reduce((total, next) => total + next, 0)}</>贡献者:@dyc3
¥Contributed by @dyc3
-
修复拼写错误,将
useConsistentBuiltinInstatiation重命名为useConsistentBuiltinInstantiation。贡献者:@minht11¥Fix typo by renaming
useConsistentBuiltinInstatiationtouseConsistentBuiltinInstantiationContributed by @minht11 -
修复规则
useSingleCaseStatement在计算switch语句中的语句数时包含break语句的问题 (#2696)。¥Fix the rule
useSingleCaseStatementincludingbreakstatements when counting the number of statements in aswitchstatement (#2696)
1.7.2 (2024-04-30)
Section titled “1.7.2 (2024-04-30)”¥Analyzer
¥Bug fixes
-
导入排序现在会忽略副作用导入 (#817)。
¥Import sorting now ignores side effect imports (#817).
副作用导入现在有其自己的组。这确保副作用导入不会被重新排序。
¥A side effect import consists now in its own group. This ensures that side effect imports are not reordered.
以下是导入排序方式的示例:
¥Here is an example of how imports are now sorted:
import "z"import { D } from "d";import { C } from "c";import { D } from "d";import "y"import "x"import { B } from "b";import { A } from "a";import { B } from "b";import "w"贡献者:@Conaclos
¥Contributed by @Conaclos
-
导入排序现在会在需要的地方添加空格 (#1665)。由 @Conaclos 贡献。
¥Import sorting now adds spaces where needed (#1665) Contributed by @Conaclos
¥Bug fixes
-
biome migrate eslint现在支持循环引用。¥
biome migrate eslintnow handles cyclic references.某些插件和配置会导出带有循环引用的对象。这会导致
biome migrate eslint失败或忽略它们。这些特殊情况现在可以正确处理。¥Some plugins and configurations export objects with cyclic references. This causes
biome migrate eslintto fail or ignore them. These edge cases are now handled correctly.贡献者:@Conaclos
¥Contributed by @Conaclos
¥Formatter
¥Bug fixes
-
正确处理命名导入语句中注释的位置。#2566。贡献者:@ah-yu
¥Correctly handle placement of comments inside named import clauses. #2566. Contributed by @ah-yu
Linter
Section titled “Linter”¥New features
-
添加 nursery/noReactSpecificProps。贡献者: @marvin-j97
¥Add nursery/noReactSpecificProps. Contributed by @marvin-j97
-
添加 noUselessUndefinedInitialization。贡献者:@lutaok
¥Add noUselessUndefinedInitialization. Contributed by @lutaok
-
添加 nursery/useArrayLiterals。贡献者:@Kazuhiro-Mimaki
¥Add nursery/useArrayLiterals. Contributed by @Kazuhiro-Mimaki
-
添加 nursery/useConsistentBuiltinInstatiation。贡献者:@minht11
¥Add nursery/useConsistentBuiltinInstatiation. Contributed by @minht11
-
添加 nursery/useDefaultSwitchClause。贡献者:@michellocana
¥Add nursery/useDefaultSwitchClause. Contributed by @michellocana
¥Bug fixes
-
noDuplicateJsonKeys 不再导致 JSON 文件包含未终止字符串时崩溃 (#2357)。贡献者:@Conaclos
¥noDuplicateJsonKeys no longer crashes when a JSON file contains an unterminated string (#2357). Contributed by @Conaclos
-
noRedeclare 现在报告函数体中参数的重复声明 (#2394)。
¥noRedeclare now reports redeclarations of parameters in a functions body (#2394).
该规则无法检测到函数体中参数或类型参数的重复声明。现在会报告以下两个重复声明:
¥The rule was unable to detect redeclarations of a parameter or a type parameter in the function body. The following two redeclarations are now reported:
function f<T>(a) {type T = number; // redeclarationconst a = 0; // redeclaration}贡献者:@Conaclos
¥Contributed by @Conaclos
-
noRedeclare 不再报告对象类型(#2608)中的重载。
¥noRedeclare no longer reports overloads in object types (#2608).
该规则不再报告以下代码中的重复声明:
¥The rule no longer report redeclarations in the following code:
type Overloads = {({ a }: { a: number }): number,({ a }: { a: string }): string,};贡献者:@Conaclos
¥Contributed by @Conaclos
-
noRedeclare 现在会合并默认函数导出声明和类型 (#2372)。
¥noRedeclare now merge default function export declarations and types (#2372).
以下代码不再被报告为重复声明:
¥The following code is no longer reported as a redeclaration:
interface Foo {}export default function Foo() {}贡献者:@Conaclos
¥Contributed by @Conaclos
-
noUndeclaredVariables 不再报告仅变量导出和仅类型导出 (#2637)。贡献者:@Conaclos
¥noUndeclaredVariables no longer reports variable-only and type-only exports (#2637). Contributed by @Conaclos
-
noUnusedVariables 不再导致 Biome 在遇到格式错误的条件类型 (#1695) 时崩溃。贡献者:@Conaclos
¥noUnusedVariables no longer crash Biome when encountering a malformed conditional type (#1695). Contributed by @Conaclos
-
useConst 现在会忽略在赋值之前读取的变量。
¥useConst now ignores a variable that is read before its assignment.
之前,该规则会报告以下示例:
¥Previously, the rule reported the following example:
let x;x; // readx = 0; // write现在它已被正确忽略。
¥It is now correctly ignored.
贡献者:@Conaclos
¥Contributed by @Conaclos
-
当需要使用括号时 (#2595),useShorthandFunctionType 现在会提供正确的代码修复建议。
¥useShorthandFunctionType now suggests correct code fixes when parentheses are required (#2595).
之前,规则在需要时没有添加括号。现在,当函数签名位于数组、并集或交集内时,会自动添加括号。
¥Previously, the rule didn’t add parentheses when they were needed. It now adds parentheses when the function signature is inside an array, a union, or an intersection.
type Union = { (): number } | string;type Union = (() => number) | string;贡献者:@Conaclos
¥Contributed by @Conaclos
-
useTemplate 现在能够正确转义字符串 (#2580)。
¥useTemplate now correctly escapes strings (#2580).
之前,规则没有正确转义前面带有转义字符的字符。
¥Previously, the rule didn’t correctly escape characters preceded by an escaped character.
贡献者:@Conaclos
¥Contributed by @Conaclos
-
noMisplacedAssertion 现在支持以下匹配器。
¥noMisplacedAssertion now allow these matchers
-
expect.any() -
expect.anything() -
expect.closeTo -
expect.arrayContaining -
expect.objectContaining -
expect.stringContaining -
expect.stringMatching -
expect.extend -
expect.addEqualityTesters -
expect.addSnapshotSerializer
贡献者:@fujiyamaorange
¥Contributed by @fujiyamaorange
-
¥Parser
¥Bug fixes
-
语言解析器不再对未终止的字符串后跟换行符和空格的情况报错(#2606、#2410)。
¥The language parsers no longer panic on unterminated strings followed by a newline and a space (#2606, #2410).
以下示例现在可以解析,而不会导致 Biome 崩溃:
¥The following example is now parsed without making Biome panics:
""贡献者:@Conaclos
¥Contributed by @Conaclos
1.7.1 (2024-04-22)
Section titled “1.7.1 (2024-04-22)”¥Editors
¥Bug fixes
-
修复 #2403 问题,在客户端控制台中打印错误信息。贡献者:@ematipico
¥Fix #2403 by printing the errors in the client console. Contributed by @ematipico
¥Formatter
¥Bug fixes
-
为带有前导多行注释的返回表达式添加括号。#2504。贡献者:@ah-yu
¥Add parentheses for the return expression that has leading multiline comments. #2504. Contributed by @ah-yu
-
正确格式化 continue 语句的悬空注释。#2555。贡献者:@ah-yu
¥Correctly format dangling comments of continue statements. #2555. Contributed by @ah-yu
-
防止注释被格式化程序 #2578 吞噬。现在以下代码的注释不会被忽略:
¥Prevent comments from being eaten by the formatter #2578. Now the comments won’t be eaten for the following code:
console.log((a,b/* comment */));贡献者:@ah-yu
¥Contributed by @ah-yu
-
正确格式化嵌套的联合类型,以避免重新格式化问题。#2628。贡献者:@ah-yu
¥Correctly format nested union type to avoid reformatting issue. #2628. Contributed by @ah-yu
Linter
Section titled “Linter”¥Bug fixes
-
修复了
jsxRuntime未被useImportType规则 (#2473) 遵守的问题。由 @arendjr 贡献。¥Fix case where
jsxRuntimewasn’t being respected byuseImportTyperule (#2473).Contributed by @arendjr -
修复 #2460,该规则在某些情况下会导致代码检查工具崩溃。现在可以正确处理以下情况:
¥Fix #2460, where the rule
noUselessFragmentswas crashing the linter in some cases. Now cases like these are correctly handled:callFunction(<>{bar}</>)贡献者:@ematipico
¥Contributed by @ematipico
-
修复 #2366,
noDuplicateJsonKeys错误地计算了要高亮显示的关键字。贡献者:@ematipico¥Fix #2366, where
noDuplicateJsonKeysincorrectly computed the kes to highlight. Contributed by @ematipico
¥Enhancements
-
规则
noMisplacedAssertions现在认为在waitFor中调用expect是有效的:¥The rule
noMisplacedAssertionsnow considers valid callingexpectinsidewaitFor:import { waitFor } from '@testing-library/react';await waitFor(() => {expect(111).toBe(222);});贡献者:@ematipico
¥Contributed by @ematipico
1.7.0 (2024-04-15)
Section titled “1.7.0 (2024-04-15)”¥Analyzer
¥Bug fixes
-
现在 Biome 可以更可靠地检测 Svelte 和 Vue 脚本块中的脚本语言 (#2245)。贡献者:@Sec-ant
¥Now Biome can detect the script language in Svelte and Vue script blocks more reliably (#2245). Contributed by @Sec-ant
useExhaustiveDependencies 不再将递归调用报告为缺少依赖(#2361)。贡献者:@arendjr
¥useExhaustiveDependencies no longer reports recursive calls as missing dependencies (#2361). Contributed by @arendjr
useExhaustiveDependencies 正确报告使用函数声明(#2362)声明的缺失依赖。贡献者:@arendjr
¥useExhaustiveDependencies correctly reports missing dependencies declared using function declarations (#2362). Contributed by @arendjr
-
Biome 现在可以处理以
CRLF为行尾序列的.svelte和.vue文件。贡献者:@Sec-ant¥Biome now can handle
.svelteand.vuefiles withCRLFas the end-of-line sequence. Contributed by @Sec-ant -
noMisplacedAssertion不再报告describe、test、it对象(例如test.each([])())的方法调用 (#2443)。由 @unvalley 提供。¥
noMisplacedAssertionno longer reports method calls bydescribe,test,itobjects (e.g.test.each([])()) (#2443). Contributed by @unvalley. -
Biome 现在可以处理以 通用组件 (#2456) 为行尾序列的
.vue文件。¥Biome now can handle
.vuefiles with generic components (#2456).<script generic="T extends Record<string, any>" lang="ts" setup>//...</script>贡献者:@Sec-ant
¥Contributed by @Sec-ant
¥Enhancements
-
完善类 JSON 文件的常用文件列表。
.jsonc文件默认允许尾随逗号。一些常用的文件,例如tsconfig.json和.babelrc,虽然没有使用.jsonc扩展名,但仍然允许注释和尾随逗号。而其他的,例如.eslintrc.json,只允许注释。Biome 能够识别这些文件并相应地调整json.parser.allowTrailingCommas选项以确保正确解析它们。贡献者:@Sec-ant¥Complete the well-known file lists for JSON-like files. Trailing commas are allowed in
.jsoncfiles by default. Some well-known files liketsconfig.jsonand.babelrcdon’t use the.jsoncextension but still allow comments and trailing commas. While others, such as.eslintrc.json, only allow comments. Biome is able to identify these files and adjusts thejson.parser.allowTrailingCommasoption accordingly to ensure they are correctly parsed. Contributed by @Sec-ant -
修复了缩进逻辑与 Prettier 不一致的问题,即缩进样式为空格且缩进宽度不为 2 的情况。贡献者:@mdm317
¥Fix dedent logic inconsistent with prettier where the indent-style is space and the indent-width is not 2. Contributed by @mdm317
¥New features
-
添加从 ESLint 迁移的命令。
¥Add a command to migrate from ESLint
biome migrate eslint允许你将 ESLint 配置迁移到 Biome。该命令支持 旧版 ESLint 配置 和 新的扁平化 ESLint 配置。不支持使用 YAML 格式的旧版 ESLint 配置。¥
biome migrate eslintallows you to migrate an ESLint configuration to Biome. The command supports legacy ESLint configurations and new flat ESLint configurations. Legacy ESLint configurations using the YAML format are not supported.加载旧版 ESLint 配置时,Biome 会解析
extends字段。它同时解决了共享配置和插件预设的问题!为此,它会调用 Node.js。¥When loading a legacy ESLint configuration, Biome resolves the
extendsfield. It resolves both shared configurations and plugin presets! To do this, it invokes Node.js.Biome 依靠其规则的元数据来确定 等效于 ESLint 规则的规则。Biome 规则要么是受 ESLint 规则启发,要么与之大致相同。默认情况下,受启发规则和 Nursery 规则不会被迁移。你也可以使用 CLI 标志
--include-inspired和--include-nursery来迁移它们。¥Biome relies on the metadata of its rules to determine the equivalent rule of an ESLint rule. A Biome rule is either inspired or roughly identical to an ESLint rules. By default, inspired and nursery rules are excluded from the migration. You can use the CLI flags
--include-inspiredand--include-nurseryto migrate them as well.请注意,这是一种尽力而为的方法。我们无法保证你获得与 ESLint 相同的结果。
¥Note that this is a best-effort approach. You are not guaranteed to get the same behavior as ESLint.
给定以下 ESLint 配置:
¥Given the following ESLint configuration:
{"ignore_patterns": ["**/*.test.js"],"globals": { "var2": "readonly" },"rules": {"eqeqeq": "error"},"overrides": [{"files": ["lib/*.js"],"rules": {"default-param-last": "off"}}]}biome migrate eslint --write将 Biome 配置更改如下:¥
biome migrate eslint --writechanges the Biome configuration as follows:{"linter": {"rules": {"recommended": false,"suspicious": {"noDoubleEquals": "error"}}},"javascript": { "globals": ["var2"] },"overrides": [{"include": ["lib/*.js"],"linter": {"rules": {"style": {"useDefaultParameterLast": "off"}}}}]}此外,如果工作目录包含
.eslintignore,Biome 会迁移 glob 模式。不支持子目录中的嵌套.eslintignore文件和否定 glob 模式。¥Also, if the working directory contains
.eslintignore, then Biome migrates the glob patterns. Nested.eslintignorein subdirectories and negated glob patterns are not supported.如果你发现任何问题,请随时报告。
¥If you find any issue, please don’t hesitate to report them.
贡献者:@Conaclos
¥Contributed by @Conaclos
-
添加了两个新选项,用于自定义 CLI 的输出:
--reporter=json和--reporter=json-pretty。启用--reporter=json后,诊断信息和摘要将以 JSON 格式输出到终端。使用--reporter=json-pretty,你可以打印相同的信息,但格式将与你配置中的选项保持一致。¥Added two new options to customise the emitted output of the CLI:
--reporter=jsonand--reporter=json-pretty. With--reporter=json, the diagnostics and the summary will be printed in the terminal in JSON format. With--reporter=json-pretty, you can print the same information, but formatted using the same options of your configuration.注意:JSON 的格式被认为是实验性的,将来可能会发生变化。
¥NOTE: the shape of the JSON is considered experimental, and the shape of the JSON might change in the future.
Example of output when running `biome format` command
```json { "summary": { "changed": 0, "unchanged": 1, "errors": 1, "warnings": 0, "skipped": 0, "suggestedFixesSkipped": 0, "diagnosticsNotPrinted": 0 }, "diagnostics": [ { "category": "format", "severity": "error", "description": "Formatter would have printed the following content:", "message": [ { "elements": [], "content": "Formatter would have printed the following content:" } ], "advices": { "advices": [ { "diff": { "dictionary": " statement();\n", "ops": [ { "diffOp": { "delete": { "range": [0, 2] } } }, { "diffOp": { "equal": { "range": [2, 12] } } }, { "diffOp": { "delete": { "range": [0, 2] } } }, { "diffOp": { "equal": { "range": [12, 13] } } }, { "diffOp": { "delete": { "range": [0, 2] } } }, { "diffOp": { "insert": { "range": [13, 15] } } } ] } } ] }, "verboseAdvices": { "advices": [] }, "location": { "path": { "file": "format.js" }, "span": null, "sourceCode": null }, "tags": [], "source": null } ], "command": "format" } ``` -
为
check、format和lint子命令添加了新的--staged标志。¥Added new
--stagedflag to thecheck,formatandlintsubcommands.此新选项允许用户仅对已暂存(即将提交)的文件应用命令,这对于简化编写 Git 钩子脚本(例如
pre-commit)非常有用。贡献者:@castarco¥This new option allows users to apply the command only to the files that are staged (the ones that will be committed), which can be very useful to simplify writing git hook scripts such as
pre-commit. Contributed by @castarco
¥Enhancements
-
改进从 Prettier 迁移时对
.prettierignore的支持。¥Improve support of
.prettierignorewhen migrating from Prettier现在,Biome 会将
.prettierignore中的大多数 glob 模式转换为等效的 Biome 忽略模式。仅不支持取反的 glob 模式。¥Now, Biome translates most of the glob patterns in
.prettierignoreto the equivalent Biome ignore pattern. Only negated glob patterns are not supported.贡献者:@Conaclos
¥Contributed by @Conaclos
-
支持从 Prettier 迁移时使用 JavaScript 配置文件
¥Support JavaScript configuration files when migrating from Prettier
biome migrate prettier现在能够迁移以js、mjs或cjs扩展名结尾的 Prettier 配置文件。为此,Biome 会调用 Node.js。¥
biome migrate prettieris now able to migrate Prettier configuration files ending withjs,mjs, orcjsextensions. To do this, Biome invokes Node.js.此外,现在支持在
package.json中嵌入 Prettier 配置。¥Also, embedded Prettier configurations in
package.jsonare now supported.贡献者:@Conaclos
¥Contributed by @Conaclos
-
支持从 Prettier 迁移时在 Prettier 配置文件中使用
overrides字段。贡献者:@Conaclos¥Support
overridesfield in Prettier configuration files when migrating from Prettier. Contributed by @Conaclos -
支持将文件路径传递给
--config-path标志或BIOME_CONFIG_PATH环境变量。¥Support passing a file path to the
--config-pathflag or theBIOME_CONFIG_PATHenvironment variable.现在,你可以将任意文件名的
.json/.jsonc文件路径传递给--config-path标志或BIOME_CONFIG_PATH环境变量。这将禁用配置自动解析,Biome 将尝试从指定的文件路径 (#2265) 读取配置。¥Now you can pass a
.json/.jsoncfile path with any filename to the--config-pathflag or theBIOME_CONFIG_PATHenvironment variable. This will disable the configuration auto-resolution and Biome will try to read the configuration from the said file path (#2265).Terminal window biome format --config-path=../biome.json ./src贡献者:@Sec-ant
¥Contributed by @Sec-ant
¥Bug fixes
-
Biome 现在会为
organizeImports和formatter发出的诊断信息添加正确的严重级别标签,以便它们能被标志--diagnostic-level(#2288) 正确过滤。贡献者:@Sec-ant¥Biome now tags the diagnostics emitted by
organizeImportsandformatterwith correct severity levels, so they will be properly filtered by the flag--diagnostic-level(#2288). Contributed by @Sec-ant -
当使用
--changed标志 #1996 时,Biome 现在能够正确过滤掉当前目录中不存在的文件。贡献者:@castarco¥Biome now correctly filters out files that are not present in the current directory when using the
--changedflag #1996. Contributed by @castarco -
Biome 现在会跳过遍历
fifo或socket文件(#2311)。贡献者:@Sec-ant¥Biome now skips traversing
fifoorsocketfiles (#2311). Contributed by @Sec-ant -
Biome 现在可以解析从工作目录(CLI)或项目根目录(LSP)导出的
extends格式的外部库配置文件。这是文档中记录的行为,之前的解决方法被视为错误 (#2231)。贡献者:@Sec-ant¥Biome now resolves configuration files exported from external libraries in
extendsfrom the working directory (CLI) or project root (LSP). This is the documented behavior and previous resolution behavior is considered as a bug (#2231). Contributed by @Sec-ant
¥Configuration
¥Bug fixes
-
现在,当组级别
all设置为false时,如果顶层recommended为true或未设置,则可以禁用该组中的推荐规则。贡献者:@Sec-ant¥Now setting group level
alltofalsecan disable recommended rules from that group when top levelrecommendedistrueor unset. Contributed by @Sec-ant -
Biome 配置文件现在可以正确扩展
.jsonc配置文件(#2279)。贡献者:@Sec-ant¥Biome configuration files can correctly extends
.jsoncconfiguration files now (#2279). Contributed by @Sec-ant -
修复了 React Hooks 配置的 JSON 模式 (#2396)。贡献者:@arendjr
¥Fixed the JSON schema for React hooks configuration (#2396). Contributed by @arendjr
¥Enhancements
-
Biome 现在会显示其配置文件 (#1627) 解析错误的位置。
¥Biome now displays the location of a parsing error for its configuration file (#1627).
之前,当 Biome 在其配置文件中遇到解析错误时,它不会指出错误的位置。现在,会显示配置文件名和错误发生的范围。
¥Previously, when Biome encountered a parsing error in its configuration file, it didn’t indicate the location of the error. It now displays the name of the configuration file and the range where the error occurred.
贡献者:@Conaclos
¥Contributed by @Conaclos
-
对于没有任何选项的规则(#2313),不再需要
options。¥
optionsis no longer required for rules without any options (#2313).之前,当使用对象设置规则的诊断级别而没有使用任何选项时,需要将
options设置为null。但是,如果将options设置为null,Biome 会报错。¥Previously, the JSON schema required to set
optionstonullwhen an object is used to set the diagnostic level of a rule without any option. However, ifoptionsis set tonull, Biome emits an error.模式已修复,不再需要指定
options。这将导致以下配置有效:¥The schema is now fixed and it no longer requires specifying
options. This makes the following configuration valid:{"linter": {"rules": {"style": {"noDefaultExport": {"level": "off"}}}}}贡献者:@Conaclos
¥Contributed by @Conaclos
¥Editors
¥Bug fixes
-
Biome 扩展现在能够解析与
javascript和 语言标识符 关联的文件中的 JSX 语法。这是一个临时解决方案,因为在大多数编辑器中,在 React 世界中,.js文件允许包含 JSX 语法 和这些文件通常与javascript语言标识符关联。此外,一些编辑器扩展 还会将.jsx文件与javascript语言标识符关联起来。相对链接:discussion, #2085.贡献者:@Sec-ant¥Biome extension is now able to parse the JSX syntax in files that associated with the
javascriptlanguage identifier. This is an ad hoc fix, because in the React world,.jsfiles are allowed to include JSX syntax, and these files are often associated with thejavascriptlanguage identifier in most of the editors. Plus, some editor extensions will also associate.jsxfiles with thejavascriptlanguage identifier. Relative links: discussion, #2085. Contributed by @Sec-ant
¥Formatter
¥Bug fixes
-
修复 #2291,正确处理 JSX 扩展属性和 JSX 扩展子元素的注释位置。贡献者:@ah-yu
¥Fix #2291 by correctly handle comment placement for JSX spread attributes and JSX spread children. Contributed by @ah-yu
JavaScript API
Section titled “JavaScript API”Linter
Section titled “Linter”¥Promoted rules
新规则在 nursery 组中进行孵化。一旦稳定下来,我们就将它们提升为稳定规则。以下规则已推广:
¥New rules are incubated in the nursery group. Once stable, we promote them to a stable group. The following rules are promoted:
¥New features
-
向
javascript配置添加一个新的选项jsxRuntime。设置为reactClassic时,noUnusedImports 和 useImportType 规则会使用此信息为 React Classic JSX 转换所需的 React 全局变量创建例外。¥Add a new option
jsxRuntimeto thejavascriptconfiguration. When set toreactClassic, the noUnusedImports and useImportType rules use this information to make exceptions for the React global that is required by the React Classic JSX transform.这仅适用于尚未升级到 新的 JSX 转换 的 React 用户。
¥This is only necessary for React users who haven’t upgraded to the new JSX transform.
由 @Conaclos 和 @arendjr 贡献
¥Contributed by @Conaclos and @arendjr
-
实现 #2043:React 规则
useExhaustiveDependencies现在也兼容从preact/hooks或preact/compat导入的 Preact hooks。贡献者:@arendjr¥Implement #2043: The React rule
useExhaustiveDependenciesis now also compatible with Preact hooks imported frompreact/hooksorpreact/compat. Contributed by @arendjr -
添加规则 noFlatMapIdentity,禁止在
flatMap中使用不必要的回调函数。贡献者:@isnakode¥Add rule noFlatMapIdentity to disallow unnecessary callback use on
flatMap. Contributed by @isnakode -
添加规则 noConstantMathMinMaxClamp,禁止使用
Math.min和Math.max来限制结果本身为常量的值。贡献者:@mgomulak¥Add rule noConstantMathMinMaxClamp, which disallows using
Math.minandMath.maxto clamp a value where the result itself is constant. Contributed by @mgomulak
¥Enhancements
-
style/useFilenamingConvention 现在允许在文件名前添加
+前缀(#2341)。¥style/useFilenamingConvention now allows prefixing a filename with
+(#2341).¥This is a convention used by Sveltekit and Vike.
贡献者:@Conaclos
¥Contributed by @Conaclos
-
style/useNamingConvention 现在接受局部变量和顶层变量的
PascalCase。¥style/useNamingConvention now accepts
PascalCasefor local and top-level variables.这允许支持保存组件或常规类的局部变量。以下代码现在被接受:
¥This allows supporting local variables that hold a component or a regular class. The following code is now accepted:
function loadComponent() {const Component = getComponent();return <Component />;}贡献者:@Conaclos
¥Contributed by @Conaclos
-
complexity/useLiteralKeys 不再报告名为
__proto__的计算属性 (#2430)。¥complexity/useLiteralKeys no longer report computed properties named
__proto__(#2430).在 JavaScript 中,
{["__proto__"]: null}和{__proto__: null}的语义并不相同。第一段代码将一个常规属性设置为null。第二个代码块将对象的原型设置为null。有关更多详细信息,请参阅 MDN 文档。¥In JavaScript,
{["__proto__"]: null}and{__proto__: null}have not the same semantic. The first code set a regular property tonull. The second one set the prototype of the object tonull. See the MDN Docs for more details.该规则现在会忽略名为
__proto__的计算属性。¥The rule now ignores computed properties named
__proto__.贡献者:@Conaclos
¥Contributed by @Conaclos
¥Bug fixes
-
Lint 规则
useNodejsImportProtocol、useNodeAssertStrict、noRestrictedImports和noNodejsModules将不再检查declare module语句。贡献者:@Sec-ant¥Lint rules
useNodejsImportProtocol,useNodeAssertStrict,noRestrictedImports,noNodejsModuleswill no longer checkdeclare modulestatements anymore. Contributed by @Sec-ant -
style/useNamingConvention 现在接受对象解构中变量的任意命名规则 (#2332)。
¥style/useNamingConvention now accepts any case for variables from object destructuring (#2332).
以下名称现在将被忽略:
¥The following name is now ignored:
const { Strange_Style } = obj;之前,该规则重命名了此变量。这将导致运行时错误。
¥Previously, the rule renamed this variable. This led to a runtime error.
贡献者:@Conaclos
¥Contributed by @Conaclos
¥Parser
¥Bug fixes
-
修复了使用转义序列在 JavaScript 字符串中编码 Unicode 代理对的问题 (#2384)。贡献者:@arendjr
¥Fixed an issue when Unicode surrogate pairs were encoded in JavaScript strings using an escape sequence (#2384). Contributed by @arendjr
1.6.4 (2024-04-03)
Section titled “1.6.4 (2024-04-03)”¥Analyzer
¥Bug fixes
-
在二进制表达式中,运算符周围没有空格不再会导致 JavaScript 分析器出错 (#2243)。贡献者:@Sec-ant
¥An operator with no spaces around in a binary expression no longer breaks the js analyzer (#2243). Contributed by @Sec-ant
¥Bug fixes
¥Configuration
¥Bug fixes
-
正确计算 lint 规则组中已启用的规则。现在,即使某个组级预设选项
recommended或all为false(#2191),也可以启用该组的特定规则。贡献者:@Sec-ant¥Correctly calculate enabled rules in lint rule groups. Now a specific rule belonging to a group can be enabled even if its group-level preset option
recommendedorallisfalse(#2191). Contributed by @Sec-ant
¥Editors
¥Bug fixes
-
修复启用
quickfix.biome并应用某些与import相关的规则 (#2222、#688、#1015) 时出现的意外代码删除和重复问题。贡献者:@Sec-ant¥Fix the unexpected code deletion and repetition when
quickfix.biomeis enabled and someimport-related rules are applied (#2222, #688, #1015). Contributed by @Sec-ant
Linter
Section titled “Linter”¥New features
-
添加 nursery/noMisplacedAssertion。由 @ematipico 贡献
¥Add nursery/noMisplacedAssertion. COntributed by @ematipico
¥Bug fixes
-
修复 #2211。当子元素作为 prop 传递到新行时,noChildrenProp 应该可以正常工作。贡献者:@fireairforce
¥Fix #2211. noChildrenProp should work fine when children pass as a prop in a new line. Contributed by @fireairforce
-
修复 #2248。当按钮元素带有 spread 属性时,
lint/a11y/useButtonType不应触发。贡献者:@fireairforce¥Fix #2248.
lint/a11y/useButtonTypeshould not trigger when button element with spread attribute. Contributed by @fireairforce -
修复 #2216。
lint/style/useNamingConvention不应忽略 JSX 组件名称绑定。贡献者:@fireairforce¥Fix #2216.
lint/style/useNamingConventionshould not ignore JSX Component name binding. Contributed by @fireairforce
¥Enhancements
-
在规则
useSortedClasses中添加对对象属性成员的支持。贡献者:@ematipico¥Add support for object property members in the rule
useSortedClasses. Contributed by @ematipico
¥Parser
-
当
.astro文件的 frontmatter 包含非法返回值时,解析器不会抛出任何错误:¥The parser doesn’t throw any error when the frontmatter of
.astrofiles contains an illegal return:---const condition = true;if (condition) {return "Something";}---<div></div>贡献者:@ematipico
¥Contributed by @ematipico
1.6.3 (2024-03-25)
Section titled “1.6.3 (2024-03-25)”¥Bug fixes
-
修复配置解析。现在,当显式设置
--config-path(#2164)时,Biome 能够正确找到biome.jsonc配置文件。贡献者:@Sec-ant¥Fix configuration resolution. Biome is now able to correctly find the
biome.jsoncconfiguration file when--config-pathis explicitly set (#2164). Contributed by @Sec-ant -
现在,在同一个工作区中,不同变体(
.ts、.js、.tsx、.jsx)的 JavaScript/TypeScript 文件,在不同的嵌套路径或不同的操作系统(#2080、#2109)中运行 CLI 命令时,格式行为将保持一致。贡献者:@Sec-ant¥JavaScript/TypeScript files of different variants (
.ts,.js,.tsx,.jsx) in a single workspace now have stable formatting behaviors when running the CLI command in paths of different nested levels or in different operating systems (#2080, #2109). Contributed by @Sec-ant
¥Configuration
¥Bug fixes
-
完善对选项
formatter.lineEnding、[language].formatter.lineEnding、formatter.attributePosition和javascript.formatter.attributePosition的文档和覆盖支持。贡献者:@Sec-ant¥Complete the documentation and overrides support for options
formatter.lineEnding,[language].formatter.lineEnding,formatter.attributePositionandjavascript.formatter.attributePosition. Contributed by @Sec-ant
¥Formatter
¥Bug fixes
-
修复 #2172,打破长对象解构模式。贡献者:@ah-yu
¥Fix #2172 by breaking long object destructuring patterns. Contributed by @ah-yu
Linter
Section titled “Linter”¥New features
-
添加规则 noEvolvingTypes,禁止通过重新赋值将变量类型更改为
any。贡献者:@fujiyamaorange¥Add rule noEvolvingTypes to disallow variables from evolving into
anytype through reassignments. Contributed by @fujiyamaorange
¥Enhancements
-
将
noSemicolonInJsx重命名为noSuspiciousSemicolonInJsx。贡献者:@fujiyamaorange¥Rename
noSemicolonInJsxtonoSuspiciousSemicolonInJsx. Contributed by @fujiyamaorange
¥Bug fixes
-
当
linter被禁用(#2161)时,快速修复操作不再在保存时自动修复 lint 规则错误。贡献者:@Sec-ant¥Quickfix action no longer autofixes lint rule errors on save when
linteris disabled (#2161). Contributed by @Sec-ant -
Astro/Svelte/Vue 的范围格式化不会将代码放置在错误的位置,尤其是在启用粘贴时格式化的情况下。贡献者:@ematipico
¥Range formatting for Astro/Svelte/Vue doesn’t place code out of place, especially when formatting on paste is enabled. Contributed by @ematipico
1.6.2 (2024-03-22)
Section titled “1.6.2 (2024-03-22)”¥Analyzer
¥Bug fixes
-
noSuperWithoutExtends规则现在允许在类表达式的派生类构造函数中调用super()(#2108)。贡献者:@Sec-ant¥The
noSuperWithoutExtendsrule now allows for callingsuper()in derived class constructors of class expressions (#2108). Contributed by @Sec-ant -
修复了文件源检测方面的差异。允许在
.cts文件(#2114)中使用模块语法。贡献者:@Sec-ant¥Fix discrepancies on file source detection. Allow module syntax in
.ctsfiles (#2114). Contributed by @Sec-ant
¥Bug fixes
-
修复了 #2131 中运行命令
check时文件夹被错误忽略的问题。现在可以根据文件夹的命令正确地忽略它们。贡献者:@ematipico¥Fixes #2131, where folders were incorrectly ignored when running the command
check. Now folders are correctly ignored based on their command. Contributed by @ematipico -
在 Prettier 迁移中更流畅地处理
"endOfLine": "auto":回退到"lf"(#2145)。贡献者:@eMerzh¥Smoother handling of
"endOfLine": "auto"in prettier migration: falling back to"lf"(#2145). Contributed by @eMerzh
¥Configuration
¥Bug fixes
-
修复已启用规则的计算。现在,顶层配置和组级配置中各个规则、
all和recommend预设的优先级都得到了正确的遵循。更多详情请参见 (#2072) (#2028)。贡献者:@Sec-ant¥Fix enabled rules calculation. The precedence of individual rules,
allandrecommendpresets in top-level and group-level configs is now correctly respected. More details can be seen in (#2072) (#2028). Contributed by @Sec-ant
¥Formatter
¥Bug fixes
-
修复 #1661。现在,嵌套条件语句与 Prettier 的逻辑保持一致,不会出现空格和制表符混用的情况。贡献者:@ematipico
¥Fix #1661. Now nested conditionals are aligned with Prettier’s logic, and won’t contain mixed spaces and tabs. Contributed by @ematipico
JavaScript API
Section titled “JavaScript API”¥Enhancements
-
支持在调用
Biome类的lintContent方法(#1956)时应用 lint 修复。贡献者:@mnahkies¥Support applying lint fixes when calling the
lintContentmethod of theBiomeclass (#1956). Contributed by @mnahkies
Linter
Section titled “Linter”¥New features
-
添加 nursery/noDuplicateElseIf。由 @mdm317 贡献
¥Add nursery/noDuplicateElseIf. COntributed by @mdm317
¥Bug fixes
-
规则
noUndeclaredDependencies现在还会验证peerDependencies和optionalDependencies(#2122)。贡献者:@Sec-ant¥Rule
noUndeclaredDependenciesnow also validatespeerDependenciesandoptionalDependencies(#2122). Contributed by @Sec-ant -
规则
noUndeclaredDependencies将不再检查declare module语句 (#2123)。贡献者:@Sec-ant¥Rule
noUndeclaredDependencieswon’t checkdeclare modulestatements anymore (#2123). Contributed by @Sec-ant -
修复 #1925。
useOptionalChain的修复有时会建议一个错误的修复,即丢弃逻辑表达式左侧的可选链式运算符。这些现在已保留。贡献者:@arendjr¥Fix #1925. The fix for
useOptionalChainwould sometimes suggest an incorrect fix that discarded optional chaining operators on the left-hand side of logical expressions. These are now preserved. Contributed by @arendjr -
规则
noUndeclaredVariables现在还会检查工作进程全局变量 (#2121)。贡献者:@Sec-ant¥Rule
noUndeclaredVariablesnow also checks for worker globals (#2121). Contributed by @Sec-ant
¥Bug fixes
-
正确解析
.jsonc文件。贡献者:@Sec-ant¥Correctly parse
.jsoncfiles. Contributed by @Sec-ant -
正确解析外部
extends配置。贡献者:@Sec-ant¥Correctly resolve external
extendsconfigs. Contributed by @Sec-ant
1.6.1 (2024-03-12)
Section titled “1.6.1 (2024-03-12)”¥Bug fixes
-
CLI 现在能够自动搜索和解析
biome.jsonc(#2008)。贡献者:@Sec-ant¥CLI is now able to automatically search and resolve
biome.jsonc(#2008). Contributed by @Sec-ant -
修复了部分文件即使未被修改也被误判为 “fixed” 的问题。贡献者:@ematipico
¥Fix a false positive where some files were counted as “fixed” even though they weren’t modified. Contributed by @ematipico
¥Configuration
¥Bug fixes
-
json.formatter.trailingCommas选项现在支持overrides(#2009)。贡献者:@Sec-ant¥
json.formatter.trailingCommasoption now works inoverrides(#2009). Contributed by @Sec-ant
Linter
Section titled “Linter”¥New features
-
添加规则 noDoneCallback,此规则检查钩子和测试的函数参数是否使用了 done 参数,并建议改为返回一个 Promise。由 @vasucp1207 贡献
¥Add rule noDoneCallback, this rule checks the function parameter of hooks & tests for use of the done argument, suggesting you return a promise instead. Contributed by @vasucp1207
beforeEach(done => {// ...});
¥Bug fixes
-
useJsxKeyInIterable 现在会识别用括号括起来的函数体 (#2011)。贡献者:@Sec-ant
¥useJsxKeyInIterable now recognizes function bodies wrapped in parentheses (#2011). Contributed by @Sec-ant
-
useShorthandFunctionType 现在会在应用修复 (#2015) 时保留泛型接口的类型参数。贡献者:@Sec-ant
¥useShorthandFunctionType now preserves type parameters of generic interfaces when applying fixes (#2015). Contributed by @Sec-ant
-
useImportType 和 useExportType 的代码修复现在可以处理多行语句 (#2041)。贡献者:@Conaclos
¥Code fixes of useImportType and useExportType now handle multiline statements (#2041). Contributed by @Conaclos
-
noRedeclare 不再报告类型参数和参数名称相同(#1992)。
¥noRedeclare no longer reports type parameter and parameter with identical names (#1992).
以下代码不再被报告:
¥The following code is no longer reported:
function f<a>(a: a) {}贡献者:@Conaclos
¥Contributed by @Conaclos
-
noRedeclare 现在会报告同一声明中重复的类型参数。
¥noRedeclare now reports duplicate type parameters in a same declaration.
现在会将以下类型参数报告为重复声明:
¥The following type parameters are now reported as a redeclaration:
function f<T, T>() {}贡献者:@Conaclos
¥Contributed by @Conaclos
-
noUndeclaredDependencies 现在会识别子路径导出的导入。
¥noUndeclaredDependencies now recognizes imports of subpath exports.
例如,如果
@mui/material和tailwindcss作为依赖已安装,则以下导入语句不再报错:¥E.g., the following import statements no longer report errors if
@mui/materialandtailwindcssare installed as dependencies:import Button from "@mui/material/Button";import { fontFamily } from "tailwindcss/defaultTheme";贡献者:@Sec-ant
¥Contributed by @Sec-ant
¥Parser
¥Bug fixes
-
JavaScript 词法分析器现在能够分析包含转义非 ASCII 字符(#1941)的正则表达式字面量。
¥JavaScript lexer is now able to lex regular expression literals with escaped non-ascii chars (#1941).
贡献者:@Sec-ant
¥Contributed by @Sec-ant
1.6.0 (2024-03-08)
Section titled “1.6.0 (2024-03-08)”¥Analyzer
¥New features
-
为
.astro文件添加局部支持。Biome 可以对 Astro 文件 frontmatter 中的导入语句进行排序。贡献者:@ematipico¥Add partial for
.astrofiles. Biome is able to sort imports inside the frontmatter of the Astro files. Contributed by @ematipico---import { getLocale } from "astro:i18n";import { Code } from "astro:components";import { Code } from "astro:components";import { getLocale } from "astro:i18n";---<div></div> -
为
.vue文件添加局部支持。Biome 可以对 Vue 文件 script 代码块中的导入语句进行排序。贡献者:@nhedger¥Add partial for
.vuefiles. Biome is able to sort imports inside the script block of Vue files. Contributed by @nhedger<script setup lang="ts">import Button from "./components/Button.vue";import * as vueUse from "vue-use";import * as vueUse from "vue-use";import Button from "./components/Button.vue";</script/><template></template> -
为
.svelte文件添加局部支持。Biome 可以对 Svelte 文件 script 代码块中的导入语句进行排序。贡献者:@ematipico¥Add partial for
.sveltefiles. Biome is able to sort imports inside the script block of Svelte files. Contributed by @ematipico<script setup lang="ts">import Button from "./components/Button.svelte";import * as svelteUse from "svelte-use";import * as svelteUse from "svelte-use";import Button from "./components/Button.svelte";</script/><div></div> -
如果设置了
javascript.formatter.quoteStyle,分析器现在可以从中推断出正确的引用。这意味着分析器建议的代码修复将使用格式化器相同的引用。贡献者:@ematipico¥The analyzer now infers the correct quote from
javascript.formatter.quoteStyle, if set. This means that code fixes suggested by the analyzer will use the same quote of the formatter. Contributed by @ematipico
¥Enhancements
-
noUnusedVariables 会忽略未使用的扩展同级文件夹。
¥noUnusedVariables ignores unused rest spread siblings.
以下代码现在可以被正确解析:有效:
¥The following code is now valid:
const { a, ...rest } = { a: 0, b: 1 };console.log(rest);贡献者:@ah-yu
¥Contributed by @ah-yu
-
修复 #1931。即使不是从 React 库导入的,内置的 React Hook(例如
useEffect())现在也可以由useExhaustiveDependendies进行验证。为此,只需像配置其他用户提供的钩子一样配置它们即可。¥Fix #1931. Built-in React hooks such as
useEffect()can now be validated by theuseExhaustiveDependendies, even when they’re not being imported from the React library. To do so, simply configure them like any other user-provided hooks.贡献者:@arendjr
¥Contributed by @arendjr
-
实现 #1128。现在可以配置用户提供的 React Hooks 来跟踪稳定结果。例如:
¥Implemented #1128. User-provided React hooks can now be configured to track stable results. For example:
"useExhaustiveDependencies": {"level": "error","options": {"hooks": [{"name": "useMyState","stableResult": [1]}]}}这将允许验证以下内容:
¥This will allow the following to be validated:
const [myState, setMyState] = useMyState();const toggleMyState = useCallback(() => {setMyState(!myState);}, [myState]); // Only `myState` needs to be specified here.贡献者:@arendjr
¥Contributed by @arendjr
¥Bug fixes
-
修复 #1748。现在,对于以下情况,我们将不再提供针对
noNonNullAssertion规则的不安全修复:¥Fix #1748. Now for the following case we won’t provide an unsafe fix for the
noNonNullAssertionrule:x[y.z!];贡献者:@ah-yu
¥Contributed by @ah-yu
-
包含
:协议的导入现在会排在npm:模块之后,URL模块之前。贡献者:@ematipico¥Imports that contain the protocol
:are now sorted after thenpm:modules, and before theURLmodules. Contributed by @ematipicoimport express from "npm:express";import Component from "./component.js"import { sortBy } from "virtual:utils";import { sortBy } from "virtual:utils";import Component from "./component.js" -
修复 #1081。
useAwait规则不会报告for await...of。由 @unvalley 提供¥Fix #1081. The
useAwaitrule does not reportfor await...of. Contributed by @unvalley -
修复 #1827 问题,正确分析嵌套的
try-finally语句。贡献者:@ah-yu¥Fix #1827 by properly analyzing nested
try-finallystatements. Contributed by @ah-yu -
修复 #1924,在导入子句中使用正确的导出名称进行排序。贡献者:@ah-yu
¥Fix #1924 Use the correct export name to sort in the import clause. Contributed by @ah-yu
-
修复 #1805 中带有条件表达式主体的箭头函数的格式化问题。(贡献者:@mdm317)
¥Fix #1805 fix formatting arrow function which has conditional expression body Contributed by @mdm317
-
修复 #1781,如果静态成员表达式不是以引用开头,则避免检索引用的整个静态成员表达式。贡献者:@ah-yu
¥Fix #1781 by avoiding the retrieval of the entire static member expression for the reference if the static member expression does not start with the reference. Contributed by @ah-yu
¥New features
-
添加一个新的命令
biome migrate prettier。该命令会读取文件.prettierrc/prettier.json和.prettierignore,并将其配置映射到 Biome 的配置。由于.prettierignore通配符和 Biome 通配符的性质不同,强烈建议确保它们在 Biome 下仍然有效。¥Add a new command
biome migrate prettier. The command will read the file.prettierrc/prettier.jsonand.prettierignoreand map its configuration to Biome’s one. Due to the different nature of.prettierignoreglobs and Biome’s globs, it’s highly advised to make sure that those still work under Biome. -
现在诊断信息中显示的文件名可以点击了。如果你从编辑器运行 CLI,则可以按 Ctrl/⌘ + 单击文件名,编辑器将打开该文件。如果指定了行和列(例如
file.js:32:7),编辑器会将光标直接定位到该位置。贡献者:@ematipico¥Now the file name printed in the diagnostics is clickable. If you run the CLI from your editor, you can Ctrl/⌘ + Click on the file name, and the editor will open said file. If row and columns are specified e.g.
file.js:32:7, the editor will set the cursor right in that position. Contributed by @ematipico -
为
biome rage添加选项--linter。该选项需要检查 Biome 代码检查器配置。贡献者:@seitarof¥Add an option
--lintertobiome rage. The option needs to check Biome linter configuration. Contributed by @seitarof -
为
biome rage添加选项--formatter。该选项需要检查 Biome 格式化程序配置。贡献者:@seitarof¥Add an option
--formattertobiome rage. The option needs to check Biome formatter configuration. Contributed by @seitarof -
CLI 现在会始终如一地报告已更改的文件数(占分析文件总数的比例)。贡献者:@ematipico
¥The CLI now consistently reports the number of files tha were changed, out of the total files that were analysed. Contributed by @ematipico
-
CLI 现在会始终如一地显示发出的错误和警告的数量。贡献者:@ematipico
¥The CLI now consistently shows the number of errors and warnings emitted. Contributed by @ematipico
¥Bug fixes
-
不要处理被忽略目录下的文件。
¥Don’t process files under an ignored directory.
之前,Biome 会处理遍历层次结构中的所有文件,即使是忽略目录中的文件。现在,它会完全跳过被忽略目录的内容。
¥Previously, Biome processed all files in the traversed hierarchy, even the files under an ignored directory. Now, it completely skips the content of ignored directories.
目前,无法在配置文件中使用
files.include忽略目录。这是一个已知的限制,我们希望在未来的版本中解决。¥For now, directories cannot be ignored using
files.includein the configuration file. This is a known limitation that we want to address in a future release.例如,如果你的项目包含文件夹
src和test,以下配置不会完全忽略test。¥For instance, if you have a project with a folder
srcand a foldertest, the following configuration doesn’t completely ignoretest.{"files": {"include": ["src"]}}Biome 将遍历
test,但目录中的所有文件都将被正确忽略。如果 Biome 遇到悬空符号链接或权限过高的文件,则可能会导致文件系统错误。¥Biome will traverse
test, however all files of the directory are correctly ignored. This can result in file system errors, if Biome encounters dangling symbolic links or files with higher permissions.避免遍历
test目录,应使用ignore忽略该目录:¥To avoid traversing the
testdirectory, you should ignore the directory usingignore:{"files": {"include": ["src"],"ignore": ["test"]}} -
修复 #1508 问题,排除已删除的文件。贡献者:@ematipico
¥Fix #1508 by excluding deleted files from being processed. Contributed by @ematipico
-
修复 #1173。修复控制流主体中单个注释指令的格式,以确保一致性。贡献者:@mdm317
¥Fix #1173. Fix the formatting of a single instruction with commented in a control flow body to ensure consistency. Contributed by @mdm317
-
修复
javascript.globals的覆盖问题。贡献者:@arendjr¥Fix overriding of
javascript.globals. Contributed by @arendjr -
修复了在提取诊断信息时未运行语法规则的问题。现在 Biome 将发出更多解析诊断信息,例如:
¥Fix a bug where syntax rules weren’t run when pulling the diagnostics. Now Biome will emit more parsing diagnostics, e.g.
check.js:1:17 parse/noDuplicatePrivateClassMembers ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━× Duplicate private class member "#foo"> 1 │ class A { #foo; #foo }│ ^^^^贡献者:@ematipico
¥Contributed by @ematipico
-
修复 #1774,在使用
--changed运行 CLI 时考虑--no-errors-on-unmatched选项。贡献者:@antogyn¥Fix #1774 by taking into account the option
--no-errors-on-unmatchedwhen running the CLI using--changed. Contributed by @antogyn
¥Enhancements
-
移除在文件 linting/检查阶段打印的多余诊断信息:
¥Removed a superfluous diagnostic that was printed during the linting/check phase of a file:
test.js check ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━× The file contains diagnostics that needs to be addressed.贡献者:@ematipico
¥Contributed by @ematipico
-
如果存在解析诊断信息,命令
format现在会输出这些信息,并以非零退出代码终止。贡献者:@ematipico¥The command
formatnow emits parsing diagnostics if there are any, and it will terminate with a non-zero exit code. Contributed by @ematipico
¥Configuration
¥New features
-
新增从
node_modules/目录解析extends中定义的配置文件的功能:¥Add the ability to resolve the configuration files defined inside
extendsfrom thenode_modules/directory.如果你想解析与指定符
@org/configs/biome匹配的配置文件,则你的package.json文件必须如下所示:¥If you want to resolve a configuration file that matches the specifier
@org/configs/biome, then yourpackage.jsonfile must look this:{"name": "@org/configs","exports": {"./biome": "./biome.json"}}“imports” 指定的
biome.json文件配置将如下所示:¥And the
biome.jsonfile that “imports” said configuration, will look like this:{"extends": "@org/configs/biome"}阅读 documentation 以更好地理解其工作原理、预期和限制。
¥Read the documentation to better understand how it works, expectations and restrictions.
¥Editors
¥Bug fixes
-
修复了编辑器中被忽略的文件被格式化的问题。贡献者:@ematipico
¥Fix a regression where ignored files where formatted in the editor. Contributed by @ematipico
-
修复了在提取诊断信息时未运行语法规则的问题。现在 Biome 将发出更多解析诊断信息,例如:
¥Fix a bug where syntax rules weren’t run when pulling the diagnostics. Now Biome will emit more parsing diagnostics, e.g.
check.js:1:17 parse/noDuplicatePrivateClassMembers ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━× Duplicate private class member "#foo"> 1 │ class A { #foo; #foo }│ ^^^^贡献者:@ematipico
¥Contributed by @ematipico
¥Formatter
¥New features
-
Biome 现在允许格式化
package.json文件。这现在是默认行为,用户可以移除他们的变通方案。如果你依赖其他工具来格式化package.json,则需要通过配置忽略它。贡献者:@pattrickrice¥Biome now allows to format the
package.jsonfile. This is now the default behaviour and users can remove their workarounds. If you rely on other tools to formatpackage.json, you’ll have to ignore it via configuration. Contributed by @pattrickrice -
新增格式化选项
attributePosition,其行为与 Prettier 的singleAttributePerLine和 #1706 类似。贡献者:@octoshikari¥New formatter option
attributePositionthat have similar behavior as PrettiersingleAttributePerLine#1706. Contributed by @octoshikari -
为
.astro文件添加局部支持。Biome 可以格式化 Astro 文件的 frontmatter。贡献者:@ematipico¥Add partial for
.astrofiles. Biome is able to format the frontmatter of the Astro files. Contributed by @ematipico---statement ( );statement();---<div></div> -
为
.vue文件添加局部支持。Biome 可以格式化 Vue 文件的 script 代码块。贡献者:@nhedger¥Add partial for
.vuefiles. Biome is able to format the script block of Vue files. Contributed by @nhedger<script setup lang="ts">statement ( );statement();</script/><template></template> -
为
.svelte文件添加局部支持。Biome 可以格式化 Svelte 文件的 script 代码块。贡献者:@ematipico¥Add partial for
.sveltefiles. Biome is able to format the script block of Svelte files. Contributed by @ematipico<script setup lang="ts">statement ( );statement();</script/><div></div>
¥Enhancements
-
composer.json、deno.json、jsconfig.json、package.json和tsconfig.json不再是受保护的文件。¥
composer.json,deno.json,jsconfig.json,package.jsonandtsconfig.jsonare no longer protected files.这意味着你现在可以格式化它们。
¥This means that you can now format them.
如果你想忽略这些文件,可以使用 files.ignore 配置:
¥If you want to ignore these files, you can use the files.ignore configuration:
{"files": {"ignore": ["composer.json","jsconfig.json","package.json","tsconfig.json","typescript.json","deno.json","deno.jsonc"]}}以下文件仍受保护,因此将被忽略:
¥The following files are still protected, and thus ignored:
-
composer.lock -
npm-shrinkwrap.json -
package-lock.json -
yarn.lock
由 @pattrickrice 和 @Conaclos 贡献
¥Contributed by @pattrickrice and @Conaclos
-
¥Bug fixes
-
修复 #1039。检查正则表达式是否为简单参数时,检查 Unicode 宽度而非字节数。
¥Fix #1039. Check unicode width instead of number of bytes when checking if regex expression is a simple argument.
这不再会出错。
¥This no longer breaks.
s(/🚀🚀/).s().s();贡献者:@kalleep
¥Contributed by @kalleep
-
修复 #1218,正确保留成员链中的空行。贡献者:@ah-yu
¥Fix #1218, by correctly preserving empty lines in member chains. Contributed by @ah-yu
-
通过正确考虑格式化选项中的前导逗号来修复 #1659 和 #1662。贡献者:@ematipico
¥Fix #1659 and #1662, by correctly taking into account the leading comma inside the formatter options. Contributed by @ematipico
-
修复 #1934。修复使用“按需箭头括号”时长箭头函数格式错误的问题。(由 @fireairforce 贡献)
¥Fix #1934. Fix invalid formatting of long arrow function for AsNeeded arrow parens Contributed by @fireairforce
JavaScript API
Section titled “JavaScript API”Linter
Section titled “Linter”¥Promoted rules
新规则在 nursery 组中进行孵化。一旦稳定下来,我们就将它们提升为稳定规则。以下规则已推广:
¥New rules are incubated in the nursery group. Once stable, we promote them to a stable group. The following rules are promoted:
此外,现在建议遵守以下规则:
¥Additionally, the following rules are now recommended:
¥Removed rules
-
移除
nursery/useGroupedTypeImport。规则 style/useImportType 涵盖了此规则的行为。¥Remove
nursery/useGroupedTypeImport. The rule style/useImportType covers the behavior of this rule.请注意,根据我们的 语义版本控制 规范,移除 Nursery 规则不被视为破坏性更改。
¥Note that removing a nursery rule is not considered a breaking change according to our semantic versioning.
贡献者:@Conaclos
¥Contributed by @Conaclos
¥New features
-
新增规则 noSkippedTests,禁止跳过测试:
¥Add the rule noSkippedTests, to disallow skipped tests:
describe.skip("test", () => {});it.skip("test", () => {});贡献者:@ematipico
¥Contributed by @ematipico
-
新增规则 noFocusedTests,禁止跳过测试:
¥Add the rule noFocusedTests, to disallow skipped tests:
describe.only("test", () => {});it.only("test", () => {});贡献者:@ematipico
¥Contributed by @ematipico
-
添加规则 useSortedClasses,用于对 CSS 实用工具类进行排序:
¥Add rule useSortedClasses, to sort CSS utility classes:
<div class="px-2 foo p-4 bar" /><div class="foo bar p-4 px-2" />贡献者:@DaniGuardiola
¥Contributed by @DaniGuardiola
-
添加规则 noUndeclaredDependencies,用于检测是否使用了
package.json中不存在的依赖。¥Add rule noUndeclaredDependencies, to detect the use of dependencies that aren’t present in the
package.json.该规则忽略使用协议(如
node:、bun:、jsr:、https:)的导入。¥The rule ignores imports using a protocol such as
node:,bun:,jsr:,https:.由 @ematipico 和 @Conaclos 贡献
¥Contributed by @ematipico and @Conaclos
-
添加规则 noNamespaceImport,用于报告命名空间导入:
¥Add rule noNamespaceImport, to report namespace imports:
import * as foo from "foo";由 @unvalley 提供
¥Contributed by @unvalley
-
为
.astro文件添加局部支持。Biome 可以检查并修复 Astro 文件的 frontmatter。贡献者:@ematipico¥Add partial support for
.astrofiles. Biome is able to lint and fix the frontmatter of the Astro files. Contributed by @ematipico---delete a.ba.b = undefined---<div></div> -
为
.vue文件添加局部支持。Biome 可以检查并修复 Vue 文件的 script 代码块。¥Add partial support for
.vuefiles. Biome is able to lint and fix the script block of the Vue files.<script setup lang="ts">delete a.ba.b = undefined<script><template></template>贡献者:@nhedger
¥Contributed by @nhedger
-
添加规则 useNodeAssertStrict,鼓励使用
node:assert/strict而不是node:assert。贡献者:@ematipico¥Add rule useNodeAssertStrict, which promotes the use of
node:assert/strictovernode:assert. Contributed by @ematipico -
添加规则 noExportsInTest,禁止在包含测试的文件中使用
export或modules.exports。贡献者:@ah-yu¥Add rule noExportsInTest which disallows
exportormodules.exportsin files containing test. Contributed by @ah-yu -
添加规则 noSemicolonInJsx,用于检测 JSX 元素中可能存在的错误分号。
¥Add rule noSemicolonInJsx to detect possible wrong semicolons inside JSX elements.
const Component = () => {return (<div><div />;</div>);}贡献者:@fujiyamaorange
¥Contributed by @fujiyamaorange
-
添加规则 noBarrelFile,用于报告桶形文件的使用情况:
¥Add rule noBarrelFile, to report the usage of barrel file:
export * from "foo";贡献者:@togami2864
¥Contributed by @togami2864
-
添加规则 noReExportAll,用于报告
export * from "mod"。贡献者:@mdm317¥Add rule noReExportAll that report
export * from "mod". Contributed by @mdm317 -
添加规则 noExcessiveNestedTestSuites。由 @vasucp1207 贡献
¥Add rule noExcessiveNestedTestSuites. Contributed by @vasucp1207
-
添加规则 useJsxKeyInIterable。由 @vohoanglong0107 贡献
¥Add rule useJsxKeyInIterable. Contributed by @vohoanglong0107
¥Enhancements
-
当片段子元素为纯文本时,noUselessFragments 现在不会触发 jsx 属性的规则。
¥noUselessFragments now rule not triggered for jsx attributes when the fragment child is simple text.
export function SomeComponent() {return <div x-some-prop={<>Foo</>} />;}同时修复了片段子元素类型为
JsxExpressionChild时的代码操作问题。¥Also fixes code action when the fragment child is of type
JsxExpressionChild.<><Hello leftIcon={<>{provider?.icon}</>} />{<>{provider?.icon}</>}<>{provider?.icon}</></>由 @vasucp1207 贡献
¥Contributed by @vasucp1207
-
noUselessTernary 现在提供了不安全代码修复程序。由 @vasucp1207 贡献
¥noUselessTernary now provides unsafe code fixes. Contributed by @vasucp1207
-
noApproximativeNumericConstant 现在提供了不安全代码修复程序,并可处理不带前导零的数字和带数字分隔符的数字。
¥noApproximativeNumericConstant now provides unsafe code fixes and handle numbers without leading zero and numbers with digit separators.
以下数字现在被报告为近似常量。
¥The following numbers are now reported as approximated constants.
3.14_15; // PI.4342; // LOG10E贡献者:@Conaclos
¥Contributed by @Conaclos
-
noPrecisionLoss 不再报告包含多余零的数字。
¥noPrecisionLoss no longer reports number with extra zeros.
以下数字现在有效。
¥The following numbers are now valid.
.1230000000000000000000000;1230000000000000000000000.0;贡献者:@Conaclos
¥Contributed by @Conaclos
-
useNamingConvention 现在支持 unicase 字母 (#1786)。
¥useNamingConvention now supports unicase letters (#1786).
unicase 的字符只有一种大小写形式:它们既不是大写也不是小写。之前,Biome 会将大小写统一的名称报告为无效。现在,它接受所有情况下都使用首字母大写的名称。
¥unicase letters have a single case: they are neither uppercase nor lowercase. Previously, Biome reported names in unicase as invalid. It now accepts a name in unicase everywhere.
以下代码现在被接受:
¥The following code is now accepted:
const 안녕하세요 = { 안녕하세요: 0 };我们仍然拒绝混合使用大小写字母的名称:以下名称将被拒绝:
¥We still reject a name that mixes unicase characters with lowercase or uppercase characters: The following names are rejected:
const A안녕하세요 = { a안녕하세요: 0 };贡献者:@Conaclos
¥Contributed by @Conaclos
-
useNamingConvention 和 useFilenamingConvention 现在提供了一个新选项
requireAscii,要求标识符必须使用 ASCII 编码。¥useNamingConvention and useFilenamingConvention now provides a new option
requireAsciito require identifiers to be in ASCII.为避免任何破坏性更改,此选项默认处于关闭状态。我们计划在 Biome 的下一个主要版本(Biome 2.0)中启用此功能。
¥To avoid any breaking change, this option is turned off by default. We intend to turn it on in the next major release of Biome (Biome 2.0).
将
requireAscii规则选项设置为true,以要求标识符必须为 ASCII 字符。¥Set the
requireAsciirule option totrueto require identifiers to be in ASCII.{"linter": {"rules": {"style": {"useNamingConvention": { "options": { "requireAscii": false } }},"nursery": {"useFilenamingConvention": { "options": { "requireAscii": false } }}}}}贡献者:@Conaclos
¥Contributed by @Conaclos
-
noUnusedVariables 不再报告未使用的导入。
¥noUnusedVariables no longer reports unused imports.
现在,我们专门添加了一条规则来报告未使用的导入:noUnusedImports
¥We now have a dedicated rule for reporting unused imports: noUnusedImports
贡献者:@Conaclos
¥Contributed by @Conaclos
¥Bug fixes
-
修复 noStaticOnlyClass 文档中缺少的链接。由 @yndajas 贡献
¥Fix missing link in noStaticOnlyClass documentation. Contributed by @yndajas
-
noConfusingVoidType 不再报告条件类型中 void 类型的有效使用 (#1812)。
¥noConfusingVoidType no longer reports valid use of the void type in conditional types (#1812).
该规则不再将以下代码报告为未使用:
¥The rule no longer reports the following code:
type Conditional<T> = T extends void ? Record<string, never> : T贡献者:@lucasweng
¥Contributed by @lucasweng
-
noInvalidUseBeforeDeclaration 不再报告绑定模式的有效使用 (#1648)。
¥noInvalidUseBeforeDeclaration no longer reports valid use of binding patterns (#1648).
该规则不再将以下代码报告为未使用:
¥The rule no longer reports the following code:
const { a = 0, b = a } = {};贡献者:@Conaclos
¥Contributed by @Conaclos
-
noUnusedVariables 不再报告已使用的绑定模式(#1652)。
¥noUnusedVariables no longer reports used binding patterns (#1652).
该规则不再将以下代码中的
a报告为未使用:¥The rule no longer reports
aas unused the following code:const { a = 0, b = a } = {};export { b };贡献者:@Conaclos
¥Contributed by @Conaclos
-
修复 #1651。noVar 现在忽略 TsGlobalDeclaration。由 @vasucp1207 贡献
¥Fix #1651. noVar now ignores TsGlobalDeclaration. Contributed by @vasucp1207
-
修复 #1640。当最后一个成员包含注释但没有逗号时,useEnumInitializers 代码操作现在可以生成有效的代码。贡献者:@kalleep
¥Fix #1640. useEnumInitializers code action now generates valid code when last member has a comment but no comma. Contributed by @kalleep
-
修复 #1653。处理
useForOf中的简写值,以避免误报。贡献者:@togami2864¥Fix #1653. Handle a shorthand value in
useForOfto avoid the false-positive case. Contributed by @togami2864 -
修复 #1656。useOptionalChain 代码操作现在可以正确处理逻辑链,其中同名方法使用不同的参数调用:
¥Fix #1656. useOptionalChain code action now correctly handles logical and chains where methods with the same name are invoked with different arguments:
tags && tags.includes('a') && tags.includes('b')tags?.includes('a') && tags.includes('b')贡献者:@lucasweng
¥Contributed by @lucasweng
-
修复 #1704。将
/转换为转义斜杠\/,以避免自动修复结果中的解析错误。贡献者:@togami2864¥Fix #1704. Convert
/to escaped slash\/to avoid parsing error in the result of autofix. Contributed by @togami2864 -
修复 #1697。在抑制规则的自动修复中保留主要细节。贡献者:@togami2864
¥Fix#1697. Preserve leading trivia in autofix of suppression rules. Contributed by @togami2864
-
修复 #603。去除尾随空格,避免重复插入。贡献者:@togami2864
¥Fix #603. Trim trailing whitespace to avoid double insertion. Contributed by @togami2864
-
修复 #1765。现在删除数据集时不会触发规则
noDelete:¥Fix #1765. Now the rule
noDeletedoesn’t trigger when deleting a dataset:delete element.dataset.prop;贡献者:@ematipico
¥Contributed by @ematipico
-
useNamingConvention 和 useFilenamingConvention 现在拒绝使用连续分隔符的标识符。
¥useNamingConvention and useFilenamingConvention now reject identifiers with consecutive delimiters.
以下名称现在无效,因为它包含两个下划线:
¥The following name is now invalid because it includes two underscores:
export const MY__CONSTANT = 0;请注意,我们仍然允许连续的前导和尾随下划线。
¥Note that we still allow consecutive leading and consecutive trailing underscores.
贡献者:@Conaclos
¥Contributed by @Conaclos
-
修复 #1932,允许在不同声明中重新声明类型参数。贡献者:@keita-hino
¥Fix #1932 Allow redeclaration of type parameters in different declarations. Contributed by @keita-hino
-
修复 #1945,允许
noUselessConstructor中的构造函数使用默认参数。¥Fix #1945 Allow constructor with default parameters in
noUselessConstructor -
修复 #1982,更改以遍历模块项列表并忽略 .d.ts 文件。贡献者:@togami2864
¥Fix #1982 Change to iterate over the module item lists and ignore .d.ts files. Contributed by @togami2864
¥Parser
¥Bug fixes
-
修复 #1728。当
{标记位于global关键字之后的行时,正确解析全局声明。¥Fix #1728. Correctly parse the global declaration when the
{token is on the line following theglobalkeyword.现在以下代码可以被正确解析:
¥Now the following code is correctly parsed:
declare global{ }declare module foo {global{ }}贡献者:@ah-yu
¥Contributed by @ah-yu
-
修复 #1730。正确解析带有非简单成员表达式操作数的
delete表达式。¥Fix #1730. Correctly parse
deleteexpressions with operands that are not simple member expressions.delete(a.b);delete console.log(1);delete(() => {});贡献者:@printfn
¥Contributed by @printfn
¥Website
¥Bug fixes
-
修复 #1981。在 Playground 中,通过文件路径识别 TypeScript 定义文件。贡献者:@ah-yu
¥Fix #1981. Identify TypeScript definition files by their file path within the playground. Contributed by @ah-yu
1.5.3 (2024-01-22)
Section titled “1.5.3 (2024-01-22)”¥Bug fixes
-
修复 #1584。确保 LSP 仅注册一次格式化程序。贡献者:@nhedger
¥Fix #1584. Ensure the LSP only registers the formatter once. Contributed by @nhedger
-
修复 #1589。修复导入/导出列表末尾的独立行注释格式错误的问题。贡献者:@spanishpear
¥Fix #1589. Fix invalid formatting of own line comments when they were at the end of an import/export list. Contributed by @spanishpear
¥Configuration
¥Bug fixes
-
正确覆盖推荐的预设(#1349)。
¥Override correctly the recommended preset (#1349).
之前,如果未指定,Biome 会在重写中启用推荐的预设。这使得诊断信息的严重级别设置为
off。这反过来又导致了 Biome 的故障。¥Previously, if unspecified, Biome turned on the recommended preset in overrides. This resulted in reporting diagnostics with a severity level set to
off. This in turn caused Biome to fail.现在,除非另有指示,否则 Biome 不会启用
overrides中的推荐预设。¥Now Biome won’t switch on the recommended preset in
overridesunless told to do so.贡献者:@Conaclos
¥Contributed by @Conaclos
-
启用
files.ignoreUnknown时,不要格式化已知的 JSONC 文件(#1607)。¥Don’t format ignored files that are well-known JSONC files when
files.ignoreUnknownis enabled (#1607).之前,当启用
files.ignoreUnknown时,Biome 总是会格式化已知为 JSONC 文件(例如.eslintrc)的文件。¥Previously, Biome always formatted files that are known to be JSONC files (e.g.
.eslintrc) whenfiles.ignoreUnknownwas enabled.贡献者:@Conaclos
¥Contributed by @Conaclos
¥Formatter
¥New features
-
添加选项
json.formatter.trailingCommas,以更好地控制 JSON/JSONC 文件中的尾随逗号。其默认值为"none"。¥Add option
json.formatter.trailingCommas, to provide a better control over the trailing comma in JSON/JSONC files. Its default value is"none".
¥Bug fixes
-
修复 #1178,其中行尾选项未正确应用。贡献者:@ematipico
¥Fix #1178, where the line ending option wasn’t correctly applied. Contributed by @ematipico
-
修复 #1571。修复嵌套多行注释格式错误的问题。贡献者:@ah-yu
¥Fix #1571. Fix invalid formatting of nested multiline comments. Contributed by @ah-yu
Linter
Section titled “Linter”¥Bug fixes
修复 #1575。noArrayIndexKey 现在会捕获模板字面量和字符串连接中的数组索引值。由 @vasucp1207 贡献
¥Fix #1575. noArrayIndexKey now captures array index value inside template literals and with string concatenation. Contributed by @vasucp1207
-
检查正则表达式的 Lint 规则现在可以正确处理多字节字符 (#1522)。
¥Linter rules that inspect regexes now handle multibyte characters correctly (#1522).
之前,noMisleadingCharacterClass、noMultipleSpacesInRegularExpressionLiterals 和 noEmptyCharacterClassInRegex 在处理多字节字符时会导致 Biome 错误。现在可以正确处理多字节字符。
¥Previously, noMisleadingCharacterClass, noMultipleSpacesInRegularExpressionLiterals, and noEmptyCharacterClassInRegex made Biome errors on multi-bytes characters. Multibyte characters are now handled correctly.
以下代码不再引发内部错误:
¥The following code no longer raises an internal error:
// Cyrillic characters/[\u200E\u2066-\u2069]/gu;贡献者:@Conaclos
¥Contributed by @Conaclos
-
useExhaustiveDependencies 不再导致 Biome 在 TypeScript 导入语句相等时出错 (#1194)。贡献者:@Conaclos
¥useExhaustiveDependencies no longer made Biome errors in code TypeScript import equal declarations (#1194). Contributed by @Conaclos
-
修复 noNodejsModules 诊断信息中的拼写错误。贡献者:@huseeiin
¥Fix typo in the diagnostic of noNodejsModules. Contributed by @huseeiin
¥Parser
¥Bug fixes
-
方法类型签名 (#1624) 中接受类型参数的
const修饰符。¥Accept the
constmodifier for type parameter in method type signature (#1624).以下代码现在可以被正确解析:
¥The following code is now correctly parsed:
type Foo = {<const T>();method<const T>();};贡献者:@magic-akari
¥Contributed by @magic-akari
-
正确解析 expression(#1184) 中的类型参数。
¥Correctly parse type arguments in expression(#1184).
以下代码现在可以在 TypeScript 中正确解析:
¥The following code is now correctly parsed in typescript:
0 < (0 >= 1);贡献者:@ah-yu
¥Contributed by @ah-yu
¥Website
¥New
-
添加 映射 Biome 规则的页面来源。贡献者:@ematipico
¥Add a page that maps the Biome rule to its source. Contributed by @ematipico
¥Fixes
-
根据链接页面生成 Open Graph 图片。贡献者:@ematipico
¥Generate Open Graph images based on the linked page. Contributed by @ematipico
-
修复了 git hook 页面 的示例。由 @9renpoto、@lmauromb 和 @Conaclos 贡献
¥Fix examples of the git hook page. Contributed by @9renpoto, @lmauromb, and @Conaclos
-
修复了失效和错误的超链接。由 @Sec-ant 和 Conaclos 贡献
¥Fix dead and erroneous hyperlinks. Contributed by @Sec-ant and Conaclos
1.5.2 (2024-01-15)
Section titled “1.5.2 (2024-01-15)”¥Bug fixes
-
修复 #1512,跳过详细诊断信息。贡献者:@ematipico
¥Fix #1512 by skipping verbose diagnostics from the count. Contributed by @ematipico
-
正确处理级联的
include和ignore。¥Correctly handle cascading
includeandignore.以前,Biome 错误地包含了工具级别包含但全局级别忽略的文件。在以下示例中,
file.js被格式化,而它本应被忽略。现在,Biome 会正确地忽略目录./src/sub/。¥Previously Biome incorrectly included files that were included at tool level and ignored at global level. In the following example,
file.jswas formatted when it should have been ignored. Now, Biome correctly ignores the directory./src/sub/.Terminal window ❯ tree srcsrc└── sub└── file.js❯ cat biome.json{"files": { "ignore": ["./src/sub/"] },"formatter": { "include": ["./src"] }}贡献者:@Conaclos
¥Contributed by @Conaclos
-
忽略受保护的文件时,不要发出详细的警告。
¥Don’t emit verbose warnings when a protected file is ignored.
一些文件,例如
package.json和tsconfig.json,实际上是 protected。Biome 在遇到受保护文件时会发出详细的警告。¥Some files, such as
package.jsonandtsconfig.json, are protected. Biome emits a verbose warning when it encounters a protected file.之前,即使配置忽略了该文件,Biome 也会发出此详细警告。现在,它不会对被忽略的受保护文件发出冗长的警告。
¥Previously, Biome emitted this verbose warning even if the file was ignored by the configuration. Now, it doesn’t emit verbose warnings for protected files that are ignored.
贡献者:@Conaclos
¥Contributed by @Conaclos
-
overrides不再影响哪些文件会被忽略。贡献者:@Conaclos¥
overridesno longer affect which files are ignored. Contributed by @Conaclos -
文件
biome.json不能再被忽略了。贡献者:@ematipico¥The file
biome.jsoncan’t be ignored anymore. Contributed by @ematipico -
修复 #1541 中未将受保护文件的内容返回给
stdout的问题。贡献者:@ematipico¥Fix #1541 where the content of protected files wasn’t returned to
stdout. Contributed by @ematipico -
不处理 CSS 文件,格式化程序尚未准备就绪。贡献者:@ematipico
¥Don’t handle CSS files, the formatter isn’t ready yet. Contributed by @ematipico
¥Configuration
¥Bug fixes
-
修复 1440,
extends和overrides未能正确生成最终配置的问题。贡献者:@arendjr¥Fix 1440, a case where
extendsandoverridesweren’t correctly emitting the final configuration. Contributed by @arendjr -
正确处理
ignore设置时的include(#1468)。贡献者:@Conaclos¥Correctly handle
includewhenignoreis set (#1468). Contributed by @Conaclos之前,如果设置了
ignore,Biome 会忽略include。现在,Biome 会检查include和ignore。如果文件被包含在内且未被忽略,则会对其进行处理。如果未设置include,则所有文件均被视为已包含。¥Previously, Biome ignored
includeifignorewas set. Now, Biome check bothincludeandignore. A file is processed if it is included and not ignored. Ifincludeis not set all files are considered included.
¥Formatter
¥Bug fixes
-
修复带有装饰器的生成器方法中
*标记之前的注释位置。#1537 由 @ah-yu 贡献¥Fix placement of comments before
*token in generator methods with decorators. #1537 Contributed by @ah-yu -
修复 #1406。确保
async关键字之前的注释位于其之前。贡献者:@ah-yu¥Fix #1406. Ensure comments before the
asynckeyword are placed before it. Contributed by @ah-yu -
修复 #1172。修复函数表达式括号后的行注释位置,现在它们附加到函数体中的第一个语句。贡献者:@kalleep
¥Fix #1172. Fix placement of line comment after function expression parentheses, they are now attached to first statement in body. Contributed by @kalleep
-
修复了 #1511 中导致 JavaScript 格式化程序崩溃的问题。贡献者:@Conaclos
¥Fix #1511 that made the JavaScript formatter crash. Contributed @Conaclos
Linter
Section titled “Linter”¥Enhancements
-
为
noConsoleLog添加不安全代码修复。由 @vasucp1207 贡献¥Add an unsafe code fix for
noConsoleLog. Contributed by @vasucp1207 -
useArrowFunction 不再报告
extends子句或new表达式中的函数。贡献者:@Conaclos¥useArrowFunction no longer reports function in
extendsclauses or in anewexpression. Contributed by @Conaclos以下情况需要存在原型。
¥These cases require the presence of a prototype.
-
当 useExhaustiveDependencies 规则显示错误时,在错误消息中添加依赖变量名称。贡献者:@mehm8128
¥Add dependency variable names on error message when useExhaustiveDependencies rule shows errors. Contributed by @mehm8128
¥Bug fixes
-
useArrowFunction 的修复现在会在更多需要的地方(#1524)为箭头函数添加括号。
¥The fix of useArrowFunction now adds parentheses around the arrow function in more cases where it is needed (#1524).
在大多数可以出现函数表达式的表达式中,函数表达式不需要括号。箭头函数的情况并非如此。之前,当函数出现在调用或成员表达式中时,我们会添加括号。现在,我们会在类似二进制表达式和其他需要的地方添加括号,希望能够涵盖所有情况。
¥A function expression doesn’t need parentheses in most expressions where it can appear. This is not the case with the arrow function. We previously added parentheses when the function appears in a call or member expression. We now add parentheses in binary-like expressions and other cases where they are needed, hopefully covering all cases.
之前:
¥Previously:
f = f ?? function() {};f = f ?? () => {};现在:
¥Now:
f = f ?? function() {};f = f ?? (() => {});贡献者:@Conaclos
¥Contributed by @Conaclos
-
修复 #1514。修复了自动修复建议,以避免
no_useless_fragments中的语法错误。贡献者:@togami2864¥Fix #1514. Fix autofix suggestion to avoid the syntax error in
no_useless_fragments. Contributed by @togami2864
1.5.1 (2024-01-10)
Section titled “1.5.1 (2024-01-10)”¥Bug fixes
-
现在,仅当传递选项
--verbose时才会显示files/missingHandler诊断信息。贡献者:@ematipico¥The diagnostics
files/missingHandlerare now shown only when the option--verboseis passed. Contributed by @ematipico -
现在,仅当传递选项
--verbose时才会显示受保护文件的诊断信息。贡献者:@ematipico¥The diagnostics for protected files are now shown only when the option
--verboseis passed. Contributed by @ematipico -
修复 #1465,在匹配模式时考虑工作区文件夹。贡献者:@ematipico
¥Fix #1465, by taking in consideration the workspace folder when matching a pattern. Contributed by @ematipico
-
修复 #1465,正确处理包含文件名的通配符。贡献者:@ematipico
¥Fix #1465, by correctly process globs that contain file names. Contributed by @ematipico
¥Formatter
¥Bug fixes
-
修复 #1170。修复默认 switch 语句中的注释位置。现在,所有带有前置节点的行注释都会保持其位置。贡献者:@kalleep
¥Fix #1170. Fix placement of comments inside default switch clause. Now all line comments that have a preceding node will keep their position. Contributed by @kalleep
Linter
Section titled “Linter”¥Bug fixes
修复 #1335。当 Fragment 为空时,noUselessFragments 现在会忽略对组件 props 的代码操作。由 @vasucp1207 贡献
¥Fix #1335. noUselessFragments now ignores code action on component props when the fragment is empty. Contributed by @vasucp1207
-
useConsistentArrayType 被错误地放置在
style规则组中,而不是nursery组中。现在它已被正确放置在nursery下。¥useConsistentArrayType was accidentally placed in the
stylerule group instead of thenurserygroup. It is now correctly placed undernursery.
修复 #1483。useConsistentArrayType 现在能够正确处理其选项。贡献者:@Conaclos
¥Fix #1483. useConsistentArrayType now correctly handles its option. Contributed by @Conaclos
修复 #1502。useArrowFunction 现在能够正确处理返回逗号序列表达式的函数。贡献者:@Conaclos
¥Fix #1502. useArrowFunction now correctly handle functions that return a (comma) sequence expression. Contributed by @Conaclos
之前该规则给出了错误的建议:
¥Previously the rule made an erroneous suggestion:
f(function() { return 0, 1; }, "");f(() => 0, 1, "")现在,该规则会将所有逗号序列用括号括起来:
¥Now, the rule wraps any comma sequence between parentheses:
f(function() { return 0, 1; }, "");f(() => (0, 1), "")修复 #1473:useHookAtTopLevel 现在能够正确处理嵌套在其他函数中的 React 组件和 hook。贡献者:@arendjr
¥Fix #1473: useHookAtTopLevel now correctly handles React components and hooks that are nested inside other functions. Contributed by @arendjr
1.5.0 (2024-01-08)
Section titled “1.5.0 (2024-01-08)”Biome 现在与 Prettier 的兼容性达到 97%,并包含超过 180 条代码检查规则。
¥Biome now scores 97% compatibility with Prettier and features more than 180 linter rules.
¥Analyzer
¥New features
-
当遇到受保护的文件时,Biome 现在会显示诊断信息。贡献者:@ematipico
¥Biome now shows a diagnostic when it encounters a protected file. Contributed by @ematipico
-
如果存在过时的
$schema版本,命令biome migrate现在会更新它。¥The command
biome migratenow updates the$schemaif there’s an outdated version. -
CLI 现在会考虑用户主目录中的
.gitignore(如果存在)。贡献者:@ematipico¥The CLI now takes in consideration the
.gitignorein the home directory of the user, if it exists. Contributed by @ematipico -
当代码中存在诊断信息时,
biome ci命令现在可以打印 GitHub 工作流命令。由 @nikeee 贡献 这可能需要设置 GitHub 操作的正确权限:¥The
biome cicommand is now able to print GitHub Workflow Commands when there are diagnostics in our code. Contributed by @nikeee This **might ** require setting the proper permissions on your GitHub action:permissions:pull-requests: write -
命令
format、lint、check和ci现在接受两个新参数:--changed和--since。启用版本控制系统 (VCS) 集成后,使用这些选项可仅处理已更改的文件。贡献者:@simonxabris¥The commands
format,lint,checkandcinow accept two new arguments:--changedand--since. Use these options with the VCS integration is enabled to process only the files that were changed. Contributed by @simonxabrisTerminal window biome format --write --changed -
引入了一个名为
biome explain的新命令,它可以显示代码检查规则的文档。贡献者:@kalleep¥Introduced a new command called
biome explain, which has the capability to display documentation for lint rules. Contributed by @kalleep -
你可以使用命令
biome explain打印 lint 规则的文档。贡献者:@kalleep¥You can use the command
biome explainto print the documentation of lint rules. Contributed by @kalleepTerminal window biome explain noDebuggerbiome explain useAltText -
你可以使用命令
biome explain打印守护进程日志的存储目录。贡献者:@ematipico¥You can use the command
biome explainto print the directory where daemon logs are stored. Contributed by @ematipicoTerminal window biome explain daemon-logs -
移除 200 条可打印诊断信息的硬编码限制。贡献者:@ematipico
¥Removed the hard coded limit of 200 printable diagnostics. Contributed by @ematipico
¥Bug fixes
-
修复 #1247,Biome 现在会在遇到无法处理的文件时打印警告诊断信息。贡献者:@ematipico
¥Fix #1247, Biome now prints a **warning ** diagnostic if it encounters files that can’t handle. Contributed by @ematipico
你可以使用
biome.json中的files.ignoreUnknown配置忽略未知文件类型:¥You can ignore unknown file types using the
files.ignoreUnknownconfiguration inbiome.json:{"files": {"ignoreUnknown": true}}或者可能是
--files-ignore-unknown的 CLI 选项:¥Or the
--files-ignore-unknownCLI option:Terminal window biome format --files-ignore-unknown=true --write . -
通过正确解析
.gitignore文件修复 #709 和 #805。贡献者:@ematipico¥Fix #709 and #805 by correctly parsing
.gitignorefiles. Contributed by @ematipico -
修复 #1117 问题,正确处理匹配。贡献者:@ematipico
¥Fix #1117 by correctly respecting the matching. Contributed by @ematipico
-
通过在计算
overrides配置 时正确应用配置来修复 #691 和 #1190。贡献者:@ematipico¥Fix #691 and #1190, by correctly apply the configuration when computing
overridesconfiguration. Contributed by @ematipico
¥Configuration
¥New features
-
用户可以在
ignore和include属性中指定 Git 忽略模式,例如,可以使用!字符来允许列出文件 glob 模式:¥Users can specify git ignore patterns inside
ignoreandincludeproperties, for example it’s possible to allow list globs of files using the!character:{"files": {"ignore": ["node_modules/**","!**/dist/**" // this is now accepted and allow files inside the `dist` folder]}}
¥Editors
¥New features
-
LSP 无需使用客户端的动态功能即可注册格式化。
¥The LSP registers formatting without the need of using dynamic capabilities from the client.
这为不支持或仅对动态功能提供有限支持的编辑器带来了格式化服务。
¥This brings formatting services to the editors that don’t support or have limited support for dynamic capabilities.
¥Formatter
¥Bug fixes
-
修复 #1169。计算赋值布局时,考虑转义字符串。贡献者:@kalleep
¥Fix #1169. Account for escaped strings when computing layout for assignments. Contributed by @kalleep
-
修复 #851。允许正则函数表达式像箭头函数表达式一样,作为调用参数进行分组和断行。#1003 由 @faultyserver 贡献
¥Fix #851. Allow regular function expressions to group and break as call arguments, just like arrow function expressions. #1003 Contributed by @faultyserver
-
修复 #914。仅将带括号的类型转换函数表达式作为默认导出。#1023 由 @faultyserver 贡献
¥Fix #914. Only parenthesize type-casted function expressions as default exports. #1023 Contributed by @faultyserver
-
修复 #1112。将 case 语句中的代码块拆分到单独的行,并保留尾随的 fallthrough 注释。#1035 由 @faultyserver 贡献
¥Fix #1112. Break block bodies in case clauses onto their own lines and preserve trailing fallthrough comments. #1035 Contributed by @faultyserver
-
修复
RemoveSoftLinesBuffer的行为,使其同时移除条件展开的内容,确保不会包含意外的、未使用的换行符。#1032 由 @faultyserver 贡献¥Fix
RemoveSoftLinesBufferbehavior to also removed conditional expanded content, ensuring no accidental, unused line breaks are included #1032 Contributed by @faultyserver -
修复 #1024。允许 JSX 表达式嵌套在箭头链中 #1033 由 @faultyserver 贡献
¥Fix #1024. Allow JSX expressions to nestle in arrow chains #1033 Contributed by @faultyserver
-
修复始终使用流式赋值时赋值语句左侧断行不正确的问题。#1021 贡献者:@faultyserver
¥Fix incorrect breaking on the left side of assignments by always using fluid assignment. #1021 Contributed by @faultyserver
-
修复了函数参数中嵌套对象模式的破坏策略。#1054 由 @faultyserver 贡献。
¥Fix breaking strategy for nested object patterns in function parameters #1054 Contributed by @faultyserver
-
修复箭头链表达式过度缩进的问题,简化了每个链的分组方式 #1036、#1136 和 #1162。由 @faultyserver 贡献。
¥Fix over-indention of arrow chain expressions by simplifying the way each chain is grouped #1036, #1136, and #1162 Contributed by @faultyserver.
-
修复 “simple” 对调用和成员表达式的检查,使其能够正确处理数组访问、单参数函数调用的复杂参数以及多参数函数调用。#1057 贡献者:@faultyserver
¥Fix “simple” checks for calls and member expressions to correctly handle array accesses, complex arguments to single-argument function calls, and multiple-argument function calls. #1057 Contributed by @faultyserver
-
修复 JSX 文本元素的文本换行和空行处理,使其与 Prettier 的行为保持一致。#1075 贡献者:@faultyserver
¥Fix text wrapping and empty line handling for JSX Text elements to match Prettier’s behavior. #1075 Contributed by @faultyserver
-
修复简洁打印数组中的前导注释,以防止出现不必要的换行符。#1135 贡献者:@faultyserver
¥Fix leading comments in concisely-printed arrays to prevent unwanted line breaks. #1135 Contributed by @faultyserver
-
修复
best_fitting和内部元素阻止从同级元素传播扩展的问题。#1141 由 @faultyserver 贡献¥Fix
best_fittingand interned elements preventing expansion propagation from sibling elements. #1141 Contributed by @faultyserver -
修复了当存在带约束的类型参数时,对函数参数进行分组的启发式方法。#1153。贡献者:@faultyserver
¥Fix heuristic for grouping function parameters when type parameters with constraints are present. #1153. Contributed by @faultyserver.
-
修复了函数表达式和调用签名中分组调用参数的二进制和类型注解处理问题。#1152 和 #1160 由 @faultyserver 贡献
¥Fix binary-ish and type annotation handling for grouping call arguments in function expressions and call signatures. #1152 and #1160 Contributed by @faultyserver
-
修复了嵌套 JSDoc 注释的处理,以保持重载的行为。#1195 贡献者:@faultyserver
¥Fix handling of nestled JSDoc comments to preserve behavior for overloads. #1195 Contributed by @faultyserver
-
修复 #1208。修复了在检查调用参数中的简单类型注解时提取内部类型的问题。#1195 由 @faultyserver 贡献
¥Fix #1208. Fix extraction of inner types when checking for simple type annotations in call arguments. #1195 Contributed by @faultyserver
-
修复 #1220。避免在映射类型、空对象类型和空元组类型的类型联合中重复注释。#1240 由 @faultyserver 贡献
¥Fix #1220. Avoid duplicating comments in type unions for mapped, empty object, and empty tuple types. #1240 Contributed by @faultyserver
-
修复 #1356。确保
if_group_fits_on_line内容始终以RemoveSoftLinesBuffer编写。#1357 由 @faultyserver 贡献¥Fix #1356. Ensure
if_group_fits_on_linecontent is always written inRemoveSoftLinesBuffers. #1357 Contributed by @faultyserver -
修复 #1171。正确格式化箭头函数体中带注释的空语句(当其作为调用表达式中的单个参数使用时)。贡献者:@kalleep
¥Fix #1171. Correctly format empty statement with comment inside arrow body when used as single argument in call expression. Contributed by @kalleep
-
修复 #1106。修复当箭头括号设置为 “AsNeeded” 且表达式跨越多行时,单个绑定格式错误的问题。#1449 由 @faultyserver 贡献
¥Fix #1106. Fix invalid formatting of single bindings when Arrow Parentheses is set to “AsNeeded” and the expression breaks over multiple lines. #1449 Contributed by @faultyserver
JavaScript API
Section titled “JavaScript API”Linter
Section titled “Linter”¥Promoted rules
新规则在 nursery 组中进行孵化。一旦稳定下来,我们就将它们提升为稳定规则。以下规则已推广:
¥New rules are incubated in the nursery group. Once stable, we promote them to a stable group. The following rules are promoted:
¥New features
-
新增 useExportType 规则,强制类型使用仅类型导出。贡献者:@Conaclos
¥Add useExportType that enforces the use of type-only exports for types. Contributed by @Conaclos
interface A {}interface B {}class C {}export type { A, C }export { type A, C }export { type B }export type { B } -
新增 useImportType 规则,强制类型使用仅类型导入。贡献者:@Conaclos
¥Add useImportType that enforces the use of type-only imports for types. Contributed by @Conaclos
import { A, B } from "./mod.js";import { type A, B } from "mod";let a: A;const b: B = new B();此外,该规则对仅类型导入进行分组:
¥Also, the rule groups type-only imports:
import { type A, type B } from "./mod.js";import type { A, B } from "./mod.js"; -
添加 useFilenamingConvention,强制执行 JavaScript 和 TypeScript 文件名的命名约定。贡献者:@Conaclos
¥Add useFilenamingConvention, that enforces naming conventions for JavaScript and TypeScript filenames. Contributed by @Conaclos
默认情况下,该规则要求文件名属于
camelCase、kebab-case或snake_case类型,或者与文件中某个export类型的导出项的名称匹配。该规则提供了一些选项来限制允许的情况。¥By default, the rule requires that a filename be in
camelCase,kebab-case,snake_case, or matches the name of anexportin the file. The rule provides options to restrict the allowed cases. -
新增 useNodejsImportProtocol 规则,强制在导入 Node.js 模块时使用
node:协议。由 @2-NOW、@vasucp1207 和 @Conaclos 贡献¥Add useNodejsImportProtocol that enforces the use of the
node:protocol when importing Node.js modules. Contributed by @2-NOW, @vasucp1207, and @Conaclosimport fs from "fs";import fs from "node:fs"; -
新增 useNumberNamespace 规则,强制使用
Number属性而非全局属性。¥Add useNumberNamespace that enforces the use of the
Numberproperties instead of the global ones.parseInt;Number.parseInt;- Infinity;Number.NEGATIVE_INFINITY; -
新增 useShorthandFunctionType 规则,强制使用函数类型而非带有调用签名的对象类型。由 @emab、@ImBIOS 和 @seitarof 贡献
¥Add useShorthandFunctionType that enforces using function types instead of object type with call signatures. Contributed by @emab, @ImBIOS, and @seitarof
interface Example {(): string;}type Example = () => string
- Add [noNodejsModules](https://biome.nodejs.cn/linter/rules/no-nodejs-modules), that disallows the use of _Node.js_ modules. Contributed by @anonrig, @ematipico, and @Conaclos
- Add [noInvalidUseBeforeDeclaration](https://biome.nodejs.cn/linter/rules/no-invalid-use-before-declaration) that reports variables and function parameters used before their declaration. Contributed by @Conaclos
```js function f() { console.log(c); // Use of `c` before its declaration. const c = 0; }-
新增 useConsistentArrayType 规则,强制数组类型使用一致的语法。贡献者:@eryue0220
¥Add useConsistentArrayType that enforces the use of a consistent syntax for array types. Contributed by @eryue0220
此规则会替换 useShorthandArrayType。提供了一个选项,可以选择简写语法或通用语法。
¥This rule will replace useShorthandArrayType. It provides an option to choose between the shorthand or the generic syntax.
-
添加 noEmptyTypeParameters,确保任何类型参数列表至少包含一个类型参数。贡献者:@togami2864
¥Add noEmptyTypeParameters that ensures that any type parameter list has at least one type parameter. Contributed by @togami2864
这将报告以下空类型参数列表:
¥This will report the following empty type parameter lists:
interface Foo<> {}// ^^type Bar<> = {};// ^^ -
添加 noGlobalEval,报告任何对全局变量
eval的使用。由 @you-5805 贡献¥Add noGlobalEval that reports any use of the global
eval. Contributed by @you-5805 -
添加 noGlobalAssign,报告对全局变量的赋值。贡献者:@chansuke
¥Add noGlobalAssign that reports assignment to global variables. Contributed by @chansuke
Object = {}; // report assignment to `Object`. -
新增 noMisleadingCharacterClass 规则,禁止使用字符类中多个代码点构成的字符。贡献者:@togami2864
¥Add noMisleadingCharacterClass that disallows characters made with multiple code points in character class. Contributed by @togami2864
-
新增 noThenProperty 规则,禁止使用
then作为属性名。添加then属性会使对象变为 thenable,这可能会导致 Promise 出现错误。贡献者:@togami2864¥Add noThenProperty that disallows the use of
thenas property name. Adding athenproperty makes an object thenable that can lead to errors with Promises. Contributed by @togami2864 -
新增 noUselessTernary 规则,禁止在存在更简单替代方案时使用条件表达式(三元表达式)。
¥Add noUselessTernary that disallows conditional expressions ( ternaries) when simpler alternatives exist.
var a = x ? true : true; // this could be simplified to `x`
¥Enhancements
-
noEmptyInterface 忽略扩展类型的空接口。地址 #959 和 #1157。贡献者:@Conaclos
¥noEmptyInterface ignores empty interfaces that extend a type. Address #959 and #1157. Contributed by @Conaclos
这允许支持外部模块中的接口增强,如下例所示:
¥This allows supporting interface augmentation in external modules as demonstrated in the following example:
interface Extension {metadata: unknown;}declare module "@external/module" {// Empty interface that extends a type.export interface ExistingInterface extends Extension {}} -
在 useExponentiationOperator 的代码修复中保留更多注释。贡献者:@Conaclos
¥Preserve more comments in the code fix of useExponentiationOperator. Contributed by @Conaclos
该规则现在会保留尾随(可选)逗号之后的注释。
¥The rule now preserves comments that follow the (optional) trailing comma.
例如,该规则现在建议以下代码修复:
¥For example, the rule now suggests the following code fix:
Math.pow(a, // a2, // 2);a ** // a2 // 2
<svg> 元素现在被视为非交互式 HTML 元素 (#1095)。贡献者:@chansuke
¥<svg> element is now considered as a non-interactive HTML element (#1095). Contributed by @chansuke
这会影响以下规则:* noAriaHiddenOnFocusable - noInteractiveElementToNoninteractiveRole - noNoninteractiveElementToInteractiveRole - noNoninteractiveTabindex - useAriaActivedescendantWithTabindex
¥This affects the following rules:
- noAriaHiddenOnFocusable
- noInteractiveElementToNoninteractiveRole
- noNoninteractiveElementToInteractiveRole
- noNoninteractiveTabindex
- useAriaActivedescendantWithTabindex
-
noMultipleSpacesInRegularExpressionLiterals 已修复安全代码。贡献者:@Conaclos
¥noMultipleSpacesInRegularExpressionLiterals has a safe code fix. Contributed by @Conaclos
-
useArrowFunction 忽略使用
new.target的表达式。贡献者:@Conaclos¥useArrowFunction ignores expressions that use
new.target. Contributed by @Conaclos -
noForEach 现在仅报告使用带有
0或1参数的回调函数的调用。地址 #547。贡献者:@Conaclos¥noForEach now reports only calls that use a callback with
0or1parameter. Address #547. Contributed by @Conaclos
¥Bug fixes
修复 #1061。noRedeclare 不再报告 export default function 的重载。贡献者:@Conaclos
¥Fix #1061. noRedeclare
no longer reports overloads of export default function. Contributed by @Conaclos
以下代码不再被报告:
¥The following code is no longer reported:
export default function (a: boolean): boolean;export default function (a: number): number;export default function (a: number | boolean): number | boolean { return a;}修复 #651,useExhaustiveDependencies 不再报告超出作用域的依赖。贡献者:@kalleep
¥Fix #651, useExhaustiveDependencies no longer reports out of scope dependencies. Contributed by @kalleep
以下代码不再被报告:
¥The following code is no longer reported:
let outer = false;
const Component = ({}) => { useEffect(() => { outer = true; }, []);}修复 #1191。noUselessElse 现在会保留 else 子句中的注释。贡献者:@Conaclos
¥Fix #1191. noUselessElse
now preserve comments of the else clause. Contributed by @Conaclos
例如,该规则建议以下修复:
¥For example, the rule suggested the following fix:
function f(x) { if (x <0) { return 0; } // Comment else { return x; }}现在,该规则建议了一种修复方案,可以保留 else 子句的注释:
¥Now the rule suggests a fix that preserves the comment of the else clause:
function f(x) { if (x <0) { return 0; } // Comment else { return x; }}修复 #1383。noConfusingVoidType 现在支持类型参数列表中的 void 类型。
¥Fix #1383. noConfusingVoidType
now accepts the void type in type parameter lists.
该规则不再将以下代码报告为未使用:
¥The rule no longer reports the following code:
f<void>();修复 #728。useSingleVarDeclarator 不再输出无效代码。贡献者:@Conaclos
¥Fix #728. useSingleVarDeclarator no longer outputs invalid code. Contributed by @Conaclos
修复 #1167。useValidAriaProps 不再将 aria-atomic 报告为无效。由 @unvalley 提供
¥Fix #1167. useValidAriaProps
no longer reports aria-atomic as invalid. Contributed by @unvalley
修复 #1192。useTemplate 现在能够正确处理带括号的表达式并遵循类型强制转换。贡献者:@n-gude
¥Fix #1192. useTemplate now correctly handles parenthesized expressions and respects type coercions. Contributed by @n-gude
以下情况现在可以正确处理:
¥These cases are now properly handled:
"a" + (1 + 2) // `a${1 + 2}`1 + (2 + "a") // `${1}${2}a`修复 #1456。useTemplate 现在会报告包含插值模板字面量和非字符串表达式的表达式。贡献者:@n-gude
¥Fix #1456. useTemplate now reports expressions with an interpolated template literal and non-string expressions. Contributed by @n-gude
以下代码现在可以被报告:
¥The following code is now reported:
`a${1}` + 2;修复 #1436。useArrowFunction 现在会在调用表达式或成员访问中使用函数表达式时应用正确的修复。贡献者:@Conaclos
¥Fix #1436. useArrowFunction now applies a correct fix when a function expression is used in a call expression or a member access. Contributed by @Conaclos
例如,该规则建议以下修复:
¥For example, the rule proposed the following fix:
const called = function() {}();const called = () => {}();现在,会提供一个修复方案,添加所需的括号:
¥It now proposes a fix that adds the needed parentheses:
const called = function() {}();const called = (() => {})();修复 #696。useHookAtTopLevel 现在能够正确检测在调用 hook 之前发生的提前返回。
¥Fix #696. useHookAtTopLevel now correctly detects early returns before the calls to the hook.
-
noUselessTypeConstraint 的代码修复现在会在需要时添加尾随逗号,以区分类型参数列表和 JSX 元素。由 @Conaclos 贡献
¥The code fix of noUselessTypeCOnstraint now adds a trailing comma when needed to disambiguate a type parameter list from a JSX element. COntributed by @Conaclos
修复 #578。useExhaustiveDependencies 现在可以正确识别 React 命名空间下的钩子。贡献者:@XiNiHa
¥Fix #578. useExhaustiveDependencies
now correctly recognizes hooks namespaced under the React namespace. Contributed by @XiNiHa
修复 #910。noSvgWithoutTitle 现在会忽略带有 aria-hidden="true" 的 <svg> 元素。由 @vasucp1207 贡献
¥Fix #910. noSvgWithoutTitle
now ignores <svg> element with aria-hidden="true". COntributed by @vasucp1207
¥Parser
BREAKING CHANGES
Section titled “BREAKING CHANGES”-
导入的表示方式已简化。贡献者:@Conaclos
¥The representation of imports has been simplified. Contributed by @Conaclos
新的表示方式更接近 ECMAScript 标准。提供了一种表示命名空间导入(例如
import * as ns from "")的单一方法。它排除了一些之前可以表示的无效状态。例如,现在无法再使用type限定符(例如import type D, { N } from "")来表示组合导入。¥The new representation is closer to the ECMAScript standard. It provides a single way of representing a namespace import such as
import * as ns from "". It rules out some invalid states that was previously representable. For example, it is no longer possible to represent a combined import with atypequalifier such asimport type D, { N } from "".有关更多详细信息,请参阅 #1163。
¥See #1163 for more details.
¥New features
-
同时带有 import 属性和
type限定符的导入和导出现在会被报告为解析错误。¥Imports and exports with both an import attribute and a
typequalifier are now reported as parse errors.import type A from "mod" with { type: "json" };// ^^^^ ^^^^^^^^^^^^^^^^^^^^^// parse error
¥Bug fixes
-
修复了 #1077 中将条件表达式中带括号的标识符解析为箭头表达式的问题。贡献者:@kalleep
¥Fix #1077 where parenthesized identifiers in conditional expression were being parsed as arrow expressions. Contributed by @kalleep
以下情况现在可以正确解析:
¥These cases are now properly parsed:
JavaScript:
a ? (b) : a => {};TypeScript:
a ? (b) : a => {};JSX:
bar ? (foo) : (<a>{() => {}}</a>); -
允许接口和类型别名使用空类型参数列表(#1237)。由 @togami2864 贡献
¥Allow empty type parameter lists for interfaces and type aliases (#1237). COntributed by @togami2864
TypeScript 允许接口声明和类型别名使用空类型参数列表。以前,Biome 无法处理这种特殊情况。现在,它可以正确解析以下语法:
¥TypeScript allows interface declarations and type aliases to have empty type parameter lists. Previously Biome didn’t handle this edge case. Now, it correctly parses this syntax:
interface Foo<> {}type Bar<> = {};
¥Crates
BREAKING CHANGES
Section titled “BREAKING CHANGES”-
将
biome_js_unicode_tablecrate 重命名为biome_unicode_table(#1302)。由 @chansuke 贡献¥Rename the
biome_js_unicode_tablecrate tobiome_unicode_table(#1302). COntributed by @chansuke
1.4.1 (2023-11-30)
Section titled “1.4.1 (2023-11-30)”¥Editors
¥Bug fixes
-
修复 #933。一些文件在 LSP 中也会被正确地忽略。例如
package.json、tsconfig.json等。¥Fix #933. Some files are properly ignored in the LSP too. E.g.
package.json,tsconfig.json, etc. -
修复 #1394,从内部保存的文件推断语言扩展名。现在,新建的 JavaScript 文件可以正确显示诊断信息。
¥Fix #1394, by inferring the language extension from the internal saved files. Now newly created files JavaScript correctly show diagnostics.
¥Formatter
¥Bug fixes
-
修复在箭头函数和其他长行中打印数组表达式时出现的一些意外换行问题 #917。贡献者:@faultyserver
¥Fix some accidental line breaks when printing array expressions within arrow functions and other long lines #917. Contributed by @faultyserver
-
与 Prettier 针对
ArrowChain布局的破坏性策略保持一致,#934 也采用了相同的策略。贡献者:@faultyserver¥Match Prettier’s breaking strategy for
ArrowChainlayouts #934. Contributed by @faultyserver -
修复了箭头链表达式 #951 中前导注释重复打印的问题。贡献者:@faultyserver
¥Fix double-printing of leading comments in arrow chain expressions #951. Contributed by @faultyserver
Linter
Section titled “Linter”¥Bug fixes
-
修复 #910,其中规则
noSvgWithoutTitle应跳过具有aria-hidden属性的元素。由 @vasucp1207 贡献¥Fix #910, where the rule
noSvgWithoutTitleshould skip elements that havearia-hiddenattributes. Contributed by @vasucp1207
¥New features
-
添加 useForOf 规则。当循环索引仅用于从正在迭代的数组中读取数据时,该规则建议使用 for-of 循环。由 @victor-teles 贡献
¥Add useForOf rule. The rule recommends a for-of loop when the loop index is only used to read from an array that is being iterated. Contributed by @victor-teles
¥Enhancement
-
地址 #924 和 #920。noUselessElse 现在会忽略至少跟在一个不会提前终止的
if语句之后的else子句。贡献者:@Conaclos¥Address #924 and #920. noUselessElse now ignores
elseclauses that follow at least oneifstatement that doesn’t break early. Contributed by @Conaclos例如,以下代码不再被该规则报告:
¥For example, the following code is no longer reported by the rule:
function f(x) {if (x < 0) {// this `if` doesn't break early.} else if (x > 0) {return x;} else {// This `else` block was previously reported as useless.}}
¥Bug fixes
修复 #918。useSimpleNumberKeys 不再报告注释的误报。贡献者:@kalleep
¥Fix #918. useSimpleNumberKeys no longer reports false positive on comments. Contributed by @kalleep
-
修复 #953。noRedeclare 不再将不同映射类型中名称相同的类型参数报告为重复声明。贡献者:@Conaclos
¥Fix #953. noRedeclare no longer reports type parameters with the same name in different mapped types as redeclarations. Contributed by @Conaclos
修复 #608。useExhaustiveDependencies 不再报告没有依赖数组的 React Hooks 缺少依赖。贡献者:@kalleep
¥Fix #608. useExhaustiveDependencies no longer reports missing dependencies for React hooks without dependency array. Contributed by @kalleep
¥Parser
1.4.0 (2023-11-27)
Section titled “1.4.0 (2023-11-27)”-
从
lsp-proxy中移除 CLI 选项,因为它们原本就不应该传递给该命令。贡献者:@ematipico¥Remove the CLI options from the
lsp-proxy, as they were never meant to be passed to that command. Contributed by @ematipico -
为命令
lsp-proxy和start添加选项--config-path。现在可以指示守护进程服务器从自定义路径加载biome.json。贡献者:@ematipico¥Add option
--config-pathtolsp-proxyandstartcommands. It’s now possible to tell the Daemon server to loadbiome.jsonfrom a custom path. Contributed by @ematipico -
添加选项
--diagnostic-level。它允许用户控制 CLI 打印的诊断信息级别。可选值:"info"、"warn"和"hint"。贡献者:@simonxabris¥Add option
--diagnostic-level. It lets users control the level of diagnostics printed by the CLI. Possible values are:"info","warn", and"hint". Contributed by @simonxabris -
将选项
--line-feed添加到format命令。贡献者:@SuperchupuDev¥Add option
--line-feedto theformatcommand. Contributed by @SuperchupuDev -
将选项
--bracket-same-line添加到format命令。贡献者:@faultyserver¥Add option
--bracket-same-lineto theformatcommand. Contributed by @faultyserver -
将选项
--bracket-spacing添加到format命令。贡献者:@faultyserver¥Add option
--bracket-spacingto theformatcommand. Contributed by @faultyserver
¥Bug fixes
-
修复了命令
format,现在当存在待处理的差异时,它会返回非零退出代码。贡献者:@ematipico¥Fix the command
format, now it returns a non-zero exit code when if there pending diffs. Contributed by @ematipico
¥Formatter
¥New features
-
添加配置
formatter.lineFeed。它允许更改行尾类型。贡献者:@SuperchupuDev¥Add the configuration
formatter.lineFeed. It allows changing the type of line endings. Contributed by @SuperchupuDev -
添加配置
javascript.formatter.bracketSameLine。它允许控制多行 JSX 元素的>结尾是否应位于最后一个属性行。#627。贡献者:@faultyserver¥Add the configuration
javascript.formatter.bracketSameLine. It allows controlling whether ending>of a multi-line JSX element should be on the last attribute line or not. #627. Contributed by @faultyserver -
添加配置
javascript.formatter.bracketSpacing。它允许控制是否在对象字面量的括号周围插入空格。#627。贡献者:@faultyserver¥Add the configuration
javascript.formatter.bracketSpacing. It allows controlling whether spaces are inserted around the brackets of object literals. #627. Contributed by @faultyserver
¥Bug fixes
-
修复 #832,格式化程序不再在类型参数列表中保留不必要的尾随逗号。贡献者:@Conaclos
¥Fix #832, the formatter no longer keeps an unnecessary trailing comma in type parameter lists. Contributed by @Conaclos
class A<T,> {}class A<T> {} -
修复 #301,格式化程序不应在
in关键字之前中断。贡献者:@ematipico¥Fix #301, the formatter should not break before the
inkeyword. Contributed by @ematipico
Linter
Section titled “Linter”¥Promoted rules
以下规则现已推荐:
¥The following rules are now recommended:
以下规则现已弃用:
¥The following rules are now deprecated:
-
correctness/noNewSymbol 该规则已被 correctness/noInvalidNewBuiltin 替换。
¥correctness/noNewSymbol The rule is replaced by correctness/noInvalidNewBuiltin
¥New features
-
添加 noDefaultExport,禁止使用
export default。贡献者:@Conaclos¥Add noDefaultExport which disallows
export default. Contributed by @Conaclos -
添加 noAriaHiddenOnFocusable,报告隐藏元素和可聚焦元素。由 @vasucp1207 贡献
¥Add noAriaHiddenOnFocusable which reports hidden and focusable elements. Contributed by @vasucp1207
-
添加 noImplicitAnyLet,报告使用
let声明但未初始化且未进行类型注解的变量。由 @TaKO8Ki 和 @b4s36t4 贡献¥Add noImplicitAnyLet that reports variables declared with
letand without initialization and type annotation. Contributed by @TaKO8Ki and @b4s36t4 -
添加 useAwait,报告未使用
await表达式的async函数。¥Add useAwait that reports
asyncfunctions that don’t use anawaitexpression. -
添加 useValidAriaRole。由 @vasucp1207 贡献
¥Add useValidAriaRole. Contributed by @vasucp1207
-
添加 useRegexLiterals,建议将对正则表达式构造函数的调用转换为正则表达式字面量。由 @Yuiki 贡献
¥Add useRegexLiterals that suggests turning call to the regex constructor into regex literals. COntributed by @Yuiki
¥Enhancements
-
为 a11y/useAriaActivedescendantWithTabindex 添加不安全代码修复。
¥Add an unsafe code fix for a11y/useAriaActivedescendantWithTabindex
¥Bug fixes
-
修复 #639 问题,忽略未使用的 TypeScript 映射键。贡献者:@Conaclos
¥Fix #639 by ignoring unused TypeScript’s mapped key. Contributed by @Conaclos
-
修复 #565 问题,处理 TypeScript 条件类型的 extends 子句中多个同名
infer的情况。贡献者:@Conaclos¥Fix #565 by handling several
inferwith the same name in extends clauses of TypeScript’s conditional types. Contributed by @Conaclos
修复 #653。noUnusedImports 现在可以正确删除包含未使用的 import 的整行。贡献者:@Conaclos
¥Fix #653. noUnusedImports
now correctly removes the entire line where the unused import is. Contributed by @Conaclos
-
修复 #607 和
useExhaustiveDependencies,忽略可选链式调用,贡献者:@msdlisper¥Fix #607
useExhaustiveDependencies, ignore optional chaining, Contributed by @msdlisper -
修复 #676,在应用代码操作时,使用正确的节点来处理
"noreferrer"。贡献者:@ematipico¥Fix #676, by using the correct node for the
"noreferrer"when applying the code action. Contributed by @ematipico -
修复 #455。CLI 现在可以正确地将复杂的表情符号打印到控制台。
¥Fix #455. The CLI can now print complex emojis to the console correctly.
修复 #727。当初始化表达式为 null 时,noInferrableTypes 现在可以正确保留类型注解。贡献者:@Conaclos
¥Fix #727. noInferrableTypes
now correctly keeps type annotations when the initialization expression is null. Contributed by @Conaclos
修复 #784,noSvgWithoutTitle 修复了 aria-label 的误报,并报告 svg 的 role 属性是隐式的。由 @unvalley 提供
¥Fix #784, noSvgWithoutTitle
fixes false-positives to aria-label and reports svg’s role attribute is implicit. Contributed by @unvalley
-
修复了 #834 中导致 noUselessLoneBlockStatements 报告 switch 语句块语句的问题。由 @vasucp1207 贡献
¥Fix #834 that made noUselessLoneBlockStatements reports block statements of switch clauses. Contributed by @vasucp1207
-
修复了 #783 中导致 noUselessLoneBlockStatements 报告
try-catch结构体块语句的问题。贡献者:@hougesen¥Fix #783 that made noUselessLoneBlockStatements reports block statements of
try-catchstructures. Contributed by @hougesen -
修复了 #69 中导致 correctness/noUnnecessaryContinue 错误报告用于中断 switch 语句的
continue的问题。贡献者:@TaKO8Ki¥Fix #69 that made correctness/noUnnecessaryContinue incorrectly reports a
continueused to break a switch clause. Contributed by @TaKO8Ki -
修复 #664 问题,改进在严格驼峰命名模式下检测到双大写字母时 style/useNamingConvention 的诊断。由 @vasucp1207 贡献
¥Fix #664 by improving the diagnostic of style/useNamingConvention when double capital are detected in strict camel case mode. Contributed by @vasucp1207
-
修复 #643 错误地解析 complexity/useExhaustiveDependencies 的选项的问题。贡献者:@arendjr
¥Fix #643 that erroneously parsed the option of complexity/useExhaustiveDependencies. Contributed by @arendjr
¥Parser
¥Bug fixes
-
修复 #846 在同时启用 TypeScript 和 JSX 时,错误地将
<const T,>() => {}解析为 JSX 标签而不是箭头函数的问题。¥Fix #846 that erroneously parsed
<const T,>() => {}as a JSX tag instead of an arrow function when both TypeScript and JSX are enabled.
VSCode
Section titled “VSCode”1.3.3 (2023-10-31)
Section titled “1.3.3 (2023-10-31)”¥Analyzer
¥Bug fixes
-
修复 #604 中当在泛型类型参数中使用
void类型时,noConfusingVoidType 会报告误报的问题。由 @unvalley 提供¥Fix #604 which made noConfusingVoidType report false positives when the
voidtype is used in a generic type parameter. Contributed by @unvalley
¥Bug fixes
-
修复
overrides的行为。现在,ignore和include会应用或不应用覆盖模式,因此它们会相互覆盖。现在overrides中的选项会覆盖顶层选项。¥Fix how
overridesbehave. Nowignoreandincludeapply or not the override pattern, so they override each other. Now the options insideoverridesoverride the top-level options. -
仅在需要时启动日志记录器。贡献者:@ematipico
¥Bootstrap the logger only when needed. Contributed by @ematipico
-
修复
overrides的运行方式。属性ignore和include的语义不同,它们分别只应用/不应用覆盖。贡献者:@ematipico¥Fix how
overridesare run. The propertiesignoreandincludehave different semantics and only apply/not apply an override. Contributed by @ematipico
¥Editors
¥Bug fixes
-
修复 #592,更改 IntelliJ 插件中的二进制解析。贡献者:@Joshuabaker2
¥Fix #592, by changing binary resolution in the IntelliJ plugin. Contributed by @Joshuabaker2
¥Formatter
¥Bug fixes
-
当赋值表达式的右侧是
await表达式或 yield 表达式时,应用正确的布局。贡献者:@ematipico¥Apply the correct layout when the right hand of an assignment expression is an
awaitexpression or a yield expression. Contributed by @ematipico -
修复 #303,其中嵌套箭头函数未失效。由 @victor-teles 贡献
¥Fix #303, where nested arrow functions didn’t break. Contributed by @victor-teles
Linter
Section titled “Linter”¥New features
-
添加 noUnusedPrivateClassMembers 规则。该规则禁止使用未使用的私有类成员。由 @victor-teles 贡献
¥Add noUnusedPrivateClassMembers rule. The rule disallow unused private class members. Contributed by @victor-teles
¥Bug fixes
-
修复 #175 中 noRedeclare 会报告使用父作用域变量名的索引签名的问题。
¥Fix #175 which made noRedeclare report index signatures using the name of a variable in the parent scope.
-
修复 #557 中 noUnusedImports 会报告在
typeof表达式中使用的导入类型的问题。贡献者:@Conaclos¥Fix #557 which made noUnusedImports report imported types used in
typeofexpression. Contributed by @Conaclos -
修复 #576,移除 noSelfAssign 中的一些错误逻辑。贡献者:@ematipico
¥Fix #576 by removing some erroneous logic in noSelfAssign. Contributed by @ematipico
-
修复了 #861 导致 noUnusedVariables 始终将非括号箭头函数的参数报告为未使用的问题。
¥Fix #861 that made noUnusedVariables always reports the parameter of a non-parenthesize arrow function as unused.
-
修复 #595,更新 unsafe-apply 逻辑以避免 noUselessFragments 中出现意外错误。贡献者:@nissy-dev
¥Fix #595 by updating unsafe-apply logic to avoid unexpected errors in noUselessFragments. Contributed by @nissy-dev
-
修复 #591 中 noRedeclare 会报告名称相同但方法签名不同的类型参数的问题。贡献者:@Conaclos
¥Fix #591 which made noRedeclare report type parameters with identical names but in different method signatures. Contributed by @Conaclos
-
支持更多 a11y 角色并修复一些 a11y lint 规则的方法。贡献者:@nissy-dev
¥Support more a11y roles and fix some methods for a11y lint rules Contributed @nissy-dev
-
修复 #609 和
useExhaustiveDependencies,从已知钩子中移除useContext、useId和useSyncExternalStore。贡献者:@msdlisper¥Fix #609
useExhaustiveDependencies, by removinguseContext,useIdanduseSyncExternalStorefrom the known hooks. Contributed by @msdlisper -
修复
useExhaustiveDependencies,从已知钩子中移除useContext、useId和useSyncExternalStore。贡献者:@msdlisper¥Fix
useExhaustiveDependencies, by removinguseContext,useIdanduseSyncExternalStorefrom the known hooks. Contributed by @msdlisper -
修复 #871 和 #610。现在,
useHookAtTopLevel可以正确处理嵌套函数。贡献者:@arendjr¥Fix #871 and #610. Now
useHookAtTopLevelcorrectly handles nested functions. Contributed by @arendjr -
规则
useHookAtTopLevel的选项已被弃用,将在 Biome 2.0 中移除。该规则现在使用 React 设定的命名约定来确定 hooks。¥The options of the rule
useHookAtTopLevelare deprecated and will be removed in Biome 2.0. The rule now determines the hooks using the naming convention set by React.{"linter": {"rules": {"correctness": {"useHookAtTopLevel": "error","useHookAtTopLevel": {"level": "error","options": {"hooks": [{"name": "useLocation","closureIndex": 0,"dependenciesIndex": 1},{ "name": "useQuery", "closureIndex": 1, "dependenciesIndex": 0 }]}}}}}}
¥Parser
¥Enhancements
-
支持正则表达式 v 标志。贡献者:@nissy-dev
¥Support RegExp v flag. Contributed by @nissy-dev
-
改进错误消息。贡献者:@ematipico
¥Improve error messages. Contributed by @ematipico
1.3.1 (2023-10-20)
Section titled “1.3.1 (2023-10-20)”¥Bug fixes
-
修复
rage命令,现在它不再打印有关正在运行的服务器的信息。贡献者:@ematipico¥Fix
ragecommand, now it doesn’t print info about running servers. Contributed by @ematipico
¥Editors
¥Bug fixes
-
修复 #552,其中格式化程序在 Windows 系统中未正确触发。由 @victor-teles 贡献
¥Fix #552, where the formatter isn’t correctly triggered in Windows systems. Contributed by @victor-teles
Linter
Section titled “Linter”¥New features
-
添加 noThisInStatic 规则。由 @ditorodev 和 @Conaclos 贡献
¥Add noThisInStatic rule. Contributed by @ditorodev and @Conaclos
¥Bug fixes
-
修复 #548 导致 noSelfAssign 崩溃的问题。
¥Fix #548 which made noSelfAssign panic.
-
修复 #555,将
globals正确映射到工作区。¥Fix #555, by correctly map
globalsinto the workspace.
1.3.0 (2023-10-19)
Section titled “1.3.0 (2023-10-19)”¥Analyzer
¥Enhancements
-
现在可以安全地应用导入排序功能,并且在运行
check --apply而不是check --apply-unsafe时会应用该功能。¥Import sorting is safe to apply now, and it will be applied when running
check --applyinstead ofcheck --apply-unsafe. -
导入排序现在可以处理 Bun 导入
bun:<name>、绝对路径导入/<path>和 Node 的子路径导入#<name>。有关更多详细信息,请参阅 我们的文档。贡献者:@Conaclos¥Import sorting now handles Bun imports
bun:<name>, absolute path imports/<path>, and Node’s subpath imports#<name>. See our documentation for more details. Contributed by @Conaclos
¥Bug fixes
-
修复 #319。命令
biome lint现在会显示正确的选项。贡献者:@ematipico¥Fix #319. The command
biome lintnow shows the correct options. Contributed by @ematipico -
修复 #312。现在运行
biome --version将以状态码0而不是1退出。贡献者:@nhedger¥Fix #312. Running
biome --versionnow exits with status code0instead of1. Contributed by @nhedger -
修复了
extends功能无法继承到organizeImports.ignore的错误。贡献者:@ematipico¥Fix a bug where the
extendsfunctionality doesn’t carry overorganizeImports.ignore. Contributed by @ematipico -
现在,使用
stdin时,CLI 会返回原始内容,并且原始内容不会改变。贡献者:@ematipico¥The CLI now returns the original content when using
stdinand the original content doesn’t change. Contributed by @ematipico
¥New features
-
添加对
BIOME_BINARY环境变量的支持,以覆盖二进制文件的位置。贡献者:@ematipico¥Add support for
BIOME_BINARYenvironment variable to override the location of the binary. Contributed by @ematipico -
添加选项
--indent-width,并弃用选项--indent-size。贡献者:@ematipico¥Add option
--indent-width, and deprecated the option--indent-size. Contributed by @ematipico -
添加选项
--javascript-formatter-indent-width,并弃用选项--javascript-formatter-indent-size。贡献者:@ematipico¥Add option
--javascript-formatter-indent-width, and deprecated the option--javascript-formatter-indent-size. Contributed by @ematipico -
添加选项
--json-formatter-indent-width,并弃用选项--json-formatter-indent-size。贡献者:@ematipico¥Add option
--json-formatter-indent-width, and deprecated the option--json-formatter-indent-size. Contributed by @ematipico -
为命令
biome rage添加选项--daemon-logs。查看 Biome 守护进程服务器日志需要启用该选项。由 @unvalley 提供¥Add option
--daemon-logstobiome rage. The option is required to view Biome daemon server logs. Contributed by @unvalley -
添加日志记录支持。默认情况下,Biome 除了诊断信息外,不会记录任何其他内容。可以使用新选项
--log-level启用日志记录:¥Add support for logging. By default, Biome doesn’t log anything other than diagnostics. Logging can be enabled with the new option
--log-level:Terminal window biome format --log-level=info ./src日志记录分为四个级别,从最详细到最简洁:
debug、info、warn和error。以下是INFO日志的示例:例如:¥There are four different levels of logging, from the most verbose to the least verbose:
debug,info,warnanderror. Here’s how anINFOlog will look like:2023-10-05T08:27:01.954727Z INFO Analyze file ./website/src/playground/components/Resizable.tsxat crates/biome_service/src/file_handlers/javascript.rs:298 on biome::worker_5in Pulling diagnostics with categories: RuleCategories(SYNTAX)in Processes formatting with path: "./website/src/playground/components/Resizable.tsx"in Process check with path: "./website/src/playground/components/Resizable.tsx"你可以使用
--log-kind中的新选项自定义日志的显示方式。支持的类型如下:pretty、compact和json。¥You can customize how the log will look like with a new option
--log-kind. The supported kinds are:pretty,compactandjson.pretty是默认日志记录方式。以下是compact日志的示例:¥
prettyis the default logging. Here’s how acompactlog will look like:2023-10-05T08:29:04.864247Z INFO biome::worker_2 Process check:Processes linting:Pulling diagnostics: crates/biome_service/src/file_handlers/javascript.rs: Analyze file ./website/src/playground/components/Resizable.tsx path="./website/src/playground/components/Resizable.tsx" path="./website/src/playground/components/Resizable.tsx" categories=RuleCategories(LINT)2023-10-05T08:29:04.864290Z INFO biome::worker_7 Process check:Processes formatting: crates/biome_service/src/file_handlers/javascript.rs: Format file ./website/src/playground/components/Tabs.tsx path="./website/src/playground/components/Tabs.tsx" path="./website/src/playground/components/Tabs.tsx"2023-10-05T08:29:04.879332Z INFO biome::worker_2 Process check:Processes formatting:Pulling diagnostics: crates/biome_service/src/file_handlers/javascript.rs: Analyze file ./website/src/playground/components/Resizable.tsx path="./website/src/playground/components/Resizable.tsx" path="./website/src/playground/components/Resizable.tsx" categories=RuleCategories(SYNTAX)2023-10-05T08:29:04.879383Z INFO biome::worker_2 Process check:Processes formatting: crates/biome_service/src/file_handlers/javascript.rs: Format file ./website/src/playground/components/Resizable.tsx path="./website/src/playground/components/Resizable.tsx" path="./website/src/playground/components/Resizable.tsx"
¥Enhancements
-
已弃用环境变量
ROME_BINARY。请改用BIOME_BINARY。贡献者:@ematipico¥Deprecated the environment variable
ROME_BINARY. UseBIOME_BINARYinstead. Contributed by @ematipico -
启用版本控制系统 (VCS) 支持后,Biome 不再检查
.git文件夹是否存在。贡献者:@ematipico¥Biome doesn’t check anymore the presence of the
.gitfolder when VCS support is enabled. Contributed by @ematipico -
biome rage不会打印守护进程的日志,请使用biome rage --daemon-logs来打印。由 @unvalley 提供¥
biome ragedoesn’t print the logs of the daemon, usebiome rage --daemon-logsto print them. Contributed by @unvalley
¥Configuration
¥New features
-
添加选项
formatter.indentWidth,并弃用选项formatter.indentSize。贡献者:@ematipico¥Add option
formatter.indentWidth, and deprecated the optionformatter.indentSize. Contributed by @ematipico -
添加选项
javascript.formatter.indentWidth,并弃用选项javascript.formatter.indentSize。贡献者:@ematipico¥Add option
javascript.formatter.indentWidth, and deprecated the optionjavascript.formatter.indentSize. Contributed by @ematipico -
添加选项
json.formatter.indentWidth,并弃用选项json.formatter.indentSize。贡献者:@ematipico¥Add option
json.formatter.indentWidth, and deprecated the optionjson.formatter.indentSize. Contributed by @ematipico -
将选项
include添加到配置的多个部分。¥Add option
includeto multiple sections of the configuration-
files.include; -
formatter.include; -
linter.include; -
organizeImports.include;当同时指定include和ignore时,ignore优先于include。¥
organizeImports.include; Whenincludeandignoreare both specified,ignoretakes precedence overinclude
-
-
添加选项
overrides,用户可以在其中修改工具对特定文件或路径的行为。¥Add option
overrides, where users can modify the behaviour of the tools for certain files or paths.例如,可以修改格式化程序
lineWidth,甚至可以修改包含在 glob 路径generated/**中的某些文件的格式化程序quoteStyle:¥For example, it’s possible to modify the formatter
lineWidth, and evenquoteStylefor certain files that are included in glob pathgenerated/**:{"formatter": {"lineWidth": 100},"overrides": [{"include": ["generated/**"],"formatter": {"lineWidth": 160},"javascript": {"formatter": {"quoteStyle": "single"}}}]}或者你可以为特定路径禁用某些规则,并为其他路径禁用代码检查器:
¥Or, you can disable certain rules for certain path, and disable the linter for other paths:
{"linter": {"enabled": true,"rules": {"recommended": true}},"overrides": [{"include": ["lib/**"],"linter": {"rules": {"suspicious": {"noDebugger": "off"}}}},{"include": ["shims/**"],"linter": {"enabled": false}}]}
¥Bug fixes
-
修复 #343,
extends被错误地应用于biome.json文件。贡献者:@ematipico¥Fix #343,
extendswas incorrectly applied to thebiome.jsonfile. Contributed by @ematipico
¥Editors
¥Bug fixes
-
修复 #404。Biome 的 IntelliJ 插件现在可以在 Windows 系统上运行。由 @victor-teles 贡献
¥Fix #404. Biome intellij plugin now works on Windows. Contributed by @victor-teles
-
修复 #402。IntelliJ IDEA 上的 Biome
format插件现在可以识别 biome.json 文件。由 @victor-teles 贡献¥Fix #402. Biome
formaton intellij plugin now recognize biome.json. Contributed by @victor-teles
¥Formatter
¥Enhancements
-
使用
OnceCell表示记忆化内存,因为这是RefCell<Option>的实现方式。贡献者:@denbezrukov¥Use
OnceCellfor the Memoized memory because that’s what theRefCell<Option>implemented. Contributed by @denbezrukov
Linter
Section titled “Linter”¥Promoted rules
以下规则现已推荐:
¥The following rules are now recommended:
¥New features
-
添加 noEmptyCharacterClassInRegex 规则。该规则报告正则表达式字面量中的空字符类和空的取反字符类。贡献者:@Conaclos
¥Add noEmptyCharacterClassInRegex rule. The rule reports empty character classes and empty negated character classes in regular expression literals. Contributed by @Conaclos
-
添加 noMisleadingInstantiator 规则。该规则报告对
new和constructor方法的错误使用。由 @unvalley 提供¥Add noMisleadingInstantiator rule. The rule reports the misleading use of the
newandconstructormethods. Contributed by @unvalley -
添加 noUselessElse 规则。该规则报告可省略的
else子句,因为它们的if分支会断开。贡献者:@Conaclos¥Add noUselessElse rule. The rule reports
elseclauses that can be omitted because theirifbranches break. Contributed by @Conaclos -
添加 noUnusedImports 规则。该规则报告未使用的导入,并建议将其删除。贡献者:@Conaclos
¥Add noUnusedImports rule. The rule reports unused imports and suggests removing them. Contributed by @Conaclos
noUnusedVariables 还会报告未使用的导入,但不建议删除它们。一旦 noUnusedImports 稳定下来,noUnusedVariables 将不再报告未使用的导入。
¥noUnusedVariables reports also unused imports, but don’t suggest their removal. Once noUnusedImports stabilized, noUnusedVariables will not report unused imports.
-
添加 useShorthandAssign 规则。该规则强制使用结合了变量赋值和一些简单数学运算的简写运算符。例如,x = x + 4 可以简化为 x += 4。由 @victor-teles 贡献
¥Add useShorthandAssign rule. The rule enforce use of shorthand operators that combine variable assignment and some simple mathematical operations. For example, x = x + 4 can be shortened to x += 4. Contributed by @victor-teles
-
添加 useAsConstAssertion 规则。该规则强制使用
as const断言来推断字面类型。由 @unvalley 提供¥Add useAsConstAssertion rule. The rule enforce use of
as constassertion to infer literal types. Contributed by @unvalley -
添加 noMisrefactoredShorthandAssign 规则。该规则报告变量在两侧都出现的简写赋值。例如,
x += x + b由 @victor-teles 贡献¥Add noMisrefactoredShorthandAssign rule. The rule reports shorthand assigns when variable appears on both sides. For example
x += x + bContributed by @victor-teles -
添加 noApproximativeNumericConstant 规则。贡献者:@nikeee
¥Add noApproximativeNumericConstant rule. Contributed by @nikeee
添加 noInteractiveElementToNoninteractiveRole 规则。该规则强制不将非交互式 ARIA 角色分配给交互式 HTML 元素。贡献者:@nissy-dev
¥Add noInteractiveElementToNoninteractiveRole rule. The rule enforces the non-interactive ARIA roles are not assigned to interactive HTML elements. Contributed by @nissy-dev
-
添加 useAriaActivedescendantWithTabindex 规则。该规则强制将
tabIndex分配给带有aria-activedescendant的非交互式 HTML 元素。贡献者:@nissy-dev¥Add useAriaActivedescendantWithTabindex rule. The rule enforces that
tabIndexis assigned to non-interactive HTML elements witharia-activedescendant. Contributed by @nissy-dev -
添加 noUselessLoneBlockStatements 规则。该规则报告不包含任何词法作用域声明的独立代码块。贡献者:@emab
¥Add noUselessLoneBlockStatements rule. The rule reports standalone blocks that don’t include any lexical scoped declaration. Contributed by @emab
-
添加 noInvalidNewBuiltin 规则。该规则报告在
Symbol和BigInt中使用new的情况。贡献者:@lucasweng¥Add noInvalidNewBuiltin rule. The rule reports use of
newonSymbolandBigInt. Contributed by @lucasweng
¥Enhancements
-
以下规则现已修复为安全代码:
¥The following rules have now safe code fixes:
-
noAccumulatingSpread 会进行更多检查以减少潜在的误报。贡献者:@Vivalldi
¥noAccumulatingSpread makes more check in order to reduce potential false positives. Contributed by @Vivalldi
-
noConstAssign 现在提供了一个不安全代码修复程序,用于将
const替换为let。由 @vasucp1207 贡献¥noConstAssign now provides an unsafe code fix that replaces
constwithlet. Contributed by @vasucp1207 -
noExcessiveComplexity 的默认复杂度阈值现在是
15。贡献者:@arendjr¥noExcessiveComplexity default complexity threshold is now
15. Contributed by @arendjr -
noPositiveTabindexValue 现在提供了一个不安全代码修复程序,用于将制表符索引设置为
0。由 @vasucp1207 贡献¥noPositiveTabindexValue now provides an unsafe code fix that set to
0the tab index. Contributed by @vasucp1207 -
noUnusedLabels 不再报告不可拆分的带标签语句。贡献者:@Conaclos
¥noUnusedLabels no longer reports unbreakable labeled statements. Contributed by @Conaclos
-
noUnusedVariables 现在报告未使用的 TypeScript 类型参数。贡献者:@Conaclos
¥noUnusedVariables now reports unused TypeScript’s type parameters. Contributed by @Conaclos
-
useAnchorContent 现在提供了一个不安全代码修复程序,用于移除
aria-hidden属性。由 @vasucp1207 贡献¥useAnchorContent now provides an unsafe code fix that removes the `aria-hidden“ attribute. Contributed by @vasucp1207
-
useValidAriaProps 现在提供了一个不安全代码修复程序,用于移除无效属性。由 @vasucp1207 贡献
¥useValidAriaProps now provides an unsafe code fix that removes invalid properties. Contributed by @vasucp1207
-
noExcessiveComplexity已重命名为noExcessiveCognitiveComplexity¥
noExcessiveComplexitywas renamed tonoExcessiveCognitiveComplexity
¥Bug fixes
修复 #294。noConfusingVoidType 不再报告返回类型的误报。贡献者:@b4s36t4
¥Fix #294. noConfusingVoidType no longer reports false positives for return types. Contributed by @b4s36t4
修复 #313。noRedundantUseStrict 现在会保留前导注释。
¥Fix #313. noRedundantUseStrict now keeps leading comments.
修复 #383。noMultipleSpacesInRegularExpressionLiterals 现在提供了针对连续空格后跟量词的正确代码修复程序。贡献者:@Conaclos
¥Fix #383. noMultipleSpacesInRegularExpressionLiterals now provides correct code fixes when consecutive spaces are followed by a quantifier. Contributed by @Conaclos
修复 #397。useNumericLiterals 现在提供了针对带符号数字的正确代码修复程序。贡献者:@Conaclos
¥Fix #397. useNumericLiterals now provides correct code fixes for signed numbers. Contributed by @Conaclos
-
修复 452。代码检查器在遇到格式错误的正则表达式(未以斜杠结尾的正则表达式)时报错。
¥Fix 452. The linter panicked when it met a malformed regex (a regex not ending with a slash).
-
修复 #104。现在,我们可以正确处理同名类型和值。
¥Fix #104. We now correctly handle types and values with the same name.
-
修复 #243 中 noUndeclaredVariables 规则中
infer类型定义的作用域错误导致的误报。贡献者:@denbezrukov¥Fix #243 a false positive case where the incorrect scope was defined for the
infertype in rule noUndeclaredVariables. Contributed by @denbezrukov -
修复 #322,现在 noSelfAssign 可以正确处理调用表达式中的字面量。
¥Fix #322, now noSelfAssign correctly handles literals inside call expressions.
-
改变了 noSelfAssign 的行为。该规则不再在函数调用时触发。贡献者:@ematipico
¥Changed how noSelfAssign behaves. The rule is not triggered anymore on function calls. Contributed by @ematipico
¥Parser
-
增强解析器中类型推断处理的诊断功能。‘infer’ 关键字只能在条件类型的 ‘extends’ 子句中使用。在上下文之外使用它会导致错误。确保所有使用 ‘infer’ 的类型声明都正确放置在条件类型结构中,以避免解析问题。贡献者:@denbezrukov
¥Enhance diagnostic for infer type handling in the parser. The ‘infer’ keyword can only be utilized within the ’ extends’ clause of a conditional type. Using it outside this context will result in an error. Ensure that any type declarations using ‘infer’ are correctly placed within the conditional type structure to avoid parsing issues. Contributed by @denbezrukov
-
新增对解析 JSON 文件中尾随逗号的支持:
¥Add support for parsing trailing commas inside JSON files:
{"json": {"parser": {"allowTrailingCommas": true}}}贡献者:@nissy-dev
¥Contributed by @nissy-dev
VSCode
Section titled “VSCode”1.2.2 (2023-09-16)
Section titled “1.2.2 (2023-09-16)”¥Bug fixes
-
修复了运行
biome check --apply时导入排序未生效的问题。¥Fix a condition where import sorting wasn’t applied when running
biome check --apply
1.2.1 (2023-09-15)
Section titled “1.2.1 (2023-09-15)”¥Configuration
-
修复了格式化程序语言配置未被选中的极端情况。
¥Fix an edge case where the formatter language configuration wasn’t picked.
-
修复配置架构,其中
json.formatter属性未转换为驼峰命名法。¥Fix the configuration schema, where
json.formatterproperties weren’t transformed in camel case.
1.2.0 (2023-09-15)
Section titled “1.2.0 (2023-09-15)”¥New features
-
新增选项,可根据文件语言自定义格式化程序的行为。
¥Add new options to customize the behaviour the formatter based on the language of the file
-
--json-formatter-enabled -
--json-formatter-indent-style -
--json-formatter-indent-size -
--json-formatter-line-width -
--javascript-formatter-enabled -
--javascript-formatter-indent-style -
--javascript-formatter-indent-size -
--javascript-formatter-line-width
-
¥Bug fixes
-
修复了运行
biome ci命令时--errors-on-warning无法正常工作的问题。¥Fix a bug where
--errors-on-warningdidn’t work when runningbiome cicommand.
¥Configuration
¥New features
-
新增选项,可根据文件语言自定义格式化程序的行为。
¥Add new options to customize the behaviour of the formatter based on the language of the file
-
json.formatter.enabled -
json.formatter.indentStyle -
json.formatter.indentSize -
json.formatter.lineWidth -
javascript.formatter.enabled -
javascript.formatter.indentStyle -
javascript.formatter.indentSize -
javascript.formatter.lineWidth
-
Linter
Section titled “Linter”¥Promoted rules
新规则在 nursery 组中进行孵化。一旦稳定下来,我们就将它们提升为稳定规则。以下规则已推广:
¥New rules are incubated in the nursery group. Once stable, we promote them to a stable group. The following rules are promoted:
¥New rules
-
添加 noConfusingVoidType 规则。该规则报告
void类型的异常使用。贡献者:@shulandmimi¥Add noConfusingVoidType rule. The rule reports the unusual use of the
voidtype. Contributed by @shulandmimi
¥Removed rules
-
移除
noConfusingArrow¥Remove
noConfusingArrow代码格式化工具(例如 Prettier 和 Biome)始终会在参数或箭头函数体周围添加括号。这将导致该规则无效。
¥Code formatters, such as prettier and Biome, always adds parentheses around the parameter or the body of an arrow function. This makes the rule useless.
贡献者:@Conaclos
¥Contributed by @Conaclos
¥Enhancements
-
noFallthroughSwitchClause 现在依靠控制流分析来报告大部分 switch 语句的执行情况。贡献者:@Conaclos
¥noFallthroughSwitchClause now relies on control flow analysis to report most of the switch clause fallthrough. Contributed by @Conaclos
-
noAssignInExpressions 不再建议代码修复。大多数情况下,建议与用户的预期不符。贡献者:@Conaclos
¥noAssignInExpressions no longer suggest code fixes. Most of the time the suggestion didn’t match users’ expectations. Contributed by @Conaclos
-
noUselessConstructor 不再发出安全的代码修复。贡献者:@Conaclos
¥noUselessConstructor no longer emits safe code fixes. Contributed by @Conaclos
所有代码修复现在都被视为不安全代码修复。移除构造函数可能会改变程序的行为。
¥All code fixes are now emitted as unsafe code fixes. Removing a constructor can change the behavior of a program.
-
useCollapsedElseIf 现在只提供安全的代码修复。贡献者:@Conaclos
¥useCollapsedElseIf now only provides safe code fixes. Contributed by @Conaclos
-
noUnusedVariables 现在会报告更多情况。
¥noUnusedVariables now reports more cases.
该规则现在可以忽略自身写入。例如,该规则报告以下未使用的变量:
¥The rule is now able to ignore self-writes. For example, the rule reports the following unused variable:
let a = 0;a++;a += 1;该规则还能检测到未使用的、使用自身的声明。例如,该规则报告以下未使用的接口:
¥The rule is also capable of detecting an unused declaration that uses itself. For example, the rule reports the following unused interface:
interface I {instance(): I}最后,该规则现在会忽略所有 TypeScript 声明文件,包括 全局声明文件。
¥Finally, the rule now ignores all TypeScript declaration files, including global declaration files.
贡献者:@Conaclos
¥Contributed by @Conaclos
¥Bug fixes
-
修复 #182,使 useLiteralKeys 保留可选链。贡献者:@denbezrukov
¥Fix #182, making useLiteralKeys retains optional chaining. Contributed by @denbezrukov
-
修复 #168,修复稳定钩子位于新行时 useExhaustiveDependencies 的误报情况。贡献者:@denbezrukov
¥Fix #168, fix useExhaustiveDependencies false positive case when stable hook is on a new line. Contributed by @denbezrukov
-
修复 #137,修复 TypeScript 模块声明时 noRedeclare 的误报情况。
¥Fix #137, fix noRedeclare false positive case with TypeScript module declaration:
declare module '*.gif' {const src: string;}declare module '*.bmp' {const src: string;}贡献者:@denbezrukov
¥Contributed by @denbezrukov
-
修复 #258,修复规则移除赋值语句时 noUselessFragments 的误报情况。贡献者:@denbezrukov
¥Fix #258, fix noUselessFragments the case where the rule removing an assignment. Contributed by @denbezrukov
-
修复 #266,
complexity/useLiteralKeys发出了一个包含无效 AST 的代码操作。贡献者:@ematipico¥Fix #266, where
complexity/useLiteralKeysemitted a code action with an invalid AST. Contributed by @ematipico -
修复 #105,移除 noUnusedVariables 报告的误报。
¥Fix #105, removing false positives reported by noUnusedVariables.
该规则不再将以下已使用变量报告为未使用:
¥The rule no longer reports the following used variable:
const a = f(() => a);贡献者:@Conaclos
¥Contributed by @Conaclos
VSCode
Section titled “VSCode”¥Enhancements
-
改进使用某些包管理器(尤其是 pnpm)时的服务器二进制文件解析。
¥Improve server binary resolution when using certain package managers, notably pnpm.
新的策略是指向
node_modules/.bin/biome路径,这对于所有包管理器都是一致的。¥The new strategy is to point to
node_modules/.bin/biomepath, which is consistent for all package managers.
1.1.2 (2023-09-07)
Section titled “1.1.2 (2023-09-07)”¥Editors
¥Bug fixes
-
修复了空 JSON 文件会导致 LSP 服务器崩溃的问题。贡献者:@ematipico
¥Fix a case where an empty JSON file would cause the LSP server to crash. Contributed by @ematipico
Linter
Section titled “Linter”¥Enhancements
-
useNamingConvention 现在支持 PascalCase 格式的导入命名空间,并拒绝 CONSTANT_CASE 格式的导出命名空间。
¥useNamingConvention now accepts import namespaces in PascalCase and rejects export namespaces in CONSTANT_CASE.
以下代码现在可以被正确解析:有效:
¥The following code is now valid:
import * as React from "react";以下代码现在无效:
¥And the following code is now invalid:
export * as MY_NAMESPACE from "./lib.js";贡献者:@Conaclos
¥Contributed by @Conaclos
-
noUselessConstructor 现在会忽略装饰器类和装饰器参数。当参数带有类型注解时,该规则现在会给出建议,而不是直接给出安全修复。贡献者:@Conaclos
¥noUselessConstructor now ignores decorated classes and decorated parameters. The rule now gives suggestions instead of safe fixes when parameters are annotated with types. Contributed by @Conaclos
1.1.1 (2023-09-07)
Section titled “1.1.1 (2023-09-07)”¥Analyzer
¥Bug fixes
-
// rome-ignore抑制注释的诊断信息不应显示为警告。警告可能会阻塞 CI,使逐步迁移变得困难。因此,将// rome-ignore更改为// biome-ignore的代码操作已被禁用。贡献者:@ematipico¥The diagnostic for
// rome-ignoresuppression comment should not be a warning. A warning could block the CI, marking a gradual migration difficult. The code action that changes// rome-ignoreto// biome-ignoreis disabled as consequence. Contributed by @ematipico
1.1.0 (2023-09-06)
Section titled “1.1.0 (2023-09-06)”¥Analyzer
¥Enhancements
-
添加代码操作,将
rome-ignore替换为biome-ignore。使用biome check --apply-unsafe更新所有注释。此操作并非万无一失,可能会生成不需要的代码,因此属于不安全操作。贡献者:@ematipico¥Add a code action to replace
rome-ignorewithbiome-ignore. Usebiome check --apply-unsafeto update all the comments. The action is not bulletproof, and it might generate unwanted code, that’s why it’s unsafe action. Contributed by @ematipico
¥Enhancements
-
当找到
rome.json文件时,Biome 现在会报告诊断信息。¥Biome now reports a diagnostics when a
rome.jsonfile is found. -
biome migrate --write从rome.json创建biome.json,但不会删除rome.json文件。贡献者:@ematipico¥
biome migrate --writecreatesbiome.jsonfromrome.json, but it won’t delete therome.jsonfile. Contributed by @ematipico
¥Bug fixes
-
Biome 首先使用
biome.json,然后尝试使用rome.json。¥Biome uses
biome.jsonfirst, then it attempts to userome.json. -
修复了启用 VSC 集成后,Biome 无法正确计算忽略文件的问题。贡献者:@ematipico
¥Fix a case where Biome couldn’t compute correctly the ignored files when the VSC integration is enabled. Contributed by @ematipico
¥Configuration
¥Editors
¥Bug fixes
-
LSP 现在使用自己的套接字,不再依赖 Biome 的套接字。此修复程序修复了用户在
rage输出中看到多个服务器的情况。¥The LSP now uses its own socket and won’t rely on Biome’s socket. This fixes some cases where users were seeing multiple servers in the
rageoutput.
¥Formatter
¥Enhancements
-
你可以将
// biome-ignore用作抑制注释。¥You can use
// biome-ignoreas suppression comment. -
// rome-ignore抑制功能已弃用。¥The
// rome-ignoresuppression is deprecated.
JavaScript API
Section titled “JavaScript API”Linter
Section titled “Linter”¥New features
-
添加 useCollapsedElseIf 规则。此新规则要求合并
else和if,前提是if语句是else代码块中的唯一语句。贡献者:@n-gude¥Add useCollapsedElseIf rule. This new rule requires merging an
elseand anif, if theifstatement is the only statement in theelseblock. Contributed by @n-gude
¥Enhancements
-
useTemplate 现在会报告所有字符串连接。
¥useTemplate now reports all string concatenations.
之前,该规则会忽略值与换行符或反引号的连接。例如,以下字符串拼接未被报告:
¥Previously, the rule ignored concatenation of a value and a newline or a backquote. For example, the following concatenation was not reported:
v + "\n";"`" + v + "`";该规则现在会报告这些情况,并建议进行以下代码修复:
¥The rule now reports these cases and suggests the following code fixes:
v + "\n";`${v}\n`;v + "`";`\`${v}\``;贡献者:@Conaclos
¥Contributed by @Conaclos
-
useExponentiationOperator 建议改进代码修复。
¥useExponentiationOperator suggests better code fixes.
该规则现在会保留指数之前的任何注释,以及底数或指数周围的任何括号。它会在幂运算符
**周围添加空格,并且始终为更新前后添加括号。¥The rule now preserves any comment preceding the exponent, and it preserves any parenthesis around the base or the exponent. It also adds spaces around the exponentiation operator
**, and always adds parentheses for pre- and post-updates.Math.pow(a++, /**/ (2))(a++) ** /**/ (2)贡献者:@Conaclos
¥Contributed by @Conaclos
-
你可以将
// biome-ignore用作抑制注释。¥You can use
// biome-ignoreas suppression comment. -
// rome-ignore抑制功能已弃用。¥The
// rome-ignoresuppression is deprecated.
¥Bug fixes
-
修复 #80,使 noDuplicateJsxProps 不区分大小写。
¥Fix #80, making noDuplicateJsxProps case-insensitive.
一些框架,例如 Material UI,依赖于 JSX 属性的大小写敏感性。例如,TextField 有两个同名属性,但情况不同:
¥Some frameworks, such as Material UI, rely on the case-sensitivity of JSX properties. For example, TextField has two properties with the same name, but distinct cases:
<TextField inputLabelProps="" InputLabelProps=""></TextField>贡献者:@Conaclos
¥Contributed by @Conaclos
-
修复 #138
¥Fix #138
noCommaOperator 现在可以正确忽略
for循环更新部分中所有逗号运算符的使用。以下代码现在可以被正确忽略:¥noCommaOperator now correctly ignores all use of comma operators inside the update part of a
forloop. The following code is now correctly ignored:for (let i = 0, j = 1, k = 2;i < 100;i++, j++, k++) {}贡献者:@Conaclos
¥Contributed by @Conaclos
-
修复 rome#4713。
¥Fix rome#4713.
之前,useTemplate 会给出以下建议:
¥Previously, useTemplate made the following suggestion:
a + b + "px"`${a}${b}px`这会破坏
a和b为数字的代码。¥This breaks code where
aandbare numbers.现在,该规则会提出以下建议:
¥Now, the rule makes the following suggestion:
a + b + "px"`${a + b}px`贡献者:@Conaclos
¥Contributed by @Conaclos
-
修复 rome#4109
¥Fix rome#4109
之前,当代码开头或结尾存在单行注释时,useTemplate 会建议一个无效的代码修复:
¥Previously, useTemplate suggested an invalid code fix when a leading or trailing single-line comment was present:
// leading comment1 /* inner comment */ + "+" + 2 // trailing comment`${// leading comment1 /* inner comment */}+${2 //trailing comment}` // trailing comment现在,该规则可以正确处理这种情况:
¥Now, the rule correctly handles this case:
// leading comment1 + "+" + 2 // trailing comment`${1}+${2}` // trailing comment作为副作用,该规则还会建议删除任何内部注释。
¥As a sideeffect, the rule also suggests the removal of any inner comments.
贡献者:@Conaclos
¥Contributed by @Conaclos
-
修复 rome#3850
¥Fix rome#3850
以前,useExponentiationOperator 在特定特殊情况下会建议无效代码:
¥Previously useExponentiationOperator suggested invalid code in a specific edge case:
1 +Math.pow(++a, 2)1 +++a**2现在,该规则会正确添加括号:
¥Now, the rule properly adds parentheses:
1 +Math.pow(++a, 2)1 +(++a) ** 2贡献者:@Conaclos
¥Contributed by @Conaclos
-
修复 #106
¥Fix #106
noUndeclaredVariables 现在可以正确识别某些 TypeScript 类型,例如
Uppercase。¥noUndeclaredVariables now correctly recognizes some TypeScript types such as
Uppercase.贡献者:@Conaclos
¥Contributed by @Conaclos
-
修复 rome#4616
¥Fix rome#4616
以前,noUnreachableSuper 会报告包含复杂嵌套控制流结构的有效代码。
¥Previously noUnreachableSuper reported valid codes with complex nesting of control flow structures.
贡献者:@Conaclos
¥Contributed by @Conaclos
1.0.0 (2023-08-28)
Section titled “1.0.0 (2023-08-28)”¥Analyzer
BREAKING CHANGES
Section titled “BREAKING CHANGES”-
“整理导入”功能现在按 “distance” 对导入语句进行分组。
¥The organize imports feature now groups import statements by “distance”.
用户的 “farther” 模块放在最顶层,用户的 “closer” 模块放在最底层。查看 documentation 以了解更多信息。
¥Modules “farther” from the user are put on the top, and modules “closer” to the user are placed on the bottom. Check the documentation for more information about it.
-
“整理导入”工具默认启用。如果你不想使用 GraphQL 格式化和检查功能,则需要显式禁用它:
¥The organize imports tool is enabled by default. If you don’t want to use it, you need to disable it explicitly:
{"organizeImports": {"enabled": false}}
BREAKING CHANGES
Section titled “BREAKING CHANGES”-
如果配置中存在错误,CLI 现在会以错误代码退出。
¥The CLI now exists with an error when there’s an error inside the configuration.
之前,Biome 会发出警告并应用其默认值继续执行。
¥Previously, biome would raise warnings and continue the execution by applying its defaults.
这对用户来说可能更好,因为它可能会在代码检查或格式化代码时产生误报,而这些代码的配置并非用户的配置。
¥This could have been better for users because this could have created false positives in linting or formatted code with a configuration that wasn’t the user’s.
-
命令
biome check现在会在检查代码时显示格式化程序诊断信息。¥The command
biome checknow shows formatter diagnostics when checking the code.当命令执行完毕时,如果存在诊断信息,则会返回错误代码。
¥The diagnostics presence will result in an error code when the command finishes.
这与命令
biome check的语义和行为一致。¥This aligns with semantic and behaviour meant for the command
biome check. -
init命令生成一个biome.json文件;¥
initcommand emits abiome.jsonfile;
¥Other changes
-
修复 #4670,避免在默认导出为空时崩溃。
¥Fix #4670, don’t crash at empty default export.
-
修复 #4556,修复了在不同操作系统上正确处理
.gitignore文件中换行符的问题。¥Fix #4556, which correctly handles new lines in the
.gitignorefile across OS. -
新增选项
--files-ignore-unknown,用于忽略未知文件。¥Add a new option to ignore unknown files
--files-ignore-unknown:Terminal window biome format --files-ignore-unknown ./src这样,Biome 就不会对无法处理的文件发出诊断信息。
¥Doing so, Biome won’t emit diagnostics for files that doesn’t know how to handle.
-
新增选项
--no-errors-on-unmatched:¥Add the new option
--no-errors-on-unmatched:Terminal window biome format --no-errors-on-unmatched ./src如果在给定路径中没有处理任何文件,Biome 不会返回错误代码退出。
¥Biome doesn’t exit with an error code if no files were processed in the given paths.
-
修复运行
biome format命令时发出的诊断信息。¥Fix the diagnostics emitted when running the
biome formatcommand. -
Biome 现在不会在发现目录之间(可能无限)的符号链接时发出警告。
¥Biome no longer warns when discovering (possibly infinite) symbolic links between directories.
这修复了 #4193 在多个符号链接指向单个文件或目录时导致的错误警告。指向其他符号链接的符号链接如果嵌套过深,仍然会触发警告。
¥This fixes #4193 which resulted in incorrect warnings when a single file or directory was pointed at by multiple symbolic links. Symbolic links to other symbolic links do still trigger warnings if they are too deeply nested.
-
引入了一个名为
biome lint的新命令,该命令只会对代码库运行代码检查规则。¥Introduced a new command called
biome lint, which will only run lint rules against the code base. -
Biome 将已知文件识别为 “允许使用带注释的 JSON 文件”:
¥Biome recognizes known files as “JSON files with comments allowed”:
-
typescript.json; -
tsconfig.json; -
jsconfig.json; -
tslint.json; -
babel.config.json; -
.babelrc.json; -
.ember-cli; -
typedoc.json; -
.eslintrc.json; -
.eslintrc; -
.jsfmtrc; -
.jshintrc; -
.swcrc; -
.hintrc; -
.babelrc;
-
-
添加对
biome.json的支持;¥Add support for
biome.json;
¥Configuration
¥Other changes
-
新增选项 ,用于忽略未知文件。
¥Add a new option to ignore unknown files:
{"files": {"ignoreUnknown": true}}这样,Biome 就不会对无法处理的文件发出诊断信息。
¥Doing so, Biome won’t emit diagnostics for file that it doesn’t know how to handle.
-
添加一个新的
"javascript"选项以支持不安全/实验性参数装饰器。¥Add a new
"javascript"option to support the unsafe/experimental parameter decorators:{"javascript": {"parser": {"unsafeParameterDecoratorsEnabled": true}}} -
添加一个新的
"extends"选项,用于将配置文件拆分为多个文件。¥Add a new
"extends"option, useful to split the configuration file in multiple files:{"extends": ["../sharedFormatter.json", "linter.json"]}文件解析基于文件系统,Biome 目前尚不支持解析依赖。
¥The resolution of the files is file system based, Biome doesn’t know how to resolve dependencies yet.
-
即使传递了
--apply-safe或--apply-unsafe,命令biome check和biome lint现在也会显示剩余的诊断信息。¥The commands
biome checkandbiome lintnow show the remaining diagnostics even when--apply-safeor--apply-unsafeare passed. -
修复命令
biome check和biome lint,如果未发出任何错误诊断信息,它们将不会返回错误代码。¥Fix the commands
biome checkandbiome lint, they won’t exit with an error code if no error diagnostics are emitted. -
新增选项
--error-on-warnings,指示 Biome 在发出警告时以错误代码退出。¥Add a new option
--error-on-warnings, which instructs Biome to exit with an error code when warnings are emitted.Terminal window biome check --error-on-warnings ./src -
添加配置以启用解析 JSON 文件中的注释。
¥Add a configuration to enable parsing comments inside JSON files:
{"json": {"parser": {"allowComments": true}}}
¥Editors
¥Other changes
-
Biome LSP 现在可以显示属于 JSON lint 规则的诊断信息。
¥The Biome LSP can now show diagnostics belonging to JSON lint rules.
-
启用
editor.codeActionsOnSave.quickfix.biome后,Biome LSP 不再在保存时应用不安全的快速修复。¥The Biome LSP no longer applies unsafe quickfixes on-save when
editor.codeActionsOnSave.quickfix.biomeis enabled. -
修复 #4564;文件过大时不会报错。
¥Fix #4564; files too large don’t emit errors.
-
当文件被忽略或过大时,Biome LSP 会向客户端发送消息。
¥The Biome LSP sends client messages when files are ignored or too big.
¥Formatter
-
新增名为
--jsx-quote-style的选项。¥Add a new option called
--jsx-quote-style.此选项允许你选择 JSX 属性使用单引号还是双引号。
¥This option lets you choose between single and double quotes for JSX attributes.
-
添加选项
--arrow-parentheses。¥Add the option
--arrow-parentheses.此选项允许设置箭头函数的括号样式。
¥This option allows setting the parentheses style for arrow functions.
-
JSON 格式化程序现在可以格式化带有注释的
.json文件。¥The JSON formatter can now format
.jsonfiles with comments.
Linter
Section titled “Linter”¥Removed rules
-
移除
complexity/noExtraSemicolon(#4553)¥Remove
complexity/noExtraSemicolon(#4553)Biome 格式化程序会自动移除多余的分号。因此,不再需要此规则。
¥The Biome formatter takes care of removing extra semicolons. Thus, there is no need for this rule.
-
移除
useCamelCase¥Remove
useCamelCase请改用 useNamingConvention。
¥Use useNamingConvention instead.
¥New rules
-
¥Add noGlobalIsFinite
此规则建议使用
Number.isFinite代替全局且不安全的isFinite(isFinite会尝试类型强制转换)。¥This rule recommends using
Number.isFiniteinstead of the global and unsafeisFinitethat attempts a type coercion. -
¥Add noGlobalIsNan
此规则建议使用
Number.isNaN代替全局且不安全的isNaN(isNaN会尝试类型强制转换)。¥This rule recommends using
Number.isNaNinstead of the global and unsafeisNaNthat attempts a type coercion. -
¥Add noUnsafeDeclarationMerging
此规则禁止在接口和类之间合并声明。
¥This rule disallows declaration merging between an interface and a class.
-
¥Add noUselessThisAlias
此规则禁止在箭头函数中使用无用的
this别名。¥This rule disallows useless aliasing of
thisin arrow functions. -
¥Add useArrowFunction
此规则建议将函数表达式转换为箭头函数。使用
this的函数表达式将被忽略。¥This rule proposes turning function expressions into arrow functions. Function expressions that use
thisare ignored. -
¥Add noDuplicateJsonKeys
此规则禁止 JSON 对象中出现重复键。
¥This rule disallow duplicate keys in a JSON object.
-
添加 noVoid
¥Add noVoid
此规则禁止使用
void。¥This rule disallows the use of
void. -
此规则禁止在字符串字面量中使用
\8和\9转义序列。¥This rule disallows
\8and\9escape sequences in string literals. -
¥Add noUselessEmptyExport
此规则禁止使用无用的
export {}。¥This rule disallows useless
export {}. -
添加 useIsArray
¥Add useIsArray
此规则建议使用
Array.isArray()代替instanceof Array。¥This rule proposes using
Array.isArray()instead ofinstanceof Array. -
¥Add useGetterReturn
此规则强制要求 getter 中必须包含非空的 return 语句。这将导致以下代码不正确:
¥This rule enforces the presence of non-empty return statements in getters. This makes the following code incorrect:
class Person {get firstName() {}}
¥Promoted rules
新规则已发布,请查看 #4750 了解更多详情:
¥New rules are promoted, please check #4750 for more details:
以下规则现已推荐:
¥The following rules are now recommended:
¥Other changes
-
新增 TypeScript 全局变量(
AsyncDisposable、Awaited、DecoratorContext等)4643。¥Add new TypeScript globals (
AsyncDisposable,Awaited,DecoratorContext, and others) 4643. -
noRedeclare:允许重新声明索引签名,如果索引签名位于不同的类型成员 #4478 中
¥noRedeclare: allow redeclare of index signatures are in different type members #4478
改进 noConsoleLog、noGlobalObjectCalls、useIsNan 和 useNumericLiterals,使其能够处理 globalThis 和 window 命名空间。
¥Improve noConsoleLog, noGlobalObjectCalls, useIsNan, and useNumericLiterals by handling
globalThis and window
namespaces.
例如,以下代码现在会被 noConsoleLog 报告:
¥For instance, the following code is now reported by noConsoleLog:
globalThis.console.log("log")-
改进 noDuplicateParameters 以管理构造函数参数。
¥Improve noDuplicateParameters to manage constructor parameters.
-
¥Improve noInnerDeclarations
现在,该规则不会对环境 TypeScript 声明发出误报。例如,以下代码不再被该规则报告:
¥Now, the rule doesn’t report false-positives about ambient TypeScript declarations. For example, the following code is no longer reported by the rule:
declare var foo; -
¥Improve useEnumInitializers
该规则现在会在单个诊断信息中报告枚举中所有未初始化的成员。
¥The rule now reports all uninitialized members of an enum in a single diagnostic.
此外,现在会忽略环境枚举声明。这避免了在 TypeScript 声明文件中报告环境枚举声明。
¥Moreover, ambient enum declarations are now ignored. This avoids reporting ambient enum declarations in TypeScript declaration files.
declare enum Weather {Rainy,Sunny,} -
放宽 noBannedTypes 的限制并改进文档。
¥Relax noBannedTypes and improve documentation
该规则不再将重用已禁用类型名称的用户类型报告为未使用。以下代码现在被允许:
¥The rule no longer reports a user type that reuses a banned type name. The following code is now allowed:
import { Number } from "a-lib";declare const v: Number;该规则现在允许使用类型
{}来表示不可为空的泛型类型:¥The rule now allows the use of the type
{}to denote a non-nullable generic type:function f<T extends {}>(x: T) {assert(x != null);}在类型交集处,为了将类型缩小到其不可为空的等效类型:
¥And in a type intersection for narrowing a type to its non-nullable equivalent type:
type NonNullableMyType = MyType & {}; -
¥Improve noConstantCondition
该规则现在允许使用
while(true)。此设置识别 Web 社区中的常见模式:¥The rule now allows
while(true). This recognizes a common pattern in the web community:while (true) {if (cond) {break;}} -
改进 useDefaultParameterLast 的诊断和代码操作。
¥Improve the diagnostic and the code action of useDefaultParameterLast.
诊断信息现在会报告最后一个必需参数,该参数应位于可选参数和默认参数之前。
¥The diagnostic now reports the last required parameter which should precede optional and default parameters.
此代码操作现在会移除参数名称与其初始化值之间的任何空格。
¥The code action now removes any whitespace between the parameter name and its initialization.
-
放宽
noConfusingArrow的限制¥Relax
noConfusingArrow所有用括号括起参数的箭头函数均被允许。因此,以下代码片段不再触发该规则:
¥All arrow functions that enclose its parameter with parenthesis are allowed. Thus, the following snippet no longer trigger the rule:
var x = (a) => 1 ? 2 : 3;以下代码片段仍然会触发此规则:
¥The following snippet still triggers the rule:
var x = a => 1 ? 2 : 3; -
放宽 useLiteralEnumMembers 的限制
¥Relax useLiteralEnumMembers
现在允许枚举成员引用先前的枚举成员。这允许枚举标志中使用常见模式,如下例所示:
¥Enum members that refer to previous enum members are now allowed. This allows a common pattern in enum flags like in the following example:
enum FileAccess {None = 0,Read = 1,Write = 1 << 1,All = Read | Write,}也允许使用任意数值常量表达式:
¥Arbitrary numeric constant expressions are also allowed:
enum FileAccess {None = 0,Read = 2**0,Write = 2**1,All = Read | Write,} -
改进 useLiteralKeys。
¥Improve useLiteralKeys.
现在,该规则建议将计算属性简化为字符串字面量属性:
¥Now, the rule suggests simplifying computed properties to string literal properties:
{["1+1"]: 2,"1+1": 2,}它还建议将字符串字面量属性简化为静态属性:
¥It also suggests simplifying string literal properties to static properties:
{"a": 0,a: 0,}这些建议适用于对象字面量、类、接口和对象类型。
¥These suggestions are made in object literals, classes, interfaces, and object types.
-
改进 noNewSymbol。
¥Improve noNewSymbol.
该规则现在可以处理
Symbol与全局命名空间globalThis或window一起使用的情况。¥The rule now handles cases where
Symbolis namespaced with the globalglobalThisorwindow. -
规则 useExhaustiveDependencies 和 useHookAtTopLevel 接受不同格式的选项。
¥The rules useExhaustiveDependencies and useHookAtTopLevel accept a different shape of options
旧配置:
¥Old configuration:
{"linter": {"rules": {"nursery": {"useExhaustiveDependencies": {"level": "error","options": {"hooks": [["useMyEffect", 0, 1]]}}}}}}新配置:
¥New configuration:
{"linter": {"rules": {"nursery": {"useExhaustiveDependencies": {"level": "error","options": {"hooks": [{"name": "useMyEffect","closureIndex": 0,"dependenciesIndex": 1}]}}}}}} -
noRedundantUseStrict 仅检查
'use strict'指令以解决误报诊断问题。¥noRedundantUseStrict check only
'use strict'directive to resolve false positive diagnostics.React 引入了新的指令 “使用客户端” 和 “使用服务器”。该规则会针对这些指令引发误报错误。
¥React introduced new directives, “use client” and “use server”. The rule raises false positive errors about these directives.
-
修复了当存在错误绑定时,NoParameterAssign 规则崩溃的问题。#4323
¥Fix a crash in the NoParameterAssign rule that occurred when there was a bogus binding. #4323
-
修复 useExhaustiveDependencies 在以下情况下的 #4330 问题:
¥Fix useExhaustiveDependencies in the following cases #4330:
-
当 hooks 的第一个参数是一个命名函数时
¥when the first argument of hooks is a named function
-
在 export default 函数内部
¥inside an export default function
-
针对
React.usehooks¥for
React.usehooks
-
-
修复 noInvalidConstructorSuper 错误地将泛型父级 #4624 报告为相等的问题。
¥Fix noInvalidConstructorSuper that erroneously reported generic parents #4624.
-
修复 noDuplicateCase 错误地将字符串字面量
"'"和'"'#4706 报告为相等的问题。¥Fix noDuplicateCase that erroneously reported as equals the strings literals
"'"and'"'#4706. -
修复 NoUnreachableSuper 的误报诊断 (#4483),该误报是由嵌套的 if 语句引起的。
¥Fix NoUnreachableSuper’s false positive diagnostics (#4483) caused to nested if statement.
该规则不再将构造函数中使用嵌套 if 语句时出现的
This constructor calls super() in a loop报告为未使用。¥The rule no longer reports
This constructor calls super() in a loopwhen using nested if statements in a constructor. -
修复 useHookAtTopLevel 的误报诊断 (#4637)
¥Fix useHookAtTopLevel’s false positive diagnostics (#4637)
该规则不再将直接从钩子访问属性以及在函数参数中调用钩子时出现的误报报告为未使用。
¥The rule no longer reports false positive diagnostics when accessing properties directly from a hook and calling a hook inside function arguments.
-
修复 noUselessConstructor 错误地报告了带有默认参数的构造函数的问题。
¥Fix noUselessConstructor which erroneously reported constructors with default parameters rome#4781
-
修复 noUselessFragments 在运行
biome check --apply-unsafe(#4637) 时发生的 panic。¥Fix noUselessFragments’s panics when running
biome check --apply-unsafe(#4637)此规则的代码操作会生成无效的抽象语法树 (AST),因此我已使用 JsxString 而不是 JsStringLiteral 修复了此问题。
¥This rule’s code action emits an invalid AST, so I fixed using JsxString instead of JsStringLiteral
-
修复 noUndeclaredVariables 的误报诊断 (#4675)
¥Fix noUndeclaredVariables’s false positive diagnostics (#4675)
语义分析器不再处理
this引用标识符。¥The semantic analyzer no longer handles
thisreference identifier. -
修复 noUnusedVariables 的误报诊断 (#4688)
¥Fix noUnusedVariables’s false positive diagnostics (#4688)
语义分析器能够正确处理 TypeScript 的导出声明子句。
¥The semantic analyzer handles ts export declaration clause correctly.
¥Parser
-
添加对类方法参数中装饰器的支持,例如:
¥Add support for decorators in class method parameters, example:
class AppController {get(@Param() id) {}// ^^^^^^^^ new supported syntax}此语法仅通过配置支持,因为它是一种非标准语法。
¥This syntax is only supported via configuration, because it’s a non-standard syntax.
{"javascript": {"parser": {"unsafeParameterDecoratorsEnabled": true}}} -
新增对解析 JSON 文件中注释的支持:
¥Add support for parsing comments inside JSON files:
{"json": {"parser": {"allowComments": true}}} -
新增对新的
using语法的支持:¥Add support for the new
usingsyntaxconst using = resource.lock();
Biome v2.1 中文网 - 粤ICP备13048890号