{"record":{"id":"4c4a3dcfae6c6e74","repo":"oxc-project/oxc","slug":"invalid-radix-parameter-must-be-an-integer-betwee","errorCode":null,"errorMessage":"Invalid radix parameter, must be an integer between 2 and 36.","messagePattern":"Invalid radix parameter, must be an integer between 2 and 36\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"warning","filePath":"crates/oxc_linter/src/rules/eslint/radix.rs","lineNumber":26,"sourceCode":"use schemars::JsonSchema;\nuse serde::{Deserialize, Serialize};\n\nuse crate::{AstNode, context::LintContext, rule::Rule};\n\nfn missing_parameters(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Missing parameters.\")\n        .with_help(\"Add parameters for parsing numbers, e.g., `parseInt('10', 10)`.\")\n        .with_label(span)\n}\n\nfn missing_radix(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Missing radix parameter.\")\n        .with_help(\"Add radix parameter `10` for parsing decimal numbers, or specify the appropriate radix for other number formats.\")\n        .with_label(span)\n}\n\nfn invalid_radix(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Invalid radix parameter, must be an integer between 2 and 36.\")\n        .with_help(\"The radix parameter should be an integer between 2 and 36, or a variable that is not `undefined`.\")\n        .with_label(span)\n}\n\n// `RadixType` has no effect, it is only here for backward compatibility.\n// Without it, the linter will report unknown rule configuration error.\n#[derive(Debug, Default, Clone, JsonSchema, Deserialize, Serialize)]\n#[serde(rename_all = \"camelCase\", default, deny_unknown_fields)]\npub struct Radix(RadixType);\n\n#[derive(Debug, Default, Clone, JsonSchema, Deserialize, Serialize)]\n#[serde(rename_all = \"kebab-case\")]\nenum RadixType {\n    /// Always require the radix parameter when using `parseInt()`.\n    #[default]\n    Always,\n    /// Only require the radix parameter when necessary.\n    AsNeeded,","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/eslint/radix.rs#L8-L44","documentation":"oxlint `eslint/radix`: a radix argument was supplied but its static value cannot be a valid base — the message (radix.rs:26) states it must be an integer between 2 and 36, or a variable that is not `undefined`. Such a call makes `parseInt` return `NaN`, so the rule flags it as a likely typo.","triggerScenarios":"`parseInt(\"11\", 1)`, `parseInt(\"11\", 37)`, `parseInt(\"11\", 2.5)`, `parseInt(\"11\", undefined)` — a second argument whose literal value is outside 2–36, non-integral, or explicitly `undefined`.","commonSituations":"Off-by-one base mistakes (1 for binary instead of 2); passing a constant that was refactored to a bad value; passing `undefined` through from an optional parameter.","solutions":["Correct the radix to an integer in 2–36: binary 2, octal 8, decimal 10, hex 16.","If the radix comes from a variable, make sure it is always a valid integer at runtime; the rule only accepts variables it cannot prove invalid.","Remove an explicit `undefined` second argument — it triggers the same diagnostic."],"exampleFix":"// before\nconst bits = parseInt(bitString, 1);\n\n// after\nconst bits = parseInt(bitString, 2);","handlingStrategy":"validation","validationCode":"// runtime guard if the radix is variable\nfunction safeParseInt(s, radix) {\n  if (!Number.isInteger(radix) || radix < 2 || radix > 36) {\n    throw new RangeError(`Invalid radix ${radix}; must be integer 2-36`);\n  }\n  return parseInt(s, radix);\n}","typeGuard":"function isValidRadix(r) {\n  return Number.isInteger(r) && r >= 2 && r <= 36;\n}","tryCatchPattern":null,"preventionTips":["Define radix as named constants (BIN=2, OCT=8, DEC=10, HEX=16) so typos like 1 are obvious.","Validate variable radices at the boundary with the guard above.","Never pass an explicit `undefined` second argument."],"tags":["eslint","oxlint","parseint","radix","correctness","lint"],"backgroundTag":"parseint-radix","analyzedSha":"e1e7af627c8843ab64044ed466b128fcc21a035b","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}