oxc-project/oxc · error · OxcDiagnostic
Number method .toFixed() should have an argument
Error message
Number method .toFixed() should have an argument
What it means
Emitted by the unicorn/require-number-to-fixed-digits-argument rule at a `Number#toFixed()` call with zero arguments. It fires because omitting the argument silently relies on the default of 0 fractional digits; the rule requires the digits argument to be written explicitly for clarity.
Source
Thrown at crates/oxc_linter/src/rules/unicorn/require_number_to_fixed_digits_argument.rs:9
use oxc_ast::{AstKind, ast::Expression};
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::{GetSpan, Span};
use crate::{AstNode, context::LintContext, rule::Rule};
fn require_number_to_fixed_digits_argument_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Number method .toFixed() should have an argument")
.with_help("It's better to make it clear what the value of the digits argument is when calling Number#toFixed(), instead of relying on the default value of 0.")
.with_label(span)
}
#[derive(Debug, Default, Clone)]
pub struct RequireNumberToFixedDigitsArgument;
declare_oxc_lint!(
/// ### What it does
///
/// Enforce using the digits argument with `Number#toFixed()`.
///
/// ### Why is this bad?
///
/// It's better to make it clear what the value of the digits argument is when calling `Number#toFixed()`,
/// instead of relying on the default value of `0`.
///
/// ### ExamplesView on GitHub (pinned to e1e7af627c)
Solutions
- Pass the digits argument explicitly, e.g. `value.toFixed(0)` or `value.toFixed(2)`
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/oxc_linter/src/rules/unicorn/require_number_to_fixed_digits_argument.rs:9 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20).
Data as JSON: /api/errors/b8c5670d196373c9.
Report an issue: GitHub.