parseInt or parseFloat is called through the global scope instead of Number

tx0/ts:global-number-functionstrictwarningstyle

What it finds

parseInt and parseFloat are also available as Number.parseInt and Number.parseFloat, which group them with the other number functions instead of the global scope. They are the same functions.

Reported are calls of the global parseInt and parseFloat. The fix, which is safe since the functions are identical, writes the Number. form. isNaN and isFinite differ from their Number. counterparts, which do not convert their argument, and are left alone.

From the rule's source, global_number_function.rs.

Example from the rule's tests
export const a = parseInt("10", 10);tx0 reports: parseInt is also Number.parseIntexport const b = Number.parseFloat("1.5");export const c = isNaN(a);
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/ts:global-number-function" = "warning"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/ts:global-number-function] reason="..."

tx0 explain tx0/ts:global-number-function shows the same in the terminal. Found a false positive? Report it.