# number-literal-case

Rule `unicorn/number-literal-case`. Enforce proper case for numeric literals.

- Source: unicorn
- Technologies: JavaScript
- Kind: style
- Needs type information: no
- Autofix: yes, in at least one linter
- Reach: 10.7M weekly downloads of presets that enable it
- Trend: +29.6% last quarter
- Rank: #868 by reach, #1145 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `unicorn/number-literal-case` | no | safe | package `eslint-plugin-unicorn` | [docs](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v80.0.0/docs/rules/number-literal-case.md) |
| Oxlint | `unicorn/number-literal-case` | no | safe | plugin `unicorn`, category style | [docs](https://oxc.rs/docs/guide/usage/linter/rules/unicorn/number-literal-case.html) |

## Code examples

### Incorrect: the rule reports this

```js
const foo = 0XFF;
```

```js
const foo = 0xff;
```

```js
const foo = 0Xff;
```

### Correct: the rule accepts this

```js
const foo = 0xFF;
```

```js
const foo = 0xFFn;
```

```js
const foo = 0b10;
```

Examples from the ESLint documentation.

## Enable it

### ESLint: `eslint.config.js`

```js
import unicorn from "eslint-plugin-unicorn";

export default [
  {
    plugins: { unicorn },
    rules: {
      "unicorn/number-literal-case": "error",
    },
  },
];
```

### Oxlint: `.oxlintrc.json`

```json
{
  "rules": {
    "unicorn/number-literal-case": "error"
  }
}
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [Unicorn recommended](https://lintradar.dev/presets/unicorn-recommended.md) | ESLint | `eslint-plugin-unicorn` | 340 | 9.5M | +30.3% |
| [Anthony Fu's config](https://lintradar.dev/presets/antfu.md) | ESLint | `@antfu/eslint-config` | 294 | 758.7K | +49.9% |
| [XO](https://lintradar.dev/presets/xo.md) | ESLint | `eslint-config-xo` | 618 | 413K | −5.0% |

## Related rules

- [unicorn/consistent-function-scoping](https://lintradar.dev/rules/unicorn/consistent-function-scoping.md): Move function definitions to the highest possible scope.
- [unicorn/import-style](https://lintradar.dev/rules/unicorn/import-style.md): Enforce specific import styles per module.
- [unicorn/no-useless-undefined](https://lintradar.dev/rules/unicorn/no-useless-undefined.md): Disallow useless `undefined`.
- [unicorn/no-process-exit](https://lintradar.dev/rules/unicorn/no-process-exit.md): Disallow `process.exit()`.
- [unicorn/prefer-global-this](https://lintradar.dev/rules/unicorn/prefer-global-this.md): Prefer `globalThis` over `window`, `self`, and `global`.
- [unicorn/no-useless-iterator-to-array](https://lintradar.dev/rules/unicorn/no-useless-iterator-to-array.md): Disallow unnecessary `.toArray()` on iterators.

---

Web page: https://lintradar.dev/rules/unicorn/number-literal-case. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
