diff --git a/lib/.eslintrc.yaml b/lib/.eslintrc.yaml index 29099193bb089e..35ced9e9011016 100644 --- a/lib/.eslintrc.yaml +++ b/lib/.eslintrc.yaml @@ -71,6 +71,8 @@ rules: message: "Use `const { WeakMap } = primordials;` instead of the global." - name: WeakSet message: "Use `const { WeakSet } = primordials;` instead of the global." + - name: parseFloat + message: "Use `const { NumberParseFloat } = primordials;` instead of the global." - name: parseInt message: "Use `const { NumberParseInt } = primordials;` instead of the global." no-restricted-syntax: diff --git a/lib/internal/util/inspect.js b/lib/internal/util/inspect.js index b5b2b8ce4f234a..7f75325e863128 100644 --- a/lib/internal/util/inspect.js +++ b/lib/internal/util/inspect.js @@ -29,6 +29,7 @@ const { MathSqrt, Number, NumberIsNaN, + NumberParseFloat, NumberParseInt, NumberPrototypeValueOf, Object, @@ -1960,7 +1961,8 @@ function formatWithOptionsInternal(inspectOptions, ...args) { if (typeof tempFloat === 'symbol') { tempStr = 'NaN'; } else { - tempStr = formatNumber(stylizeNoColor, parseFloat(tempFloat)); + tempStr = formatNumber(stylizeNoColor, + NumberParseFloat(tempFloat)); } break; case 99: // 'c' diff --git a/lib/repl.js b/lib/repl.js index 773d2f64c43f05..adb20c653199ea 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -46,6 +46,7 @@ const { Error, MathMax, NumberIsNaN, + NumberParseFloat, ObjectAssign, ObjectCreate, ObjectDefineProperty, @@ -58,7 +59,9 @@ const { PromiseRace, RegExp, Set, + StringPrototypeCharAt, StringPrototypeIncludes, + StringPrototypeMatch, Symbol, SyntaxError, SyntaxErrorPrototype, @@ -791,9 +794,10 @@ function REPLServer(prompt, // Check to see if a REPL keyword was used. If it returns true, // display next prompt and return. if (trimmedCmd) { - if (trimmedCmd.charAt(0) === '.' && trimmedCmd.charAt(1) !== '.' && - NumberIsNaN(parseFloat(trimmedCmd))) { - const matches = trimmedCmd.match(/^\.([^\s]+)\s*(.*)$/); + if (StringPrototypeCharAt(trimmedCmd, 0) === '.' && + StringPrototypeCharAt(trimmedCmd, 1) !== '.' && + NumberIsNaN(NumberParseFloat(trimmedCmd))) { + const matches = StringPrototypeMatch(trimmedCmd, /^\.([^\s]+)\s*(.*)$/); const keyword = matches && matches[1]; const rest = matches && matches[2]; if (_parseREPLKeyword.call(self, keyword, rest) === true) {