# prefer-numeric-literals

Rule `eslint/prefer-numeric-literals`. Disallow `parseInt()` and `Number.parseInt()` in favor of binary, octal, and hexadecimal literals

- Source: eslint
- Technologies: JavaScript
- Kind: style
- Needs type information: no
- Autofix: yes, in at least one linter
- Reach: 41.1M weekly downloads of presets that enable it
- Trend: +65.1% last quarter
- Rank: #413 by reach, #458 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `prefer-numeric-literals` | no | safe | package `eslint` | [docs](https://eslint.org/docs/latest/rules/prefer-numeric-literals) |
| Oxlint | `prefer-numeric-literals` | no | safe | plugin `eslint`, category style | [docs](https://oxc.rs/docs/guide/usage/linter/rules/eslint/prefer-numeric-literals.html) |
| Biome | `complexity/useNumericLiterals` | yes | safe | group complexity, since 1.0.0 | [docs](https://biomejs.dev/linter/rules/use-numeric-literals/) |

## Code examples

### Incorrect: the rule reports this

```js
parseInt("111110111", 2) === 503;
parseInt(`111110111`, 2) === 503;
parseInt("767", 8) === 503;
parseInt("1F7", 16) === 503;
Number.parseInt("111110111", 2) === 503;
Number.parseInt("767", 8) === 503;
Number.parseInt("1F7", 16) === 503;
```

### Correct: the rule accepts this

```js
parseInt(1);
parseInt(1, 3);
Number.parseInt(1);
Number.parseInt(1, 3);

0b111110111 === 503;
0o767 === 503;
0x1F7 === 503;

a[parseInt](1,2);

parseInt(foo);
parseInt(foo, 2);
Number.parseInt(foo);
Number.parseInt(foo, 2);
```

Examples from the ESLint documentation.

## Enable it

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

```js
export default [
  {
    rules: {
      "prefer-numeric-literals": "error",
    },
  },
];
```

### Oxlint: `.oxlintrc.json`

```json
{
  "rules": {
    "prefer-numeric-literals": "error"
  }
}
```

### Biome: `biome.json`

```json
{
  "linter": {
    "rules": {
      "complexity": {
        "useNumericLiterals": "error"
      }
    }
  }
}
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [Biome recommended](https://lintradar.dev/presets/biome-recommended.md) | Biome | `@biomejs/biome` | 491 | 28.5M | +106.8% |
| [Airbnb base](https://lintradar.dev/presets/airbnb-base.md) | ESLint | `eslint-config-airbnb-base` | 241 | 6.5M | +2.1% |
| [Airbnb](https://lintradar.dev/presets/airbnb.md) | ESLint | `eslint-config-airbnb` | 346 | 3.4M | +2.3% |
| [Ultracite for Biome](https://lintradar.dev/presets/ultracite-biome.md) | Biome | `ultracite` | 616 | 2.1M | +151.7% |
| [Ultracite for Oxlint](https://lintradar.dev/presets/ultracite-oxlint.md) | Oxlint | `ultracite` | 475 | 2.1M | +151.7% |
| [XO](https://lintradar.dev/presets/xo.md) | ESLint | `eslint-config-xo` | 618 | 413K | −5.0% |
| [eslint-config-love](https://lintradar.dev/presets/love.md) | ESLint | `eslint-config-love` | 258 | 171.7K | +39.3% |

## Related rules

- [eslint/no-constructor-return](https://lintradar.dev/rules/eslint/no-constructor-return.md): Disallow returning value from constructor
- [eslint/no-inner-declarations](https://lintradar.dev/rules/eslint/no-inner-declarations.md): Disallow variable or `function` declarations in nested blocks
- [eslint/prefer-template](https://lintradar.dev/rules/eslint/prefer-template.md): Require template literals instead of string concatenation
- [eslint/prefer-exponentiation-operator](https://lintradar.dev/rules/eslint/prefer-exponentiation-operator.md): Disallow the use of `Math.pow` in favor of the `**` operator
- [eslint/radix](https://lintradar.dev/rules/eslint/radix.md): Enforce the use of the radix argument when using `parseInt()`
- [eslint/no-useless-call](https://lintradar.dev/rules/eslint/no-useless-call.md): Disallow unnecessary calls to `.call()` and `.apply()`

---

Web page: https://lintradar.dev/rules/eslint/prefer-numeric-literals. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
