useConsistentUnicodeBom (HTML)
Summary
Section titled “Summary”- Rule available since:
v2.6.3 - Diagnostic Category:
lint/nursery/useConsistentUnicodeBom - This rule has a safe fix.
- The default severity of this rule is information.
- Sources:
- Same as
unicode-bom
- Same as
How to configure
Section titled “How to configure”{ "linter": { "rules": { "nursery": { "useConsistentUnicodeBom": "error" } } }}Description
Section titled “Description”Require or disallow a Unicode byte order mark at the beginning of a file.
A byte order mark (BOM) is the invisible U+FEFF character at the start of a file.
UTF-8 does not need a BOM, so this rule disallows it by default.
Set bom to "always" if your tools require one.
U+FEFF characters elsewhere in the file are not checked by this rule.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”The following example starts with an invisible U+FEFF character.
<div>text</div>code-block.html:1:1 lint/nursery/useConsistentUnicodeBom FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ This file starts with a Unicode byte order mark (BOM).
> 1 │ <div>text</div>
│ ^
2 │
ℹ UTF-8 does not require a byte order mark.
ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.
ℹ Safe fix: Remove the Unicode byte order mark.
1 │ <div>text</div>
│ -
<div>text</div>Options
Section titled “Options”Type: "always" | "never"
Default: "never"
Whether files must start with a BOM.
Use "always" to require a BOM, including in empty files.
{ "linter": { "rules": { "nursery": { "useConsistentUnicodeBom": { "level": "on", "options": { "bom": "always" } } } } }}Invalid
Section titled “Invalid”<div>text</div>code-block.html:1:1 lint/nursery/useConsistentUnicodeBom FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ This file is missing a Unicode byte order mark (BOM).
> 1 │ <div>text</div>
│
2 │
ℹ The configured BOM policy requires files to start with U+FEFF.
ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.
ℹ Safe fix: Insert a Unicode byte order mark.
1 │ <div>text</div>
│ +
The following example starts with an invisible U+FEFF character.
<div>text</div>Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.