Skip to content

useConsistentUnicodeBom (JSON)

biome.json
{
"linter": {
"rules": {
"nursery": {
"useConsistentUnicodeBom": "error"
}
}
}
}

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. Embedded JSON is checked through the containing file.

The following example starts with an invisible U+FEFF character.

{"value": 1}
code-block.json:1:1 lint/nursery/useConsistentUnicodeBom  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

ℹ This file starts with a Unicode byte order mark (BOM).

> 1 │ {"value": 1}
│ ^
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 │ {"value":·1}
│ -
{"value": 1}

Type: "always" | "never"

Default: "never"

Whether files must start with a BOM. Use "always" to require a BOM, including in empty files.

biome.json
{
"linter": {
"rules": {
"nursery": {
"useConsistentUnicodeBom": {
"level": "on",
"options": {
"bom": "always"
}
}
}
}
}
}
{"value": 1}
code-block.json:1:1 lint/nursery/useConsistentUnicodeBom  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

ℹ This file is missing a Unicode byte order mark (BOM).

> 1 │ {"value": 1}
│
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 │ {"value":·1}
│ +

The following example starts with an invisible U+FEFF character.

{"value": 1}