JSLint says "missing radix parameter"
It always a good practice to pass radix with parseInt -
parseInt(string, radix)
For decimal -
parseInt(id.substring(id.length - 1), 10)
If the radix parameter is omitted, JavaScript assumes the following:
- If the string begins with "0x", the radix is 16 (hexadecimal)
- If the string begins with "0", the radix is 8 (octal). This feature is deprecated
- If the string begins with any other value, the radix is 10 (decimal)
(Reference)
To avoid this warning, instead of using:
parseInt("999", 10);
You may replace it by:
Number("999");
Note that parseInt and Number have different behaviors, but in some cases, one can replace the other.
I'm not properly answering the question but, I think it makes sense to clear why we should specify the radix.
On MDN documentation we can read that:
If radix is undefined or 0 (or absent), JavaScript assumes the following:
- [...]
- If the input string begins with "0", radix is eight (octal) or 10 (decimal). Exactly which radix is chosen is implementation-dependent. ECMAScript 5 specifies that 10 (decimal) is used, but not all browsers support this yet. For this reason always specify a radix when using parseInt.
- [...]
Source: MDN parseInt()
You can turn off this rule if you wish to skip that test.
Insert:
radix: false
Under the "rules
" property in the tslint.json
file.
It's not recommended to do that if you don't understand this exception.