Skip to content

noOctal (JavaScript)

Language JavaScript (and super languages)
biome.json
{
"linter": {
"rules": {
"nursery": {
"noOctal": "error"
}
}
}
}

Disallow numbers written with an extra leading zero.

A leading zero can make a number use base 8 instead of base 10. For example, 071 represents the decimal value 57. This notation is deprecated and forbidden in strict mode. Use the explicit 0o prefix for octal numbers.

This rule also reports decimal numbers with leading zeros, such as 08 and 09.1, because their notation can be confused with octal numbers. Strings and octal numbers with the 0o or 0O prefix are allowed.

const number = 071;
code-block.cjs:1:16 lint/nursery/noOctal ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

⚠ Don't use number literals with leading zeros.

> 1 │ const number = 071;
│ ^^^
2 │

ℹ A leading zero can make a number use base 8 instead of base 10, and is forbidden in strict mode.

ℹ Use the 0o prefix for octal numbers, or remove leading zeros from decimal numbers.

ℹ 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.

const number = 08;
code-block.cjs:1:16 lint/nursery/noOctal ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

⚠ Don't use number literals with leading zeros.

> 1 │ const number = 08;
│ ^^
2 │

ℹ A leading zero can make a number use base 8 instead of base 10, and is forbidden in strict mode.

ℹ Use the 0o prefix for octal numbers, or remove leading zeros from decimal numbers.

ℹ 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.

const octal = 0o71;
const decimal = 57;
const text = "071";