For AI agents: the complete documentation index is available at https://rslint.rs/llms.txt, the full documentation bundle is available at https://rslint.rs/llms-full.txt, and this page is available as Markdown at https://rslint.rs/rules/unicorn/require-number-to-fixed-digits-argument.md.
close

require-number-to-fixed-digits-argument

Added in v0.7.0

Configuration

PresetConfigured Value
✅ unicornPlugin.configs.recommended"error"
rslint.config.ts
import { defineConfig, unicornPlugin } from '@rslint/core';

export default defineConfig([
  unicornPlugin.configs.recommended,
  {
    rules: {
      'unicorn/require-number-to-fixed-digits-argument': 'error',
    },
  },
]);

Rule Details

Requires calls to Number#toFixed() to explicitly pass the number of fraction digits. Writing the argument makes the intended formatting clear instead of relying on the default value of 0.

Examples of incorrect code for this rule:

const value = number.toFixed();

Examples of correct code for this rule:

const integer = number.toFixed(0);
const decimal = number.toFixed(2);

Original Documentation