# prefer-bigint-literals

Rule `unicorn/prefer-bigint-literals`. Prefer `BigInt` literals over the constructor.

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

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `unicorn/prefer-bigint-literals` | no | safe | package `eslint-plugin-unicorn` | [docs](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v80.0.0/docs/rules/prefer-bigint-literals.md) |
| Oxlint | `unicorn/prefer-bigint-literals` | no | safe | plugin `unicorn`, category style | [docs](https://oxc.rs/docs/guide/usage/linter/rules/unicorn/prefer-bigint-literals.html) |
| Biome | `nursery/useBigintLiterals` | yes | safe | group nursery, since 2.6.0 | [docs](https://biomejs.dev/linter/rules/use-bigint-literals/) |

## Code examples

### Incorrect: the rule reports this

```js
const bigint = BigInt(1);
```

```js
const large = BigInt('9007199254740991');
```

```js
const hex = BigInt('0xFF');
```

### Correct: the rule accepts this

```js
const bigint = 1n;
```

```js
const large = 9007199254740991n;
```

```js
const hex = 0xFFn;
```

Examples from the ESLint documentation.

## Enable it

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

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

export default [
  {
    plugins: { unicorn },
    rules: {
      "unicorn/prefer-bigint-literals": "error",
    },
  },
];
```

### Oxlint: `.oxlintrc.json`

```json
{
  "rules": {
    "unicorn/prefer-bigint-literals": "error"
  }
}
```

### Biome: `biome.json`

```json
{
  "linter": {
    "rules": {
      "nursery": {
        "useBigintLiterals": "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% |
| [Unicorn recommended](https://lintradar.dev/presets/unicorn-recommended.md) | ESLint | `eslint-plugin-unicorn` | 340 | 9.5M | +30.3% |
| [Unicorn unopinionated](https://lintradar.dev/presets/unicorn-unopinionated.md) | ESLint | `eslint-plugin-unicorn` | 236 | 9.5M | +30.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% |

## Related rules

- [unicorn/prefer-array-index-of](https://lintradar.dev/rules/unicorn/prefer-array-index-of.md): Prefer `Array#{indexOf,lastIndexOf}()` over `Array#{findIndex,findLastIndex}()` when looking for the index of an item.
- [unicorn/prefer-date-now](https://lintradar.dev/rules/unicorn/prefer-date-now.md): Prefer `Date.now()` to get the number of milliseconds since the Unix Epoch.
- [unicorn/prefer-array-flat-map](https://lintradar.dev/rules/unicorn/prefer-array-flat-map.md): Prefer `.flatMap(…)` over `.map(…).flat()` and `.filter(…).flatMap(…)`.
- [unicorn/prefer-math-min-max](https://lintradar.dev/rules/unicorn/prefer-math-min-max.md): Prefer `Math.min()` and `Math.max()` over ternaries for simple comparisons.
- [unicorn/no-useless-switch-case](https://lintradar.dev/rules/unicorn/no-useless-switch-case.md): Disallow useless case in switch statements.
- [unicorn/prefer-math-trunc](https://lintradar.dev/rules/unicorn/prefer-math-trunc.md): Prefer `Math.trunc()` for truncating numbers.

---

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