close

require-number-to-fixed-digits-argument

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