Skip to content

no-octal

JavaScript / TypeScriptsuspiciousno fixdefault: errorjs/eslint-recommended

Reports a number literal that starts with 0 followed by another digit, such as 017 or 08. 0, 0.5 and the modern forms 0o17, 0x1F and 0b11 are not reported.

A leading zero makes a legacy octal literal: 017 is 15, not 17. A literal such as 08 or 09 has a digit that is not octal, so it is read as the decimal 8 or 9, which hides the mistake. Both forms are syntax errors in strict mode and in modules.

To fix, drop the leading zero for a decimal number or write 0o17 for an octal one.

Reported
...
var i = 017, j = 08, k = 0, l = 0.5, m = 0o17;
...
js:
lint:
rules:
no-octal: error # off, warn, error (default)

Enabled by the presets: js/eslint-recommended.

Suppress one line with sudsy-disable-next-line no-octal in a comment of the file’s language.

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
eslint no-octal full