noOctal (JavaScript)
Language JavaScript (and super languages)
Summary
Section titled “Summary”- Rule available since:
v2.6.0 - Diagnostic Category:
lint/nursery/noOctal - This rule doesn’t have a fix.
- The default severity of this rule is warning.
- Sources:
How to configure
Section titled “How to configure”{ "linter": { "rules": { "nursery": { "noOctal": "error" } } }}Description
Section titled “Description”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.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”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";Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.