Skip to content

unicorn/number-literal-case Style

🛠️ An auto-fix is available for this rule.

What it does

This rule enforces proper case for numeric literals.

Why is this bad?

When both an identifier and a number literal are in lower case, it can be hard to differentiate between them.

Examples

Examples of incorrect code for this rule:

javascript
const foo = 0xff;
const foo = 0xff;
const foo = 0xff;
const foo = 0xffn;

const foo = 0b10;
const foo = 0b10n;

const foo = 0o76;
const foo = 0o76n;

const foo = 2e-5;

Examples of correct code for this rule:

javascript
const foo = 0xff;
const foo = 0b10;
const foo = 0o76;
const foo = 0xffn;
const foo = 2e5;

References

Released under the MIT License.