Skip to content

Latest commit

 

History

History
61 lines (43 loc) · 1.14 KB

number-literal-case.md

File metadata and controls

61 lines (43 loc) · 1.14 KB

Enforce proper case for numeric literals

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.

This rule is fixable.

Fail

Hexadecimal

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

Binary

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

Octal

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

Exponential notation

const foo = 2E-5;

Pass

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