{"record":{"id":"b8c5670d196373c9","repo":"oxc-project/oxc","slug":"number-method-tofixed-should-have-an-argument","errorCode":null,"errorMessage":"Number method .toFixed() should have an argument","messagePattern":"Number method \\.toFixed\\(\\) should have an argument","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/unicorn/require_number_to_fixed_digits_argument.rs","lineNumber":9,"sourceCode":"use oxc_ast::{AstKind, ast::Expression};\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::{GetSpan, Span};\n\nuse crate::{AstNode, context::LintContext, rule::Rule};\n\nfn require_number_to_fixed_digits_argument_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Number method .toFixed() should have an argument\")\n        .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.\")\n        .with_label(span)\n}\n\n#[derive(Debug, Default, Clone)]\npub struct RequireNumberToFixedDigitsArgument;\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///\n    /// Enforce using the digits argument with `Number#toFixed()`.\n    ///\n    /// ### Why is this bad?\n    ///\n    /// It's better to make it clear what the value of the digits argument is when calling `Number#toFixed()`,\n    /// instead of relying on the default value of `0`.\n    ///\n    /// ### Examples","sourceCodeStart":1,"sourceCodeEnd":27,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/unicorn/require_number_to_fixed_digits_argument.rs#L1-L27","documentation":"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.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/unicorn/require_number_to_fixed_digits_argument.rs:9 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass the digits argument explicitly, e.g. `value.toFixed(0)` or `value.toFixed(2)`"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e1e7af627c8843ab64044ed466b128fcc21a035b","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}