prefer-numeric-literals-over-parseint-radix
Replaces parseInt() and Number.parseInt() calls that parse static base-2, base-8, or base-16 strings with equivalent 0b, 0o, and 0x numeric literals when the result is semantically safe.
What It Rewrites
js
Safety Rules
- Only rewrites calls with exactly 2 arguments.
- Only rewrites string literals or template literals with no expressions.
- Only rewrites radix literals that evaluate to
2,8, or16. - Requires the trimmed payload to be entirely valid digits for that radix.
- Preserves hex digit casing from the source string.
- Skips shadowed
parseIntbindings and shadowedNumber.parseIntreceivers. - Skips partial parses, prefixed payloads like
"0xFF", and negative-zero inputs such as"-0".
Target Files
*.js,*.cjs,*.mjs*.ts,*.cts,*.mts*.jsx,*.tsx
Usage
bash
Development
bash
License
MIT