2 title: prefer-numeric-literals
8 The `parseInt()` and `Number.parseInt()` functions can be used to turn binary, octal, and hexadecimal strings into integers. As binary, octal, and hexadecimal literals are supported in ES6, this rule encourages use of those numeric literals instead of `parseInt()` or `Number.parseInt()`.
17 This rule disallows calls to `parseInt()` or `Number.parseInt()` if called with two arguments: a string; and a radix option of 2 (binary), 8 (octal), or 16 (hexadecimal).
19 Examples of **incorrect** code for this rule:
24 /*eslint prefer-numeric-literals: "error"*/
26 parseInt("111110111", 2) === 503;
27 parseInt(`111110111`, 2) === 503;
28 parseInt("767", 8) === 503;
29 parseInt("1F7", 16) === 503;
30 Number.parseInt("111110111", 2) === 503;
31 Number.parseInt("767", 8) === 503;
32 Number.parseInt("1F7", 16) === 503;
37 Examples of **correct** code for this rule:
42 /*eslint prefer-numeric-literals: "error"*/
48 Number.parseInt(1, 3);
59 Number.parseInt(foo, 2);
66 If you want to allow use of `parseInt()` or `Number.parseInt()` for binary, octal, or hexadecimal integers, or if you are not using ES6 (because binary and octal literals are not supported in ES5 and below), you may wish to disable this rule.
70 * **JSCS**: [requireNumericLiterals](https://jscs-dev.github.io/rule/requireNumericLiterals)