Disallow Octal Literals (no-octal)

Octal literals are numerals that begin with a leading zero, such as:

var num = 071;      // 57

The leading zero to identify an octal literal has been a source of confusion and error in JavaScript. ECMAScript 5 deprecates the use of octal numeric literals in JavaScript and octal literals cause syntax errors in strict mode.

It’s therefore recommended to avoid using octal literals in JavaScript code.

Rule Details

The rule is aimed at preventing the use of a deprecated JavaScript feature, the use of octal literals. As such it will warn whenever an octal literal is found.

The following patterns are considered warnings:

var num = 071;
var result = 5 + 07;

The following patterns are not considered warnings:

var num  = "071";


Further Reading


This rule was introduced in ESLint 0.0.6.