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/no-zero-fractions.md.
close

no-zero-fractions

Added in v0.9.3

Configuration

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

export default defineConfig([
  unicornPlugin.configs.recommended,
  {
    rules: {
      'unicorn/no-zero-fractions': 'error',
    },
  },
]);

Rule Details

Remove trailing zero fractions and dangling decimal points from numeric literals. For example, 1.0 becomes 1, 1.010 becomes 1.01, and 1. becomes 1. Numeric separators and exponent spelling are preserved outside the removed fraction.

The rule provides an automatic fix. It preserves required parentheses, keyword spacing, and statement boundaries when changing a numeric member receiver.

Examples of incorrect code:

const value = 123_456.000_000;
const scale = 123.00e20;
const text = 1.00.toString();

Examples of correct code:

const value = 123_456;
const scale = 123e20;
const text = (1).toString();

Options

This rule has no options.

Original Documentation