Skip to content

Enforce proper case for numeric literals ​

💼 This rule is enabled in the ✅ recommended config.

🔧 This rule is automatically fixable by the --fix CLI option.

Differentiating the casing of the identifier and value clearly separates them and makes your code more readable.

  • Lowercase identifier and uppercase value for Number and BigInt.
  • Lowercase e for exponential notation.

Fail ​

Hexadecimal

js
const foo = 0XFF;
const foo = 0xff;
const foo = 0Xff;
const foo = 0Xffn;

Binary

js
const foo = 0B10;
const foo = 0B10n;

Octal

js
const foo = 0O76;
const foo = 0O76n;

Exponential notation

js
const foo = 2E-5;

Pass ​

js
const foo = 0xFF;
js
const foo = 0b10;
js
const foo = 0o76;
js
const foo = 0xFFn;
js
const foo = 2e+5;

Released under the Apache License 2.0.