From e3b99db7668d26ad10bb3dce069a4f85673f2390 Mon Sep 17 00:00:00 2001 From: Denis Pushkarev Date: Sun, 31 Mar 2019 14:45:45 +0700 Subject: [PATCH] enable `eslint-plugin-unicorn` --- .eslintrc.js | 35 +++++++++++ Gruntfile.js | 5 +- package.json | 1 + .../core-js/es/number/max-safe-integer.js | 2 +- .../core-js/es/number/min-safe-integer.js | 2 +- packages/core-js/features/index.js | 2 +- .../internals/array-buffer-view-core.js | 2 +- packages/core-js/internals/array-buffer.js | 6 +- .../call-with-safe-iteration-closing.js | 4 +- .../check-correctness-of-iteration.js | 4 +- packages/core-js/internals/classof.js | 2 +- packages/core-js/internals/fails.js | 2 +- .../core-js/internals/flatten-into-array.js | 2 +- .../internals/forced-string-trim-method.js | 2 +- packages/core-js/internals/microtask.js | 4 +- .../internals/object-define-property.js | 2 +- .../object-get-own-property-descriptor.js | 2 +- .../object-get-own-property-names-external.js | 2 +- .../internals/object-set-prototype-of.js | 4 +- packages/core-js/internals/perform.js | 4 +- .../core-js/internals/punycode-to-ascii.js | 6 +- packages/core-js/internals/set-global.js | 2 +- .../core-js/internals/sloppy-array-method.js | 4 +- packages/core-js/internals/string-at.js | 6 +- packages/core-js/internals/to-length.js | 2 +- .../internals/typed-array-constructor.js | 2 +- .../internals/webkit-string-pad-bug.js | 5 ++ packages/core-js/internals/whitespaces.js | 2 +- packages/core-js/modules/es.array.concat.js | 2 +- packages/core-js/modules/es.array.splice.js | 2 +- packages/core-js/modules/es.function.name.js | 2 +- packages/core-js/modules/es.math.imul.js | 4 +- .../modules/es.number.is-safe-integer.js | 2 +- .../modules/es.number.max-safe-integer.js | 2 +- .../modules/es.number.min-safe-integer.js | 2 +- packages/core-js/modules/es.promise.js | 16 ++--- .../modules/es.reflect.define-property.js | 2 +- .../modules/es.reflect.prevent-extensions.js | 2 +- .../modules/es.reflect.set-prototype-of.js | 2 +- .../modules/es.string.from-code-point.js | 4 +- packages/core-js/modules/es.string.pad-end.js | 5 +- .../core-js/modules/es.string.pad-start.js | 5 +- packages/core-js/modules/es.string.split.js | 2 +- packages/core-js/modules/esnext.math.imulh.js | 2 +- packages/core-js/modules/esnext.math.umulh.js | 2 +- packages/core-js/modules/esnext.observable.js | 24 ++++---- .../modules/web.dom-collections.for-each.js | 2 +- .../modules/web.dom-collections.iterator.js | 4 +- packages/core-js/modules/web.url.js | 54 ++++++++--------- tests/commonjs.js | 26 ++++---- tests/compat/browsers-runner.js | 2 +- tests/compat/node-runner.js | 2 +- tests/compat/tests.js | 59 ++++++++++--------- tests/helpers/constants.js | 10 ++-- tests/helpers/helpers.js | 6 +- tests/helpers/qunit-helpers.js | 4 +- tests/pure/es.array.from.js | 2 +- tests/pure/es.map.js | 2 +- tests/pure/es.math.imul.js | 4 +- tests/pure/es.object.assign.js | 4 +- tests/pure/es.object.entries.js | 4 +- tests/pure/es.object.values.js | 4 +- tests/pure/es.promise.js | 4 +- tests/pure/es.set.js | 2 +- tests/pure/es.string.trim-end.js | 4 +- tests/pure/es.string.trim-start.js | 4 +- tests/pure/es.string.trim.js | 2 +- tests/pure/es.weak-map.js | 2 +- tests/pure/es.weak-set.js | 2 +- tests/pure/esnext.math.iaddh.js | 4 +- tests/pure/esnext.math.imulh.js | 4 +- tests/pure/esnext.math.isubh.js | 4 +- tests/pure/esnext.math.umulh.js | 4 +- tests/pure/esnext.promise.any.js | 12 ++-- tests/pure/web.timers.js | 20 +++---- tests/tests/es.array.from.js | 2 +- tests/tests/es.data-view.js | 16 ++--- tests/tests/es.map.js | 2 +- tests/tests/es.math.imul.js | 4 +- tests/tests/es.number.constructor.js | 2 +- tests/tests/es.object.assign.js | 4 +- tests/tests/es.object.entries.js | 4 +- tests/tests/es.object.values.js | 4 +- tests/tests/es.promise.js | 4 +- tests/tests/es.set.js | 2 +- tests/tests/es.string.match.js | 10 ++-- tests/tests/es.string.replace.js | 24 ++++---- tests/tests/es.string.search.js | 8 +-- tests/tests/es.string.split.js | 20 +++---- tests/tests/es.string.trim-end.js | 4 +- tests/tests/es.string.trim-start.js | 4 +- tests/tests/es.string.trim.js | 2 +- tests/tests/es.weak-map.js | 2 +- tests/tests/es.weak-set.js | 2 +- tests/tests/esnext.math.iaddh.js | 4 +- tests/tests/esnext.math.imulh.js | 4 +- tests/tests/esnext.math.isubh.js | 4 +- tests/tests/esnext.math.umulh.js | 4 +- tests/tests/esnext.promise.any.js | 12 ++-- tests/tests/web.timers.js | 6 +- tests/wpt-url-resources/urltestdata.js | 12 ++-- 101 files changed, 328 insertions(+), 295 deletions(-) create mode 100644 packages/core-js/internals/webkit-string-pad-bug.js diff --git a/.eslintrc.js b/.eslintrc.js index 6f6845994d5a..48ce924604e5 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -310,6 +310,36 @@ const base = { // require strict mode directives strict: ['error', 'global'], + + // unicorn + // enforce a specific parameter name in catch clauses + 'unicorn/catch-error-name': ['error', { name: 'error', caughtErrorsIgnorePattern: '^err' }], + // enforce passing a message value when throwing a built-in error + 'unicorn/error-message': 'error', + // require escape sequences to use uppercase values + 'unicorn/escape-case': 'error', + // enforce a case style for filenames + 'unicorn/filename-case': ['error', { case: 'kebabCase' }], + // enforce importing index files with `.` + 'unicorn/import-index': 'error', + // enforce specifying rules to disable in eslint-disable comments + 'unicorn/no-abusive-eslint-disable': 'error', + // do not use leading/trailing space between `console.log` parameters + 'unicorn/no-console-spaces': 'error', + // enforce the use of unicode escapes instead of hexadecimal escapes + 'unicorn/no-hex-escape': 'error', + // disallow unreadable array destructuring + 'unicorn/no-unreadable-array-destructuring': 'error', + // disallow unsafe regular expressions + 'unicorn/no-unsafe-regex': 'error', + // disallow unused object properties + 'unicorn/no-unused-properties': 'error', + // enforce lowercase identifier and uppercase value for number literals + 'unicorn/number-literal-case': 'error', + // prefer the exponentiation operator over `Math.pow()` + 'unicorn/prefer-exponentiation-operator': 'error', + // enforce the use of regex shorthands to improve readability + 'unicorn/regex-shorthand': 'error', }; const es3 = { @@ -333,6 +363,8 @@ const es3 = { 'quote-props': ['error', 'as-needed', { keywords: true }], // require strict mode directives strict: 'off', + // prefer the exponentiation operator over `Math.pow()` + 'unicorn/prefer-exponentiation-operator': 'off', }; const unit = { @@ -360,6 +392,8 @@ const unit = { 'no-unused-expressions': 'off', // disallow unnecessary calls to `.call()` and `.apply()` 'no-useless-call': 'off', + // enforce passing a message value when throwing a built-in error + 'unicorn/error-message': 'off', // qunit: // ensure the correct number of assert arguments is used @@ -427,6 +461,7 @@ module.exports = { plugins: [ 'import', 'qunit', + 'unicorn', ], settings: { 'import/resolver': { diff --git a/Gruntfile.js b/Gruntfile.js index 9f7a011cef1f..be71d2bdea0f 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,3 +1,4 @@ +/* eslint-disable unicorn/filename-case */ 'use strict'; const { banner } = require('./packages/core-js-builder/config'); @@ -159,9 +160,9 @@ module.exports = grunt => { const builder = require('./packages/core-js-builder'); const done = this.async(); - builder({ filename: './packages/core-js-bundle/index.js' }).then(done).catch(it => { + builder({ filename: './packages/core-js-bundle/index.js' }).then(done).catch(error => { // eslint-disable-next-line no-console - console.error(it); + console.error(error); process.exit(1); }); }); diff --git a/package.json b/package.json index 9a29b4324655..f9d27fcaa17f 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ "eslint-import-resolver-webpack": "^0.11.0", "eslint-plugin-import": "~2.16.0", "eslint-plugin-qunit": "^4.0.0", + "eslint-plugin-unicorn": "^8.0.1", "grunt": "^1.0.4", "grunt-cli": "^1.3.2", "grunt-contrib-clean": "^2.0.0", diff --git a/packages/core-js/es/number/max-safe-integer.js b/packages/core-js/es/number/max-safe-integer.js index 2ce59a6cd290..b901200ca06c 100644 --- a/packages/core-js/es/number/max-safe-integer.js +++ b/packages/core-js/es/number/max-safe-integer.js @@ -1,3 +1,3 @@ require('../../modules/es.number.max-safe-integer'); -module.exports = 0x1fffffffffffff; +module.exports = 0x1FFFFFFFFFFFFF; diff --git a/packages/core-js/es/number/min-safe-integer.js b/packages/core-js/es/number/min-safe-integer.js index 631187534ac2..3678895ab72e 100644 --- a/packages/core-js/es/number/min-safe-integer.js +++ b/packages/core-js/es/number/min-safe-integer.js @@ -1,3 +1,3 @@ require('../../modules/es.number.min-safe-integer'); -module.exports = -0x1fffffffffffff; +module.exports = -0x1FFFFFFFFFFFFF; diff --git a/packages/core-js/features/index.js b/packages/core-js/features/index.js index 4b2e02c0cc19..c259160ef58f 100644 --- a/packages/core-js/features/index.js +++ b/packages/core-js/features/index.js @@ -1 +1 @@ -module.exports = require('../'); +module.exports = require('..'); diff --git a/packages/core-js/internals/array-buffer-view-core.js b/packages/core-js/internals/array-buffer-view-core.js index 2ac9d4f93e36..ea86c2a3e758 100644 --- a/packages/core-js/internals/array-buffer-view-core.js +++ b/packages/core-js/internals/array-buffer-view-core.js @@ -93,7 +93,7 @@ var exportStatic = function (KEY, property, forced) { // V8 ~ Chrome 49-50 `%TypedArray%` methods are non-writable non-configurable try { return redefine(TypedArray, KEY, forced ? property : NATIVE_ARRAY_BUFFER_VIEWS && Int8Array[KEY] || property); - } catch (e) { /* empty */ } + } catch (error) { /* empty */ } } else return; } for (ARRAY in TypedArrayConstructorsList) { diff --git a/packages/core-js/internals/array-buffer.js b/packages/core-js/internals/array-buffer.js index 5aa104bbce20..8ab7fd931cf0 100644 --- a/packages/core-js/internals/array-buffer.js +++ b/packages/core-js/internals/array-buffer.js @@ -115,15 +115,15 @@ var unpackInt32 = function (buffer) { }; var packInt8 = function (number) { - return [number & 0xff]; + return [number & 0xFF]; }; var packInt16 = function (number) { - return [number & 0xff, number >> 8 & 0xff]; + return [number & 0xFF, number >> 8 & 0xFF]; }; var packInt32 = function (number) { - return [number & 0xff, number >> 8 & 0xff, number >> 16 & 0xff, number >> 24 & 0xff]; + return [number & 0xFF, number >> 8 & 0xFF, number >> 16 & 0xFF, number >> 24 & 0xFF]; }; var packFloat32 = function (number) { diff --git a/packages/core-js/internals/call-with-safe-iteration-closing.js b/packages/core-js/internals/call-with-safe-iteration-closing.js index 7b806fe48014..75036565572a 100644 --- a/packages/core-js/internals/call-with-safe-iteration-closing.js +++ b/packages/core-js/internals/call-with-safe-iteration-closing.js @@ -5,9 +5,9 @@ module.exports = function (iterator, fn, value, ENTRIES) { try { return ENTRIES ? fn(anObject(value)[0], value[1]) : fn(value); // 7.4.6 IteratorClose(iterator, completion) - } catch (e) { + } catch (error) { var returnMethod = iterator['return']; if (returnMethod !== undefined) anObject(returnMethod.call(iterator)); - throw e; + throw error; } }; diff --git a/packages/core-js/internals/check-correctness-of-iteration.js b/packages/core-js/internals/check-correctness-of-iteration.js index 7af2043e8b4a..ad3356ecd099 100644 --- a/packages/core-js/internals/check-correctness-of-iteration.js +++ b/packages/core-js/internals/check-correctness-of-iteration.js @@ -16,7 +16,7 @@ try { }; // eslint-disable-next-line no-throw-literal Array.from(iteratorWithReturn, function () { throw 2; }); -} catch (e) { /* empty */ } +} catch (error) { /* empty */ } module.exports = function (exec, SKIP_CLOSING) { if (!SKIP_CLOSING && !SAFE_CLOSING) return false; @@ -31,6 +31,6 @@ module.exports = function (exec, SKIP_CLOSING) { }; }; exec(object); - } catch (e) { /* empty */ } + } catch (error) { /* empty */ } return ITERATION_SUPPORT; }; diff --git a/packages/core-js/internals/classof.js b/packages/core-js/internals/classof.js index 3733b7557ee6..eb30d277739f 100644 --- a/packages/core-js/internals/classof.js +++ b/packages/core-js/internals/classof.js @@ -7,7 +7,7 @@ var CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) == 'Argu var tryGet = function (it, key) { try { return it[key]; - } catch (e) { /* empty */ } + } catch (error) { /* empty */ } }; // getting tag from ES6+ `Object.prototype.toString` diff --git a/packages/core-js/internals/fails.js b/packages/core-js/internals/fails.js index 3b4cdf6740b3..f398e2da8e9d 100644 --- a/packages/core-js/internals/fails.js +++ b/packages/core-js/internals/fails.js @@ -1,7 +1,7 @@ module.exports = function (exec) { try { return !!exec(); - } catch (e) { + } catch (error) { return true; } }; diff --git a/packages/core-js/internals/flatten-into-array.js b/packages/core-js/internals/flatten-into-array.js index 403ee4bf68c4..e218b1dcb8d2 100644 --- a/packages/core-js/internals/flatten-into-array.js +++ b/packages/core-js/internals/flatten-into-array.js @@ -18,7 +18,7 @@ var flattenIntoArray = function (target, original, source, sourceLen, start, dep if (depth > 0 && isArray(element)) { targetIndex = flattenIntoArray(target, original, element, toLength(element.length), targetIndex, depth - 1) - 1; } else { - if (targetIndex >= 0x1fffffffffffff) throw TypeError(); + if (targetIndex >= 0x1FFFFFFFFFFFFF) throw TypeError('Exceed the acceptable array length'); target[targetIndex] = element; } diff --git a/packages/core-js/internals/forced-string-trim-method.js b/packages/core-js/internals/forced-string-trim-method.js index 758227f7fac0..bba4104f4c59 100644 --- a/packages/core-js/internals/forced-string-trim-method.js +++ b/packages/core-js/internals/forced-string-trim-method.js @@ -1,6 +1,6 @@ var fails = require('../internals/fails'); var whitespaces = require('../internals/whitespaces'); -var non = '\u200b\u0085\u180e'; +var non = '\u200B\u0085\u180E'; // check that a method works with the correct list // of whitespaces and has a correct name diff --git a/packages/core-js/internals/microtask.js b/packages/core-js/internals/microtask.js index cea0d275db5a..82873821248c 100644 --- a/packages/core-js/internals/microtask.js +++ b/packages/core-js/internals/microtask.js @@ -23,10 +23,10 @@ if (!queueMicrotask) { head = head.next; try { fn(); - } catch (e) { + } catch (error) { if (head) notify(); else last = undefined; - throw e; + throw error; } } last = undefined; if (parent) parent.enter(); diff --git a/packages/core-js/internals/object-define-property.js b/packages/core-js/internals/object-define-property.js index 80dba727601f..8854d5e940f4 100644 --- a/packages/core-js/internals/object-define-property.js +++ b/packages/core-js/internals/object-define-property.js @@ -10,7 +10,7 @@ exports.f = DESCRIPTORS ? nativeDefineProperty : function defineProperty(O, P, A anObject(Attributes); if (IE8_DOM_DEFINE) try { return nativeDefineProperty(O, P, Attributes); - } catch (e) { /* empty */ } + } catch (error) { /* empty */ } if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported'); if ('value' in Attributes) O[P] = Attributes.value; return O; diff --git a/packages/core-js/internals/object-get-own-property-descriptor.js b/packages/core-js/internals/object-get-own-property-descriptor.js index f069d666826e..c19b3d0fe882 100644 --- a/packages/core-js/internals/object-get-own-property-descriptor.js +++ b/packages/core-js/internals/object-get-own-property-descriptor.js @@ -12,6 +12,6 @@ exports.f = DESCRIPTORS ? nativeGetOwnPropertyDescriptor : function getOwnProper P = toPrimitive(P, true); if (IE8_DOM_DEFINE) try { return nativeGetOwnPropertyDescriptor(O, P); - } catch (e) { /* empty */ } + } catch (error) { /* empty */ } if (has(O, P)) return createPropertyDescriptor(!propertyIsEnumerableModule.f.call(O, P), O[P]); }; diff --git a/packages/core-js/internals/object-get-own-property-names-external.js b/packages/core-js/internals/object-get-own-property-names-external.js index 15813b77e5ee..776e793541da 100644 --- a/packages/core-js/internals/object-get-own-property-names-external.js +++ b/packages/core-js/internals/object-get-own-property-names-external.js @@ -9,7 +9,7 @@ var windowNames = typeof window == 'object' && window && Object.getOwnPropertyNa var getWindowNames = function (it) { try { return nativeGetOwnPropertyNames(it); - } catch (e) { + } catch (error) { return windowNames.slice(); } }; diff --git a/packages/core-js/internals/object-set-prototype-of.js b/packages/core-js/internals/object-set-prototype-of.js index c297a7d66ab2..9765d0340373 100644 --- a/packages/core-js/internals/object-set-prototype-of.js +++ b/packages/core-js/internals/object-set-prototype-of.js @@ -2,7 +2,7 @@ /* eslint-disable no-proto */ var validateSetPrototypeOfArguments = require('../internals/validate-set-prototype-of-arguments'); -module.exports = Object.setPrototypeOf || ('__proto__' in {} ? function () { // eslint-disable-line +module.exports = Object.setPrototypeOf || ('__proto__' in {} ? function () { var correctSetter = false; var test = {}; var setter; @@ -10,7 +10,7 @@ module.exports = Object.setPrototypeOf || ('__proto__' in {} ? function () { // setter = Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').set; setter.call(test, []); correctSetter = test instanceof Array; - } catch (e) { /* empty */ } + } catch (error) { /* empty */ } return function setPrototypeOf(O, proto) { validateSetPrototypeOfArguments(O, proto); if (correctSetter) setter.call(O, proto); diff --git a/packages/core-js/internals/perform.js b/packages/core-js/internals/perform.js index bfc7b296da95..2e75d7a26858 100644 --- a/packages/core-js/internals/perform.js +++ b/packages/core-js/internals/perform.js @@ -1,7 +1,7 @@ module.exports = function (exec) { try { return { e: false, v: exec() }; - } catch (e) { - return { e: true, v: e }; + } catch (error) { + return { e: true, v: error }; } }; diff --git a/packages/core-js/internals/punycode-to-ascii.js b/packages/core-js/internals/punycode-to-ascii.js index bce919e72e83..2d43864ad7ac 100644 --- a/packages/core-js/internals/punycode-to-ascii.js +++ b/packages/core-js/internals/punycode-to-ascii.js @@ -9,8 +9,8 @@ var damp = 700; var initialBias = 72; var initialN = 128; // 0x80 var delimiter = '-'; // '\x2D' -var regexNonASCII = /[^\0-\x7E]/; // non-ASCII chars -var regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g; // RFC 3490 separators +var regexNonASCII = /[^\0-\u007E]/; // non-ASCII chars +var regexSeparators = /[\u002E\u3002\uFF0E\uFF61]/g; // RFC 3490 separators var OVERFLOW_ERROR = 'Overflow: input needs wider integers to process'; var baseMinusTMin = base - tMin; var floor = Math.floor; @@ -160,7 +160,7 @@ var encode = function (input) { module.exports = function (input) { var encoded = []; - var labels = input.toLowerCase().replace(regexSeparators, '\x2E').split('.'); + var labels = input.toLowerCase().replace(regexSeparators, '\u002E').split('.'); var i, label; for (i = 0; i < labels.length; i++) { label = labels[i]; diff --git a/packages/core-js/internals/set-global.js b/packages/core-js/internals/set-global.js index 0077f6017eff..6ebbe5db6082 100644 --- a/packages/core-js/internals/set-global.js +++ b/packages/core-js/internals/set-global.js @@ -4,7 +4,7 @@ var hide = require('../internals/hide'); module.exports = function (key, value) { try { hide(global, key, value); - } catch (e) { + } catch (error) { global[key] = value; } return value; }; diff --git a/packages/core-js/internals/sloppy-array-method.js b/packages/core-js/internals/sloppy-array-method.js index 309d58cbf9cf..8ec998384ad4 100644 --- a/packages/core-js/internals/sloppy-array-method.js +++ b/packages/core-js/internals/sloppy-array-method.js @@ -4,7 +4,7 @@ var fails = require('../internals/fails'); module.exports = function (METHOD_NAME, argument) { var method = [][METHOD_NAME]; return !method || !fails(function () { - // eslint-disable-next-line no-useless-call - method.call(null, argument || function () { throw Error(); }, 1); + // eslint-disable-next-line no-useless-call,no-throw-literal + method.call(null, argument || function () { throw 1; }, 1); }); }; diff --git a/packages/core-js/internals/string-at.js b/packages/core-js/internals/string-at.js index 6a707276104c..657c5ffc5242 100644 --- a/packages/core-js/internals/string-at.js +++ b/packages/core-js/internals/string-at.js @@ -9,8 +9,8 @@ module.exports = function (that, pos, CONVERT_TO_STRING) { var first, second; if (position < 0 || position >= size) return CONVERT_TO_STRING ? '' : undefined; first = S.charCodeAt(position); - return first < 0xd800 || first > 0xdbff || position + 1 === size - || (second = S.charCodeAt(position + 1)) < 0xdc00 || second > 0xdfff + return first < 0xD800 || first > 0xDBFF || position + 1 === size + || (second = S.charCodeAt(position + 1)) < 0xDC00 || second > 0xDFFF ? CONVERT_TO_STRING ? S.charAt(position) : first - : CONVERT_TO_STRING ? S.slice(position, position + 2) : (first - 0xd800 << 10) + (second - 0xdc00) + 0x10000; + : CONVERT_TO_STRING ? S.slice(position, position + 2) : (first - 0xD800 << 10) + (second - 0xDC00) + 0x10000; }; diff --git a/packages/core-js/internals/to-length.js b/packages/core-js/internals/to-length.js index 2ac7d90753bd..a38ca663b0a9 100644 --- a/packages/core-js/internals/to-length.js +++ b/packages/core-js/internals/to-length.js @@ -4,5 +4,5 @@ var min = Math.min; // `ToLength` abstract operation // https://tc39.github.io/ecma262/#sec-tolength module.exports = function (argument) { - return argument > 0 ? min(toInteger(argument), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991 + return argument > 0 ? min(toInteger(argument), 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991 }; diff --git a/packages/core-js/internals/typed-array-constructor.js b/packages/core-js/internals/typed-array-constructor.js index 7dd0bfb3b2e7..dd362ca96eb2 100644 --- a/packages/core-js/internals/typed-array-constructor.js +++ b/packages/core-js/internals/typed-array-constructor.js @@ -119,7 +119,7 @@ if (require('../internals/descriptors')) { var setter = function (that, index, value) { var data = getInternalState(that); - if (CLAMPED) value = (value = Math.round(value)) < 0 ? 0 : value > 0xff ? 0xff : value & 0xff; + if (CLAMPED) value = (value = Math.round(value)) < 0 ? 0 : value > 0xFF ? 0xFF : value & 0xFF; data.view[SETTER](index * BYTES + data.byteOffset, value, true); }; diff --git a/packages/core-js/internals/webkit-string-pad-bug.js b/packages/core-js/internals/webkit-string-pad-bug.js new file mode 100644 index 000000000000..31ab9fc2220a --- /dev/null +++ b/packages/core-js/internals/webkit-string-pad-bug.js @@ -0,0 +1,5 @@ +// https://github.com/zloirock/core-js/issues/280 +var userAgent = require('../internals/user-agent'); + +// eslint-disable-next-line unicorn/no-unsafe-regex +module.exports = /Version\/10\.\d+(\.\d+)?( Mobile\/\w+)? Safari\//.test(userAgent); diff --git a/packages/core-js/internals/whitespaces.js b/packages/core-js/internals/whitespaces.js index e8d1f562b024..0924bab14637 100644 --- a/packages/core-js/internals/whitespaces.js +++ b/packages/core-js/internals/whitespaces.js @@ -1,3 +1,3 @@ // a string of all valid unicode whitespaces // eslint-disable-next-line max-len -module.exports = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF'; +module.exports = '\u0009\u000A\u000B\u000C\u000D\u0020\u00A0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF'; diff --git a/packages/core-js/modules/es.array.concat.js b/packages/core-js/modules/es.array.concat.js index 4eb187dad728..cace2e5e2f4c 100644 --- a/packages/core-js/modules/es.array.concat.js +++ b/packages/core-js/modules/es.array.concat.js @@ -6,7 +6,7 @@ var toLength = require('../internals/to-length'); var createProperty = require('../internals/create-property'); var arraySpeciesCreate = require('../internals/array-species-create'); var IS_CONCAT_SPREADABLE = require('../internals/well-known-symbol')('isConcatSpreadable'); -var MAX_SAFE_INTEGER = 0x1fffffffffffff; +var MAX_SAFE_INTEGER = 0x1FFFFFFFFFFFFF; var MAXIMUM_ALLOWED_INDEX_EXCEEDED = 'Maximum allowed index exceeded'; var IS_CONCAT_SPREADABLE_SUPPORT = !require('../internals/fails')(function () { diff --git a/packages/core-js/modules/es.array.splice.js b/packages/core-js/modules/es.array.splice.js index 10a97266c2c2..0c53664a8fe3 100644 --- a/packages/core-js/modules/es.array.splice.js +++ b/packages/core-js/modules/es.array.splice.js @@ -7,7 +7,7 @@ var arraySpeciesCreate = require('../internals/array-species-create'); var createProperty = require('../internals/create-property'); var max = Math.max; var min = Math.min; -var MAX_SAFE_INTEGER = 0x1fffffffffffff; +var MAX_SAFE_INTEGER = 0x1FFFFFFFFFFFFF; var MAXIMUM_ALLOWED_LENGTH_EXCEEDED = 'Maximum allowed length exceeded'; var SPECIES_SUPPORT = require('../internals/array-method-has-species-support')('splice'); diff --git a/packages/core-js/modules/es.function.name.js b/packages/core-js/modules/es.function.name.js index 1d089573d7c5..0bd8a8661318 100644 --- a/packages/core-js/modules/es.function.name.js +++ b/packages/core-js/modules/es.function.name.js @@ -13,7 +13,7 @@ if (DESCRIPTORS && !(NAME in FunctionPrototype)) { get: function () { try { return FunctionPrototypeToString.call(this).match(nameRE)[1]; - } catch (e) { + } catch (error) { return ''; } } diff --git a/packages/core-js/modules/es.math.imul.js b/packages/core-js/modules/es.math.imul.js index 1d060da6617e..cfdedd5a66df 100644 --- a/packages/core-js/modules/es.math.imul.js +++ b/packages/core-js/modules/es.math.imul.js @@ -1,7 +1,7 @@ var nativeImul = Math.imul; var FORCED = require('../internals/fails')(function () { - return nativeImul(0xffffffff, 5) != -5 || nativeImul.length != 2; + return nativeImul(0xFFFFFFFF, 5) != -5 || nativeImul.length != 2; }); // `Math.imul` method @@ -9,7 +9,7 @@ var FORCED = require('../internals/fails')(function () { // some WebKit versions fails with big numbers, some has wrong arity require('../internals/export')({ target: 'Math', stat: true, forced: FORCED }, { imul: function imul(x, y) { - var UINT16 = 0xffff; + var UINT16 = 0xFFFF; var xn = +x; var yn = +y; var xl = UINT16 & xn; diff --git a/packages/core-js/modules/es.number.is-safe-integer.js b/packages/core-js/modules/es.number.is-safe-integer.js index 81d786fc97fd..a2986cb21f1b 100644 --- a/packages/core-js/modules/es.number.is-safe-integer.js +++ b/packages/core-js/modules/es.number.is-safe-integer.js @@ -5,6 +5,6 @@ var abs = Math.abs; // https://tc39.github.io/ecma262/#sec-number.issafeinteger require('../internals/export')({ target: 'Number', stat: true }, { isSafeInteger: function isSafeInteger(number) { - return isInteger(number) && abs(number) <= 0x1fffffffffffff; + return isInteger(number) && abs(number) <= 0x1FFFFFFFFFFFFF; } }); diff --git a/packages/core-js/modules/es.number.max-safe-integer.js b/packages/core-js/modules/es.number.max-safe-integer.js index 1d395c2e6097..fd5640ea25b5 100644 --- a/packages/core-js/modules/es.number.max-safe-integer.js +++ b/packages/core-js/modules/es.number.max-safe-integer.js @@ -1,3 +1,3 @@ // `Number.MAX_SAFE_INTEGER` constant // https://tc39.github.io/ecma262/#sec-number.max_safe_integer -require('../internals/export')({ target: 'Number', stat: true }, { MAX_SAFE_INTEGER: 0x1fffffffffffff }); +require('../internals/export')({ target: 'Number', stat: true }, { MAX_SAFE_INTEGER: 0x1FFFFFFFFFFFFF }); diff --git a/packages/core-js/modules/es.number.min-safe-integer.js b/packages/core-js/modules/es.number.min-safe-integer.js index ca9765aadfab..9323cc8eaa3b 100644 --- a/packages/core-js/modules/es.number.min-safe-integer.js +++ b/packages/core-js/modules/es.number.min-safe-integer.js @@ -1,3 +1,3 @@ // `Number.MIN_SAFE_INTEGER` constant // https://tc39.github.io/ecma262/#sec-number.min_safe_integer -require('../internals/export')({ target: 'Number', stat: true }, { MIN_SAFE_INTEGER: -0x1fffffffffffff }); +require('../internals/export')({ target: 'Number', stat: true }, { MIN_SAFE_INTEGER: -0x1FFFFFFFFFFFFF }); diff --git a/packages/core-js/modules/es.promise.js b/packages/core-js/modules/es.promise.js index d5d840a70e4e..24fe0d2d9a71 100644 --- a/packages/core-js/modules/es.promise.js +++ b/packages/core-js/modules/es.promise.js @@ -106,9 +106,9 @@ var notify = function (promise, state, isReject) { then.call(result, resolve, reject); } else resolve(result); } else reject(value); - } catch (e) { + } catch (error) { if (domain && !exited) domain.exit(); - reject(e); + reject(error); } }; while (chain.length > i) run(chain[i++]); // variable length - can't use forEach @@ -191,8 +191,8 @@ var internalResolve = function (promise, state, value, unwrap) { bind(internalResolve, promise, wrapper, state), bind(internalReject, promise, wrapper, state) ); - } catch (e) { - internalReject(promise, wrapper, e, state); + } catch (error) { + internalReject(promise, wrapper, error, state); } }); } else { @@ -200,8 +200,8 @@ var internalResolve = function (promise, state, value, unwrap) { state.state = FULFILLED; notify(promise, state, false); } - } catch (e) { - internalReject(promise, { done: false }, e, state); + } catch (error) { + internalReject(promise, { done: false }, error, state); } }; @@ -215,8 +215,8 @@ if (FORCED) { var state = getInternalState(this); try { executor(bind(internalResolve, this, state), bind(internalReject, this, state)); - } catch (err) { - internalReject(this, state, err); + } catch (error) { + internalReject(this, state, error); } }; // eslint-disable-next-line no-unused-vars diff --git a/packages/core-js/modules/es.reflect.define-property.js b/packages/core-js/modules/es.reflect.define-property.js index 8ea03a0bbf67..d325cd5acc7d 100644 --- a/packages/core-js/modules/es.reflect.define-property.js +++ b/packages/core-js/modules/es.reflect.define-property.js @@ -19,7 +19,7 @@ require('../internals/export')({ target: 'Reflect', stat: true, forced: ERROR_IN try { definePropertyModule.f(target, propertyKey, attributes); return true; - } catch (e) { + } catch (error) { return false; } } diff --git a/packages/core-js/modules/es.reflect.prevent-extensions.js b/packages/core-js/modules/es.reflect.prevent-extensions.js index 3a7e0b9a4676..f197e035b32d 100644 --- a/packages/core-js/modules/es.reflect.prevent-extensions.js +++ b/packages/core-js/modules/es.reflect.prevent-extensions.js @@ -11,7 +11,7 @@ require('../internals/export')({ target: 'Reflect', stat: true, sham: !FREEZING var objectPreventExtensions = getBuiltIn('Object', 'preventExtensions'); if (objectPreventExtensions) objectPreventExtensions(target); return true; - } catch (e) { + } catch (error) { return false; } } diff --git a/packages/core-js/modules/es.reflect.set-prototype-of.js b/packages/core-js/modules/es.reflect.set-prototype-of.js index 270652b759ff..0477429a6b78 100644 --- a/packages/core-js/modules/es.reflect.set-prototype-of.js +++ b/packages/core-js/modules/es.reflect.set-prototype-of.js @@ -9,7 +9,7 @@ if (objectSetPrototypeOf) require('../internals/export')({ target: 'Reflect', st try { objectSetPrototypeOf(target, proto); return true; - } catch (e) { + } catch (error) { return false; } } diff --git a/packages/core-js/modules/es.string.from-code-point.js b/packages/core-js/modules/es.string.from-code-point.js index 77ccbae4a8b5..18690ffefb41 100644 --- a/packages/core-js/modules/es.string.from-code-point.js +++ b/packages/core-js/modules/es.string.from-code-point.js @@ -15,10 +15,10 @@ require('../internals/export')({ target: 'String', stat: true, forced: INCORRECT var code; while (length > i) { code = +arguments[i++]; - if (toAbsoluteIndex(code, 0x10ffff) !== code) throw RangeError(code + ' is not a valid code point'); + if (toAbsoluteIndex(code, 0x10FFFF) !== code) throw RangeError(code + ' is not a valid code point'); elements.push(code < 0x10000 ? fromCharCode(code) - : fromCharCode(((code -= 0x10000) >> 10) + 0xd800, code % 0x400 + 0xdc00) + : fromCharCode(((code -= 0x10000) >> 10) + 0xD800, code % 0x400 + 0xDC00) ); } return elements.join(''); } diff --git a/packages/core-js/modules/es.string.pad-end.js b/packages/core-js/modules/es.string.pad-end.js index d754190e92ce..cf54ba3aa792 100644 --- a/packages/core-js/modules/es.string.pad-end.js +++ b/packages/core-js/modules/es.string.pad-end.js @@ -1,9 +1,6 @@ 'use strict'; var internalStringPad = require('../internals/string-pad'); -var userAgent = require('../internals/user-agent'); - -// https://github.com/zloirock/core-js/issues/280 -var WEBKIT_BUG = /Version\/10\.\d+(\.\d+)?( Mobile\/\w+)? Safari\//.test(userAgent); +var WEBKIT_BUG = require('../internals/webkit-string-pad-bug'); // `String.prototype.padEnd` method // https://tc39.github.io/ecma262/#sec-string.prototype.padend diff --git a/packages/core-js/modules/es.string.pad-start.js b/packages/core-js/modules/es.string.pad-start.js index 2acd46fbb8cd..1cd71a093903 100644 --- a/packages/core-js/modules/es.string.pad-start.js +++ b/packages/core-js/modules/es.string.pad-start.js @@ -1,9 +1,6 @@ 'use strict'; var internalStringPad = require('../internals/string-pad'); -var userAgent = require('../internals/user-agent'); - -// https://github.com/zloirock/core-js/issues/280 -var WEBKIT_BUG = /Version\/10\.\d+(\.\d+)?( Mobile\/\w+)? Safari\//.test(userAgent); +var WEBKIT_BUG = require('../internals/webkit-string-pad-bug'); // `String.prototype.padStart` method // https://tc39.github.io/ecma262/#sec-string.prototype.padstart diff --git a/packages/core-js/modules/es.string.split.js b/packages/core-js/modules/es.string.split.js index bbced21b5a4b..565883137c36 100644 --- a/packages/core-js/modules/es.string.split.js +++ b/packages/core-js/modules/es.string.split.js @@ -11,7 +11,7 @@ var regexpExec = require('../internals/regexp-exec'); var fails = require('../internals/fails'); var arrayPush = [].push; var min = Math.min; -var MAX_UINT32 = 0xffffffff; +var MAX_UINT32 = 0xFFFFFFFF; // babel-minify transpiles RegExp('x', 'y') -> /x/y and it causes SyntaxError var SUPPORTS_Y = !fails(function () { return !RegExp(MAX_UINT32, 'y'); }); diff --git a/packages/core-js/modules/esnext.math.imulh.js b/packages/core-js/modules/esnext.math.imulh.js index 9bc8a728bb4b..43fa535a6e9a 100644 --- a/packages/core-js/modules/esnext.math.imulh.js +++ b/packages/core-js/modules/esnext.math.imulh.js @@ -2,7 +2,7 @@ // https://gist.github.com/BrendanEich/4294d5c212a6d2254703 require('../internals/export')({ target: 'Math', stat: true }, { imulh: function imulh(u, v) { - var UINT16 = 0xffff; + var UINT16 = 0xFFFF; var $u = +u; var $v = +v; var u0 = $u & UINT16; diff --git a/packages/core-js/modules/esnext.math.umulh.js b/packages/core-js/modules/esnext.math.umulh.js index 50f4915656fa..6485f90b1343 100644 --- a/packages/core-js/modules/esnext.math.umulh.js +++ b/packages/core-js/modules/esnext.math.umulh.js @@ -2,7 +2,7 @@ // https://gist.github.com/BrendanEich/4294d5c212a6d2254703 require('../internals/export')({ target: 'Math', stat: true }, { umulh: function umulh(u, v) { - var UINT16 = 0xffff; + var UINT16 = 0xFFFF; var $u = +u; var $v = +v; var u0 = $u & UINT16; diff --git a/packages/core-js/modules/esnext.observable.js b/packages/core-js/modules/esnext.observable.js index 1167f551f844..c9938298ac3b 100644 --- a/packages/core-js/modules/esnext.observable.js +++ b/packages/core-js/modules/esnext.observable.js @@ -27,8 +27,8 @@ var cleanupSubscription = function (subscriptionState) { subscriptionState.cleanup = undefined; try { cleanup(); - } catch (e) { - hostReportErrors(e); + } catch (error) { + hostReportErrors(error); } } }; @@ -55,8 +55,8 @@ var Subscription = function (observer, subscriber) { if (!DESCRIPTORS) this.closed = false; try { if (start = getMethod(observer.start)) start.call(observer, this); - } catch (e) { - hostReportErrors(e); + } catch (error) { + hostReportErrors(error); } if (subscriptionClosed(subscriptionState)) return; var subscriptionObserver = subscriptionState.subscriptionObserver = new SubscriptionObserver(this); @@ -66,8 +66,8 @@ var Subscription = function (observer, subscriber) { if (cleanup != null) subscriptionState.cleanup = typeof cleanup.unsubscribe === 'function' ? function () { subscription.unsubscribe(); } : aFunction(cleanup); - } catch (e) { - subscriptionObserver.error(e); + } catch (error) { + subscriptionObserver.error(error); return; } if (subscriptionClosed(subscriptionState)) cleanupSubscription(subscriptionState); }; @@ -102,8 +102,8 @@ SubscriptionObserver.prototype = redefineAll({}, { try { var m = getMethod(observer.next); if (m) m.call(observer, value); - } catch (e) { - hostReportErrors(e); + } catch (error) { + hostReportErrors(error); } } }, @@ -117,8 +117,8 @@ SubscriptionObserver.prototype = redefineAll({}, { var m = getMethod(observer.error); if (m) m.call(observer, value); else hostReportErrors(value); - } catch (e) { - hostReportErrors(e); + } catch (err) { + hostReportErrors(err); } cleanupSubscription(subscriptionState); } }, @@ -131,8 +131,8 @@ SubscriptionObserver.prototype = redefineAll({}, { try { var m = getMethod(observer.complete); if (m) m.call(observer); - } catch (e) { - hostReportErrors(e); + } catch (error) { + hostReportErrors(error); } cleanupSubscription(subscriptionState); } } diff --git a/packages/core-js/modules/web.dom-collections.for-each.js b/packages/core-js/modules/web.dom-collections.for-each.js index a64791af3a85..1c115d18d483 100644 --- a/packages/core-js/modules/web.dom-collections.for-each.js +++ b/packages/core-js/modules/web.dom-collections.for-each.js @@ -9,7 +9,7 @@ for (var COLLECTION_NAME in DOMIterables) { // some Chrome versions have non-configurable methods on DOMTokenList if (CollectionPrototype && CollectionPrototype.forEach !== forEach) try { hide(CollectionPrototype, 'forEach', forEach); - } catch (e) { + } catch (error) { CollectionPrototype.forEach = forEach; } } diff --git a/packages/core-js/modules/web.dom-collections.iterator.js b/packages/core-js/modules/web.dom-collections.iterator.js index 1bcb631379a5..f6a147d0152a 100644 --- a/packages/core-js/modules/web.dom-collections.iterator.js +++ b/packages/core-js/modules/web.dom-collections.iterator.js @@ -14,7 +14,7 @@ for (var COLLECTION_NAME in DOMIterables) { // some Chrome versions have non-configurable methods on DOMTokenList if (CollectionPrototype[ITERATOR] !== ArrayValues) try { hide(CollectionPrototype, ITERATOR, ArrayValues); - } catch (e) { + } catch (error) { CollectionPrototype[ITERATOR] = ArrayValues; } if (!CollectionPrototype[TO_STRING_TAG]) hide(CollectionPrototype, TO_STRING_TAG, COLLECTION_NAME); @@ -22,7 +22,7 @@ for (var COLLECTION_NAME in DOMIterables) { // some Chrome versions have non-configurable methods on DOMTokenList if (CollectionPrototype[METHOD_NAME] !== ArrayIteratorMethods[METHOD_NAME]) try { hide(CollectionPrototype, METHOD_NAME, ArrayIteratorMethods[METHOD_NAME]); - } catch (e) { + } catch (error) { CollectionPrototype[METHOD_NAME] = ArrayIteratorMethods[METHOD_NAME]; } } diff --git a/packages/core-js/modules/web.url.js b/packages/core-js/modules/web.url.js index 0d6de904c626..50a5a4f3b866 100644 --- a/packages/core-js/modules/web.url.js +++ b/packages/core-js/modules/web.url.js @@ -1,6 +1,5 @@ 'use strict'; require('../modules/es.string.iterator'); -// var DEBUG = true; var DESCRIPTORS = require('../internals/descriptors'); var USE_NATIVE_URL = require('../internals/native-url'); var NativeURL = require('../internals/global').URL; @@ -27,10 +26,10 @@ var INVALID_PORT = 'Invalid port'; var ALPHA = /[a-zA-Z]/; var ALPHANUMERIC = /[a-zA-Z0-9+\-.]/; -var DIGIT = /[0-9]/; +var DIGIT = /\d/; var HEX_START = /^(0x|0X)/; var OCT = /^[0-7]+$/; -var DEC = /^[0-9]+$/; +var DEC = /^\d+$/; var HEX = /^[0-9A-Fa-f]+$/; // eslint-disable-next-line no-control-regex var FORBIDDEN_HOST_CODE_POINT = /\u0000|\u0009|\u000A|\u000D|\u0020|#|%|\/|:|\?|@|\[|\\|\]/; @@ -304,27 +303,27 @@ var isDoubleDot = function (segment) { }; // States: -var SCHEME_START = {}; // 'SCHEME_START'; -var SCHEME = {}; // 'SCHEME'; -var NO_SCHEME = {}; // 'NO_SCHEME'; -var SPECIAL_RELATIVE_OR_AUTHORITY = {}; // 'SPECIAL_RELATIVE_OR_AUTHORITY'; -var PATH_OR_AUTHORITY = {}; // 'PATH_OR_AUTHORITY'; -var RELATIVE = {}; // 'RELATIVE'; -var RELATIVE_SLASH = {}; // 'RELATIVE_SLASH'; -var SPECIAL_AUTHORITY_SLASHES = {}; // 'SPECIAL_AUTHORITY_SLASHES'; -var SPECIAL_AUTHORITY_IGNORE_SLASHES = {}; // 'SPECIAL_AUTHORITY_IGNORE_SLASHES'; -var AUTHORITY = {}; // 'AUTHORITY'; -var HOST = {}; // 'HOST'; -var HOSTNAME = {}; // 'HOSTNAME'; -var PORT = {}; // 'PORT'; -var FILE = {}; // 'FILE'; -var FILE_SLASH = {}; // 'FILE_SLASH'; -var FILE_HOST = {}; // 'FILE_HOST'; -var PATH_START = {}; // 'PATH_START'; -var PATH = {}; // 'PATH'; -var CANNOT_BE_A_BASE_URL_PATH = {}; // 'CANNOT_BE_A_BASE_URL_PATH'; -var QUERY = {}; // 'QUERY'; -var FRAGMENT = {}; // 'FRAGMENT'; +var SCHEME_START = {}; +var SCHEME = {}; +var NO_SCHEME = {}; +var SPECIAL_RELATIVE_OR_AUTHORITY = {}; +var PATH_OR_AUTHORITY = {}; +var RELATIVE = {}; +var RELATIVE_SLASH = {}; +var SPECIAL_AUTHORITY_SLASHES = {}; +var SPECIAL_AUTHORITY_IGNORE_SLASHES = {}; +var AUTHORITY = {}; +var HOST = {}; +var HOSTNAME = {}; +var PORT = {}; +var FILE = {}; +var FILE_SLASH = {}; +var FILE_HOST = {}; +var PATH_START = {}; +var PATH = {}; +var CANNOT_BE_A_BASE_URL_PATH = {}; +var QUERY = {}; +var FRAGMENT = {}; // eslint-disable-next-line max-statements var parseURL = function (url, input, stateOverride, base) { @@ -355,8 +354,6 @@ var parseURL = function (url, input, stateOverride, base) { while (pointer <= codePoints.length) { char = codePoints[pointer]; - // eslint-disable-next-line - // if (DEBUG) console.log(pointer, char, state, buffer); switch (state) { case SCHEME_START: if (char && ALPHA.test(char)) { @@ -571,7 +568,7 @@ var parseURL = function (url, input, stateOverride, base) { ) { if (buffer != '') { var port = parseInt(buffer, 10); - if (port > 0xffff) return INVALID_PORT; + if (port > 0xFFFF) return INVALID_PORT; url.port = (isSpecial(url) && port === specialSchemes[url.scheme]) ? null : port; buffer = ''; } @@ -737,7 +734,6 @@ var URLConstructor = function URL(url /* , base */) { var urlString = String(url); var state = setInternalState(that, { type: 'URL' }); var baseState, failure; - // if (DEBUG) this.state = state; if (base !== undefined) { if (base instanceof URLConstructor) baseState = getInternalURLState(base); else { @@ -802,7 +798,7 @@ var getOrigin = function () { var port = url.port; if (scheme == 'blob') try { return new URL(scheme.path[0]).origin; - } catch (e) { + } catch (error) { return 'null'; } if (scheme == 'file' || !isSpecial(url)) return 'null'; diff --git a/tests/commonjs.js b/tests/commonjs.js index 95402dce65c9..5b4ee3525191 100644 --- a/tests/commonjs.js +++ b/tests/commonjs.js @@ -134,23 +134,23 @@ for (const _PATH of ['../packages/core-js-pure', '../packages/core-js']) { ok(load('features/math/deg-per-rad') === Math.PI / 180); ok(load('features/math/degrees')(Math.PI) === 180); ok(load('features/math/fscale')(3, 1, 2, 1, 2) === 3); - ok(load('features/math/iaddh')(3, 2, 0xffffffff, 4) === 7); - ok(load('features/math/isubh')(3, 4, 0xffffffff, 2) === 1); - ok(load('features/math/imulh')(0xffffffff, 7) === -1); + ok(load('features/math/iaddh')(3, 2, 0xFFFFFFFF, 4) === 7); + ok(load('features/math/isubh')(3, 4, 0xFFFFFFFF, 2) === 1); + ok(load('features/math/imulh')(0xFFFFFFFF, 7) === -1); ok(load('features/math/rad-per-deg') === 180 / Math.PI); ok(load('features/math/radians')(180) === Math.PI); ok(load('features/math/scale')(3, 1, 2, 1, 2) === 3); - ok(load('features/math/umulh')(0xffffffff, 7) === 6); + ok(load('features/math/umulh')(0xFFFFFFFF, 7) === 6); ok(load('features/math/signbit')(-2) === false); ok(typeof load('features/math/seeded-prng')({ seed: 42 }).next().value === 'number'); ok(load('features/number/constructor')('5') === 5); - ok(load('features/number/epsilon') === Math.pow(2, -52)); + ok(load('features/number/epsilon') === 2 ** -52); ok(load('features/number/is-finite')(42.5)); ok(load('features/number/is-integer')(42.5) === false); ok(load('features/number/is-nan')(NaN)); ok(load('features/number/is-safe-integer')(42)); - ok(load('features/number/max-safe-integer') === 0x1fffffffffffff); - ok(load('features/number/min-safe-integer') === -0x1fffffffffffff); + ok(load('features/number/max-safe-integer') === 0x1FFFFFFFFFFFFF); + ok(load('features/number/min-safe-integer') === -0x1FFFFFFFFFFFFF); ok(load('features/number/parse-float')('1.5') === 1.5); ok(load('features/number/parse-int')('2.1') === 2); ok(load('features/number/to-fixed')(1, 1) === '1.0'); @@ -481,13 +481,13 @@ for (const _PATH of ['../packages/core-js-pure', '../packages/core-js']) { ok(load('stable/math/to-string-tag') === 'Math'); ok(load('stable/math/trunc')(1.5) === 1); ok(load('stable/number/constructor')('5') === 5); - ok(load('stable/number/epsilon') === Math.pow(2, -52)); + ok(load('stable/number/epsilon') === 2 ** -52); ok(load('stable/number/is-finite')(42.5)); ok(load('stable/number/is-integer')(42.5) === false); ok(load('stable/number/is-nan')(NaN)); ok(load('stable/number/is-safe-integer')(42)); - ok(load('stable/number/max-safe-integer') === 0x1fffffffffffff); - ok(load('stable/number/min-safe-integer') === -0x1fffffffffffff); + ok(load('stable/number/max-safe-integer') === 0x1FFFFFFFFFFFFF); + ok(load('stable/number/min-safe-integer') === -0x1FFFFFFFFFFFFF); ok(load('stable/number/parse-float')('1.5') === 1.5); ok(load('stable/number/parse-int')('2.1') === 2); ok(load('stable/number/to-fixed')(1, 1) === '1.0'); @@ -743,13 +743,13 @@ for (const _PATH of ['../packages/core-js-pure', '../packages/core-js']) { ok(load('es/math/to-string-tag') === 'Math'); ok(load('es/math/trunc')(1.5) === 1); ok(load('es/number/constructor')('5') === 5); - ok(load('es/number/epsilon') === Math.pow(2, -52)); + ok(load('es/number/epsilon') === 2 ** -52); ok(load('es/number/is-finite')(42.5)); ok(load('es/number/is-integer')(42.5) === false); ok(load('es/number/is-nan')(NaN)); ok(load('es/number/is-safe-integer')(42)); - ok(load('es/number/max-safe-integer') === 0x1fffffffffffff); - ok(load('es/number/min-safe-integer') === -0x1fffffffffffff); + ok(load('es/number/max-safe-integer') === 0x1FFFFFFFFFFFFF); + ok(load('es/number/min-safe-integer') === -0x1FFFFFFFFFFFFF); ok(load('es/number/parse-float')('1.5') === 1.5); ok(load('es/number/parse-int')('2.1') === 2); ok(load('es/number/to-fixed')(1, 1) === '1.0'); diff --git a/tests/compat/browsers-runner.js b/tests/compat/browsers-runner.js index a2351931f51c..5dae32e5893e 100644 --- a/tests/compat/browsers-runner.js +++ b/tests/compat/browsers-runner.js @@ -9,7 +9,7 @@ for (var key in window.tests) { } else { for (var i = 0; i < test.length; i++) result = result && !!test[i].call(undefined); } - } catch (e) { + } catch (error) { result = false; } diff --git a/tests/compat/node-runner.js b/tests/compat/node-runner.js index 80e622d6c6d8..df3672ec511f 100644 --- a/tests/compat/node-runner.js +++ b/tests/compat/node-runner.js @@ -10,7 +10,7 @@ for (var key in tests) { } else result[key] = test.reduce(function (accumulator, $test) { return accumulator && !!$test(); }, true); - } catch (e) { + } catch (error) { result[key] = false; } } diff --git a/tests/compat/tests.js b/tests/compat/tests.js index b7151676763e..a101cf785dc7 100644 --- a/tests/compat/tests.js +++ b/tests/compat/tests.js @@ -2,12 +2,15 @@ // eslint-disable-next-line no-new-func var GLOBAL = Function('return this')(); // eslint-disable-next-line max-len -var WHITESPACES = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF'; +var WHITESPACES = '\u0009\u000A\u000B\u000C\u000D\u0020\u00A0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF'; -var NOT_WHITESPACES = '\u200b\u0085\u180e'; +var NOT_WHITESPACES = '\u200B\u0085\u180E'; var USERAGENT = GLOBAL.navigator && GLOBAL.navigator.userAgent || ''; +// eslint-disable-next-line unicorn/no-unsafe-regex +var WEBKIT_STRING_PAD_BUG = /Version\/10\.\d+(\.\d+)?( Mobile\/\w+)? Safari\//.test(USERAGENT); + var DESCRIPTORS_SUPPORT = function () { return Object.defineProperty({}, 'a', { get: function () { return 7; } }).a == 7; }; @@ -51,7 +54,7 @@ var URL_AND_URL_SEARCH_PARAMS_SUPPORT = function () { var OBJECT_PROTOTYPE_ACCESSORS_SUPPORT = function () { try { Object.prototype.__defineSetter__.call(null, Math.random(), function () { /* empty */ }); - } catch (e) { + } catch (error) { return Object.prototype.__defineSetter__; } }; @@ -71,8 +74,8 @@ var SAFE_ITERATION_CLOSING_SUPPORT = function () { iteratorWithReturn[Symbol.iterator] = function () { return this; }; - Array.from(iteratorWithReturn, function () { throw Error(); }); - } catch (e) { + Array.from(iteratorWithReturn, function () { throw Error('close'); }); + } catch (error) { return SAFE_CLOSING; } }; @@ -101,10 +104,10 @@ var ARRAY_BUFFER_VIEWS_SUPPORT = function () { var TYPED_ARRAY_CONSTRUCTORS_NOT_REQUIRES_WRAPPERS = function () { try { return !Int8Array(1); - } catch (e) { /* empty */ } + } catch (error) { /* empty */ } try { return !new Int8Array(-1); - } catch (e) { /* empty */ } + } catch (error) { /* empty */ } new Int8Array(); new Int8Array(null); new Int8Array(1.5); @@ -221,7 +224,7 @@ GLOBAL.tests = { try { Array.prototype.every.call(null, function () { /* empty */ }); return false; - } catch (e) { /* empty */ } + } catch (error) { /* empty */ } return Array.prototype.every; }, 'es.array.fill': function () { @@ -255,7 +258,7 @@ GLOBAL.tests = { try { Array.prototype.forEach.call(null, function () { /* empty */ }); return false; - } catch (e) { /* empty */ } + } catch (error) { /* empty */ } return Array.prototype.forEach; }, 'es.array.from': SAFE_ITERATION_CLOSING_SUPPORT, @@ -265,7 +268,7 @@ GLOBAL.tests = { 'es.array.index-of': function () { try { Array.prototype.indexOf.call(null); - } catch (e) { + } catch (error) { return 1 / [1].indexOf(1, -0) > 0; } }, @@ -284,19 +287,19 @@ GLOBAL.tests = { 'es.array.join': function () { try { if (!Object.prototype.propertyIsEnumerable.call(Object('z'), 0)) return false; - } catch (e) { + } catch (error) { return false; } try { Array.prototype.join.call(null); return false; - } catch (e) { /* empty */ } + } catch (error) { /* empty */ } return true; }, 'es.array.last-index-of': function () { try { Array.prototype.lastIndexOf.call(null); - } catch (e) { + } catch (error) { return 1 / [1].lastIndexOf(1, -0) > 0; } }, @@ -315,14 +318,14 @@ GLOBAL.tests = { 'es.array.reduce': function () { try { Array.prototype.reduce.call(null, function () { /* empty */ }, 1); - } catch (e) { + } catch (error) { return Array.prototype.reduce; } }, 'es.array.reduce-right': function () { try { Array.prototype.reduceRight.call(null, function () { /* empty */ }, 1); - } catch (e) { + } catch (error) { return Array.prototype.reduceRight; } }, @@ -341,7 +344,7 @@ GLOBAL.tests = { 'es.array.some': function () { try { Array.prototype.some.call(null, function () { /* empty */ }); - } catch (e) { + } catch (error) { return Array.prototype.some; } }, @@ -377,10 +380,10 @@ GLOBAL.tests = { 'es.array-buffer.constructor': [ARRAY_BUFFER_SUPPORT, function () { try { return !ArrayBuffer(1); - } catch (e) { /* empty */ } + } catch (error) { /* empty */ } try { return !new ArrayBuffer(-1); - } catch (e) { /* empty */ } + } catch (error) { /* empty */ } new ArrayBuffer(); new ArrayBuffer(1.5); new ArrayBuffer(NaN); @@ -399,7 +402,7 @@ GLOBAL.tests = { 'es.date.to-iso-string': function () { try { new Date(NaN).toISOString(); - } catch (e) { + } catch (error) { return new Date(-5e13 - 1).toISOString() == '0385-07-25T07:06:39.999Z'; } }, @@ -478,7 +481,7 @@ GLOBAL.tests = { return Math.hypot; }, 'es.math.imul': function () { - return Math.imul(0xffffffff, 5) == -5 && Math.imul.length == 2; + return Math.imul(0xFFFFFFFF, 5) == -5 && Math.imul.length == 2; }, 'es.math.log10': function () { return Math.log10; @@ -540,7 +543,7 @@ GLOBAL.tests = { 'es.number.to-fixed': function () { try { Number.prototype.toFixed.call({}); - } catch (e) { + } catch (error) { return 0.00008.toFixed(3) === '0.000' && 0.9.toFixed(0) === '1' && 1.255.toFixed(2) === '1.25' @@ -550,7 +553,7 @@ GLOBAL.tests = { 'es.number.to-precision': function () { try { Number.prototype.toPrecision.call({}); - } catch (e) { + } catch (error) { return 1.0.toPrecision(undefined) === '1'; } }, @@ -643,7 +646,7 @@ GLOBAL.tests = { return Reflect.apply(function () { return false; }); - } catch (e) { + } catch (error) { return Reflect.apply(function () { return true; }, null, []); @@ -652,7 +655,7 @@ GLOBAL.tests = { 'es.reflect.construct': function () { try { return !Reflect.construct(function () { /* empty */ }); - } catch (e) { /* empty */ } + } catch (error) { /* empty */ } function F() { /* empty */ } return Reflect.construct(function () { /* empty */ }, [], F) instanceof F; }, @@ -756,12 +759,10 @@ GLOBAL.tests = { return ''.match(O) == 7 && execCalled; }, 'es.string.pad-end': function () { - return String.prototype.padEnd - && !/Version\/10\.\d+(\.\d+)?( Mobile\/\w+)? Safari\//.test(USERAGENT); + return String.prototype.padEnd && !WEBKIT_STRING_PAD_BUG; }, 'es.string.pad-start': function () { - return String.prototype.padStart - && !/Version\/10\.\d+(\.\d+)?( Mobile\/\w+)? Safari\//.test(USERAGENT); + return String.prototype.padStart && !WEBKIT_STRING_PAD_BUG; }, 'es.string.raw': function () { return String.raw; @@ -957,7 +958,7 @@ GLOBAL.tests = { 'es.typed-array.to-locale-string': [ARRAY_BUFFER_VIEWS_SUPPORT, function () { try { Int8Array.prototype.toLocaleString.call([1, 2]); - } catch (e) { + } catch (error) { return [1, 2].toLocaleString() == new Int8Array([1, 2]).toLocaleString(); } }], diff --git a/tests/helpers/constants.js b/tests/helpers/constants.js index bc53031ec289..abe77d5d245c 100644 --- a/tests/helpers/constants.js +++ b/tests/helpers/constants.js @@ -5,7 +5,7 @@ export const DESCRIPTORS = !!(() => { return 7; }, }).a === 7; - } catch (e) { /* empty */ } + } catch (error) { /* empty */ } })(); export const GLOBAL = Function('return this')(); @@ -27,7 +27,7 @@ export const TYPED_ARRAYS = { export const LITTLE_ENDIAN = (() => { try { return new GLOBAL.Uint8Array(new GLOBAL.Uint16Array([1]).buffer)[0] === 1; - } catch (e) { + } catch (error) { return true; } })(); @@ -41,7 +41,7 @@ export const STRICT = !function () { export const FREEZING = !function () { try { return Object.isExtensible(Object.preventExtensions({})); - } catch (e) { + } catch (error) { return true; } }(); @@ -51,10 +51,10 @@ export const CORRECT_PROTOTYPE_GETTER = !function () { function F() { /* empty */ } F.prototype.constructor = null; return Object.getPrototypeOf(new F()) !== F.prototype; - } catch (e) { + } catch (error) { return true; } }(); // eslint-disable-next-line max-len -export const WHITESPACES = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF'; +export const WHITESPACES = '\u0009\u000A\u000B\u000C\u000D\u0020\u00A0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF'; diff --git a/tests/helpers/helpers.js b/tests/helpers/helpers.js index 72eb1af8f0fc..d889f9110a2b 100644 --- a/tests/helpers/helpers.js +++ b/tests/helpers/helpers.js @@ -44,7 +44,7 @@ export const nativeSubclass = (() => { 'use strict'; return class extends Parent { /* empty */ }; `); - } catch (e) { /* empty */ } + } catch (error) { /* empty */ } })(); export function timeLimitedPromise(time, fn) { @@ -68,8 +68,8 @@ export function patchRegExp$exec(run) { return run(assert); // In very old IE try / finally does not work without catch. // eslint-disable-next-line no-useless-catch - } catch (e) { - throw e; + } catch (error) { + throw error; } finally { // eslint-disable-next-line no-extend-native RegExp.prototype.exec = originalExec; diff --git a/tests/helpers/qunit-helpers.js b/tests/helpers/qunit-helpers.js index 15a1d44fd857..759a06468a6e 100644 --- a/tests/helpers/qunit-helpers.js +++ b/tests/helpers/qunit-helpers.js @@ -110,9 +110,9 @@ QUnit.assert.notThrows = function (fn, message) { try { result = fn(); throws = false; - } catch (e) { + } catch (err) { throws = true; - error = e; + error = err; } this.pushResult({ result: !throws && result, diff --git a/tests/pure/es.array.from.js b/tests/pure/es.array.from.js index 60e4372e176c..801ed25e8efe 100644 --- a/tests/pure/es.array.from.js +++ b/tests/pure/es.array.from.js @@ -74,7 +74,7 @@ QUnit.test('Array.from', assert => { }), () => { throw new Error(); }); - } catch (e) { /* empty */ } + } catch (error) { /* empty */ } assert.ok(done, '.return #throw'); class C { /* empty */ } let instance = from.call(C, createIterable([1, 2])); diff --git a/tests/pure/es.map.js b/tests/pure/es.map.js index efdbb1fdde80..f6eb23d97bb3 100644 --- a/tests/pure/es.map.js +++ b/tests/pure/es.map.js @@ -25,7 +25,7 @@ QUnit.test('Map', assert => { return done = true; }, })); - } catch (e) { /* empty */ } + } catch (error) { /* empty */ } assert.ok(done, '.return #throw'); const array = []; done = false; diff --git a/tests/pure/es.math.imul.js b/tests/pure/es.math.imul.js index f7a15ca0391f..6cb9c7028733 100644 --- a/tests/pure/es.math.imul.js +++ b/tests/pure/es.math.imul.js @@ -22,8 +22,8 @@ QUnit.test('Math.imul', assert => { assert.same(imul(7, {}), 0); assert.same(imul([], 7), 0); assert.same(imul(7, []), 0); - assert.strictEqual(imul(0xffffffff, 5), -5); - assert.strictEqual(imul(0xfffffffe, 5), -10); + assert.strictEqual(imul(0xFFFFFFFF, 5), -5); + assert.strictEqual(imul(0xFFFFFFFE, 5), -10); assert.strictEqual(imul(2, 4), 8); assert.strictEqual(imul(-1, 8), -8); assert.strictEqual(imul(-2, -2), 4); diff --git a/tests/pure/es.object.assign.js b/tests/pure/es.object.assign.js index 472c7ba3dd55..81cde26de0c4 100644 --- a/tests/pure/es.object.assign.js +++ b/tests/pure/es.object.assign.js @@ -41,7 +41,7 @@ QUnit.test('Object.assign', assert => { delete this.b; }, b: 2 }); `)(assign).b, 1); - } catch (e) { /* empty */ } + } catch (error) { /* empty */ } try { assert.strictEqual(Function('assign', ` return assign({ b: 1 }, { get a() { @@ -51,7 +51,7 @@ QUnit.test('Object.assign', assert => { }); }, b: 2 }); `)(assign).b, 1); - } catch (e) { /* empty */ } + } catch (error) { /* empty */ } } string = 'abcdefghijklmnopqrst'; const result = {}; diff --git a/tests/pure/es.object.entries.js b/tests/pure/es.object.entries.js index 4cdc4911bd42..a2e0675363e6 100644 --- a/tests/pure/es.object.entries.js +++ b/tests/pure/es.object.entries.js @@ -14,7 +14,7 @@ QUnit.test('Object.entries', assert => { return 2; }, c: 3 }); `)(entries), [['a', 1], ['b', 2]]); - } catch (e) { /* empty */ } + } catch (error) { /* empty */ } try { assert.deepEqual(Function('entries', ` return entries({ a: 1, get b() { @@ -25,5 +25,5 @@ QUnit.test('Object.entries', assert => { return 2 }, c: 3 }); `)(entries), [['a', 1], ['b', 2]]); - } catch (e) { /* empty */ } + } catch (error) { /* empty */ } }); diff --git a/tests/pure/es.object.values.js b/tests/pure/es.object.values.js index a4b868673ef6..0f261b34350f 100644 --- a/tests/pure/es.object.values.js +++ b/tests/pure/es.object.values.js @@ -14,7 +14,7 @@ QUnit.test('Object.values', assert => { return 2; }, c: 3 }); `)(values), [1, 2]); - } catch (e) { /* empty */ } + } catch (error) { /* empty */ } try { assert.deepEqual(Function('values', ` return values({ a: 1, get b() { @@ -25,5 +25,5 @@ QUnit.test('Object.values', assert => { return 2; }, c: 3 }); `)(values), [1, 2]); - } catch (e) { /* empty */ } + } catch (error) { /* empty */ } }); diff --git a/tests/pure/es.promise.js b/tests/pure/es.promise.js index 588ad04b8a42..6e9d0fcb4c79 100644 --- a/tests/pure/es.promise.js +++ b/tests/pure/es.promise.js @@ -194,7 +194,7 @@ QUnit.test('Promise.all', assert => { done = true; }, })).catch(() => { /* empty */ }); - } catch (e) { /* empty */ } + } catch (error) { /* empty */ } Promise.resolve = resolve; assert.ok(done, 'iteration closing'); let FakePromise1 = function (executor) { @@ -254,7 +254,7 @@ QUnit.test('Promise.race', assert => { done = true; }, })).catch(() => { /* empty */ }); - } catch (e) { /* empty */ } + } catch (error) { /* empty */ } Promise.resolve = resolve; assert.ok(done, 'iteration closing'); let FakePromise1 = function (executor) { diff --git a/tests/pure/es.set.js b/tests/pure/es.set.js index 74815add5209..9b3d80278668 100644 --- a/tests/pure/es.set.js +++ b/tests/pure/es.set.js @@ -43,7 +43,7 @@ QUnit.test('Set', assert => { return done = true; }, })); - } catch (e) { /* empty */ } + } catch (error) { /* empty */ } Set.prototype.add = add; assert.ok(done, '.return #throw'); const array = []; diff --git a/tests/pure/es.string.trim-end.js b/tests/pure/es.string.trim-end.js index 90eb3e14e2ef..17e580e33033 100644 --- a/tests/pure/es.string.trim-end.js +++ b/tests/pure/es.string.trim-end.js @@ -6,7 +6,7 @@ QUnit.test('String#trimRight', assert => { assert.isFunction(trimRight); assert.strictEqual(trimRight(' \n q w e \n '), ' \n q w e', 'removes whitespaces at right side of string'); assert.strictEqual(trimRight(WHITESPACES), '', 'removes all whitespaces'); - assert.strictEqual(trimRight('\u200b\u0085'), '\u200b\u0085', "shouldn't remove this symbols"); + assert.strictEqual(trimRight('\u200B\u0085'), '\u200B\u0085', "shouldn't remove this symbols"); if (STRICT) { assert.throws(() => trimRight(null, 0), TypeError); assert.throws(() => trimRight(undefined, 0), TypeError); @@ -17,7 +17,7 @@ QUnit.test('String#trimEnd', assert => { assert.isFunction(trimEnd); assert.strictEqual(trimEnd(' \n q w e \n '), ' \n q w e', 'removes whitespaces at right side of string'); assert.strictEqual(trimEnd(WHITESPACES), '', 'removes all whitespaces'); - assert.strictEqual(trimEnd('\u200b\u0085'), '\u200b\u0085', "shouldn't remove this symbols"); + assert.strictEqual(trimEnd('\u200B\u0085'), '\u200B\u0085', "shouldn't remove this symbols"); if (STRICT) { assert.throws(() => trimEnd(null, 0), TypeError); assert.throws(() => trimEnd(undefined, 0), TypeError); diff --git a/tests/pure/es.string.trim-start.js b/tests/pure/es.string.trim-start.js index 36d24d8c9cae..1001e7decf97 100644 --- a/tests/pure/es.string.trim-start.js +++ b/tests/pure/es.string.trim-start.js @@ -6,7 +6,7 @@ QUnit.test('String#trimLeft', assert => { assert.isFunction(trimLeft); assert.strictEqual(trimLeft(' \n q w e \n '), 'q w e \n ', 'removes whitespaces at left side of string'); assert.strictEqual(trimLeft(WHITESPACES), '', 'removes all whitespaces'); - assert.strictEqual(trimLeft('\u200b\u0085'), '\u200b\u0085', "shouldn't remove this symbols"); + assert.strictEqual(trimLeft('\u200B\u0085'), '\u200B\u0085', "shouldn't remove this symbols"); if (STRICT) { assert.throws(() => trimLeft(null, 0), TypeError); assert.throws(() => trimLeft(undefined, 0), TypeError); @@ -17,7 +17,7 @@ QUnit.test('String#trimStart', assert => { assert.isFunction(trimStart); assert.strictEqual(trimStart(' \n q w e \n '), 'q w e \n ', 'removes whitespaces at left side of string'); assert.strictEqual(trimStart(WHITESPACES), '', 'removes all whitespaces'); - assert.strictEqual(trimStart('\u200b\u0085'), '\u200b\u0085', "shouldn't remove this symbols"); + assert.strictEqual(trimStart('\u200B\u0085'), '\u200B\u0085', "shouldn't remove this symbols"); if (STRICT) { assert.throws(() => trimStart(null, 0), TypeError); assert.throws(() => trimStart(undefined, 0), TypeError); diff --git a/tests/pure/es.string.trim.js b/tests/pure/es.string.trim.js index 72f02bfa53bd..92bffbbd94e3 100644 --- a/tests/pure/es.string.trim.js +++ b/tests/pure/es.string.trim.js @@ -6,7 +6,7 @@ QUnit.test('String#trim', assert => { assert.isFunction(trim); assert.strictEqual(trim(' \n q w e \n '), 'q w e', 'removes whitespaces at left & right side of string'); assert.strictEqual(trim(WHITESPACES), '', 'removes all whitespaces'); - assert.strictEqual(trim('\u200b\u0085'), '\u200b\u0085', "shouldn't remove this symbols"); + assert.strictEqual(trim('\u200B\u0085'), '\u200B\u0085', "shouldn't remove this symbols"); if (STRICT) { assert.throws(() => trim(null, 0), TypeError); assert.throws(() => trim(undefined, 0), TypeError); diff --git a/tests/pure/es.weak-map.js b/tests/pure/es.weak-map.js index 2eda0cb7f7e2..655c86356267 100644 --- a/tests/pure/es.weak-map.js +++ b/tests/pure/es.weak-map.js @@ -33,7 +33,7 @@ QUnit.test('WeakMap', assert => { return done = true; }, })); - } catch (e) { /* empty */ } + } catch (error) { /* empty */ } assert.ok(done, '.return #throw'); assert.ok(!('clear' in WeakMap.prototype), 'should not contains `.clear` method'); const array = []; diff --git a/tests/pure/es.weak-set.js b/tests/pure/es.weak-set.js index 82e9700e19fc..4d8920359514 100644 --- a/tests/pure/es.weak-set.js +++ b/tests/pure/es.weak-set.js @@ -27,7 +27,7 @@ QUnit.test('WeakSet', assert => { return done = true; }, })); - } catch (e) { /* empty */ } + } catch (error) { /* empty */ } assert.ok(done, '.return #throw'); assert.ok(!('clear' in WeakSet.prototype), 'should not contains `.clear` method'); const array = []; diff --git a/tests/pure/esnext.math.iaddh.js b/tests/pure/esnext.math.iaddh.js index 5e4e9b5083fe..a2c72112936d 100644 --- a/tests/pure/esnext.math.iaddh.js +++ b/tests/pure/esnext.math.iaddh.js @@ -6,6 +6,6 @@ QUnit.test('Math.iaddh', assert => { assert.same(iaddh(0, 2, 1, 0), 2); assert.same(iaddh(0, 4, 1, 1), 5); assert.same(iaddh(2, 4, 1, 1), 5); - assert.same(iaddh(0xffffffff, 4, 1, 1), 6); - assert.same(iaddh(1, 4, 0xffffffff, 1), 6); + assert.same(iaddh(0xFFFFFFFF, 4, 1, 1), 6); + assert.same(iaddh(1, 4, 0xFFFFFFFF, 1), 6); }); diff --git a/tests/pure/esnext.math.imulh.js b/tests/pure/esnext.math.imulh.js index e668fb3f902f..7a6444911875 100644 --- a/tests/pure/esnext.math.imulh.js +++ b/tests/pure/esnext.math.imulh.js @@ -3,8 +3,8 @@ import imulh from 'core-js-pure/features/math/imulh'; QUnit.test('Math.imulh', assert => { assert.isFunction(imulh); assert.arity(imulh, 2); - assert.same(imulh(0xffffffff, 7), -1); - assert.same(imulh(0xfffffff, 77), 4); + assert.same(imulh(0xFFFFFFFF, 7), -1); + assert.same(imulh(0xFFFFFFF, 77), 4); assert.same(imulh(1, 7), 0); assert.same(imulh(-1, 7), -1); }); diff --git a/tests/pure/esnext.math.isubh.js b/tests/pure/esnext.math.isubh.js index fb3a12f091fa..38da3102ae0b 100644 --- a/tests/pure/esnext.math.isubh.js +++ b/tests/pure/esnext.math.isubh.js @@ -6,6 +6,6 @@ QUnit.test('Math.isubh', assert => { assert.same(isubh(0, 2, 1, 0), 1); assert.same(isubh(0, 4, 1, 1), 2); assert.same(isubh(2, 4, 1, 1), 3); - assert.same(isubh(0xffffffff, 4, 1, 1), 3); - assert.same(isubh(1, 4, 0xffffffff, 1), 2); + assert.same(isubh(0xFFFFFFFF, 4, 1, 1), 3); + assert.same(isubh(1, 4, 0xFFFFFFFF, 1), 2); }); diff --git a/tests/pure/esnext.math.umulh.js b/tests/pure/esnext.math.umulh.js index a9c06c4df684..868734f362eb 100644 --- a/tests/pure/esnext.math.umulh.js +++ b/tests/pure/esnext.math.umulh.js @@ -3,8 +3,8 @@ import umulh from 'core-js-pure/features/math/umulh'; QUnit.test('Math.umulh', assert => { assert.isFunction(umulh); assert.arity(umulh, 2); - assert.same(umulh(0xffffffff, 7), 6); - assert.same(umulh(0xfffffff, 77), 4); + assert.same(umulh(0xFFFFFFFF, 7), 6); + assert.same(umulh(0xFFFFFFF, 77), 4); assert.same(umulh(1, 7), 0); assert.same(umulh(-1, 7), 6); }); diff --git a/tests/pure/esnext.promise.any.js b/tests/pure/esnext.promise.any.js index 520a1a9177be..613d6239c7ff 100644 --- a/tests/pure/esnext.promise.any.js +++ b/tests/pure/esnext.promise.any.js @@ -26,9 +26,9 @@ QUnit.test('Promise.any, rejected #1', assert => { Promise.reject(1), Promise.reject(2), Promise.reject(3), - ]).catch(it => { - assert.ok(it instanceof AggregateError, 'instanceof AggregateError'); - assert.deepEqual(it.errors, [1, 2, 3], 'rejected with a correct value'); + ]).catch(error => { + assert.ok(error instanceof AggregateError, 'instanceof AggregateError'); + assert.deepEqual(error.errors, [1, 2, 3], 'rejected with a correct value'); async(); }); }); @@ -45,9 +45,9 @@ QUnit.test('Promise.any, rejected #2', assert => { QUnit.test('Promise.any, rejected #3', assert => { assert.expect(2); const async = assert.async(); - Promise.any([]).catch(it => { - assert.ok(it instanceof AggregateError, 'instanceof AggregateError'); - assert.deepEqual(it.errors, [], 'rejected with a correct value'); + Promise.any([]).catch(error => { + assert.ok(error instanceof AggregateError, 'instanceof AggregateError'); + assert.deepEqual(error.errors, [], 'rejected with a correct value'); async(); }); }); diff --git a/tests/pure/web.timers.js b/tests/pure/web.timers.js index ebe20a78ac09..4fdb1e15a517 100644 --- a/tests/pure/web.timers.js +++ b/tests/pure/web.timers.js @@ -5,16 +5,16 @@ import { setTimeout, setInterval } from 'core-js-pure'; QUnit.test('setTimeout / clearTimeout', assert => { assert.expect(2); - timeLimitedPromise(1e3, res => { - setTimeout((a, b) => { res(a + b); }, 10, 'a', 'b'); + timeLimitedPromise(1e3, resolve => { + setTimeout((a, b) => { resolve(a + b); }, 10, 'a', 'b'); }).then(it => { assert.strictEqual(it, 'ab', 'setTimeout works with additional args'); }).catch(() => { assert.ok(false, 'setTimeout works with additional args'); }).then(assert.async()); - timeLimitedPromise(50, res => { - clearTimeout(setTimeout(res, 10)); + timeLimitedPromise(50, resolve => { + clearTimeout(setTimeout(resolve, 10)); }).then(() => { assert.ok(false, 'clearImmediate works with wraped setTimeout'); }).catch(() => { @@ -25,19 +25,19 @@ QUnit.test('setTimeout / clearTimeout', assert => { QUnit.test('setInterval / clearInterval', assert => { assert.expect(1); - timeLimitedPromise(1e4, (res, rej) => { + timeLimitedPromise(1e4, (resolve, reject) => { let i = 0; const interval = setInterval((a, b) => { - if (a + b !== 'ab' || i > 2) rej({ a, b, i }); + if (a + b !== 'ab' || i > 2) reject({ a, b, i }); if (i++ === 2) { clearInterval(interval); - setTimeout(res, 30); + setTimeout(resolve, 30); } }, 5, 'a', 'b'); }).then(() => { assert.ok(true, 'setInterval & clearInterval works with additional args'); - }).catch(args => { - if (!args) args = {}; - assert.ok(false, `setInterval & clearInterval works with additional args: ${ args.a }, ${ args.b }, times: ${ args.i }`); + }).catch(error => { + if (!error) error = {}; + assert.ok(false, `setInterval & clearInterval works with additional args: ${ error.a }, ${ error.b }, times: ${ error.i }`); }).then(assert.async()); }); diff --git a/tests/tests/es.array.from.js b/tests/tests/es.array.from.js index 11d50e68a003..01d79be63f23 100644 --- a/tests/tests/es.array.from.js +++ b/tests/tests/es.array.from.js @@ -75,7 +75,7 @@ QUnit.test('Array.from', assert => { }), () => { throw new Error(); }); - } catch (e) { /* empty */ } + } catch (error) { /* empty */ } assert.ok(done, '.return #throw'); class C { /* empty */ } let instance = from.call(C, createIterable([1, 2])); diff --git a/tests/tests/es.data-view.js b/tests/tests/es.data-view.js index ea3e881a4e19..18601e44c22e 100644 --- a/tests/tests/es.data-view.js +++ b/tests/tests/es.data-view.js @@ -59,21 +59,21 @@ if (DESCRIPTORS) { const dataview = new DataView(uint8array.buffer); assert.arrayEqual(uint8array, [0, 0, 0, 0, 0, 0, 0, 0]); dataview.setUint8(0, 255); - assert.arrayEqual(uint8array, [0xff, 0, 0, 0, 0, 0, 0, 0]); + assert.arrayEqual(uint8array, [0xFF, 0, 0, 0, 0, 0, 0, 0]); dataview.setInt8(1, -1); - assert.arrayEqual(uint8array, [0xff, 0xff, 0, 0, 0, 0, 0, 0]); + assert.arrayEqual(uint8array, [0xFF, 0xFF, 0, 0, 0, 0, 0, 0]); dataview.setUint16(2, 0x1234); - assert.arrayEqual(uint8array, [0xff, 0xff, 0x12, 0x34, 0, 0, 0, 0]); + assert.arrayEqual(uint8array, [0xFF, 0xFF, 0x12, 0x34, 0, 0, 0, 0]); dataview.setInt16(4, -1); - assert.arrayEqual(uint8array, [0xff, 0xff, 0x12, 0x34, 0xff, 0xff, 0, 0]); + assert.arrayEqual(uint8array, [0xFF, 0xFF, 0x12, 0x34, 0xFF, 0xFF, 0, 0]); dataview.setUint32(1, 0x12345678); - assert.arrayEqual(uint8array, [0xff, 0x12, 0x34, 0x56, 0x78, 0xff, 0, 0]); + assert.arrayEqual(uint8array, [0xFF, 0x12, 0x34, 0x56, 0x78, 0xFF, 0, 0]); dataview.setInt32(4, -2023406815); - assert.arrayEqual(uint8array, [0xff, 0x12, 0x34, 0x56, 0x87, 0x65, 0x43, 0x21]); + assert.arrayEqual(uint8array, [0xFF, 0x12, 0x34, 0x56, 0x87, 0x65, 0x43, 0x21]); dataview.setFloat32(2, 1.2e+38); - assert.arrayEqual(uint8array, [0xff, 0x12, 0x7e, 0xb4, 0x8e, 0x52, 0x43, 0x21]); + assert.arrayEqual(uint8array, [0xFF, 0x12, 0x7E, 0xB4, 0x8E, 0x52, 0x43, 0x21]); dataview.setFloat64(0, -1.2345678e+301); - assert.arrayEqual(uint8array, [0xfe, 0x72, 0x6f, 0x51, 0x5f, 0x61, 0x77, 0xe5]); + assert.arrayEqual(uint8array, [0xFE, 0x72, 0x6F, 0x51, 0x5F, 0x61, 0x77, 0xE5]); const data = [0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87]; for (let i = 0, { length } = data; i < length; ++i) { uint8array[i] = data[i]; diff --git a/tests/tests/es.map.js b/tests/tests/es.map.js index 52d4224ceb70..6b00701dbabc 100644 --- a/tests/tests/es.map.js +++ b/tests/tests/es.map.js @@ -26,7 +26,7 @@ QUnit.test('Map', assert => { return done = true; }, })); - } catch (e) { /* empty */ } + } catch (error) { /* empty */ } assert.ok(done, '.return #throw'); const array = []; done = false; diff --git a/tests/tests/es.math.imul.js b/tests/tests/es.math.imul.js index 59ac9bb5c559..787376d17b2d 100644 --- a/tests/tests/es.math.imul.js +++ b/tests/tests/es.math.imul.js @@ -25,8 +25,8 @@ QUnit.test('Math.imul', assert => { assert.same(imul(7, {}), 0); assert.same(imul([], 7), 0); assert.same(imul(7, []), 0); - assert.strictEqual(imul(0xffffffff, 5), -5); - assert.strictEqual(imul(0xfffffffe, 5), -10); + assert.strictEqual(imul(0xFFFFFFFF, 5), -5); + assert.strictEqual(imul(0xFFFFFFFE, 5), -10); assert.strictEqual(imul(2, 4), 8); assert.strictEqual(imul(-1, 8), -8); assert.strictEqual(imul(-2, -2), 4); diff --git a/tests/tests/es.number.constructor.js b/tests/tests/es.number.constructor.js index d16b535e73fe..e5a638fff9e9 100644 --- a/tests/tests/es.number.constructor.js +++ b/tests/tests/es.number.constructor.js @@ -1,5 +1,5 @@ import { nativeSubclass } from '../helpers/helpers'; -const whitespaces = ' \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000'; +const whitespaces = ' \t\u000B\f\u00A0\uFEFF\n\r\u2028\u2029\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000'; function getCheck(assert) { return function (a, b) { diff --git a/tests/tests/es.object.assign.js b/tests/tests/es.object.assign.js index f17001643657..bbfa6e481114 100644 --- a/tests/tests/es.object.assign.js +++ b/tests/tests/es.object.assign.js @@ -43,7 +43,7 @@ QUnit.test('Object.assign', assert => { delete this.b; }, b: 2 }); `)(assign).b, 1); - } catch (e) { /* empty */ } + } catch (error) { /* empty */ } try { assert.strictEqual(Function('assign', ` return assign({ b: 1 }, { get a() { @@ -53,7 +53,7 @@ QUnit.test('Object.assign', assert => { }); }, b: 2 }); `)(assign).b, 1); - } catch (e) { /* empty */ } + } catch (error) { /* empty */ } } string = 'abcdefghijklmnopqrst'; const result = {}; diff --git a/tests/tests/es.object.entries.js b/tests/tests/es.object.entries.js index 1b7e8ce5be7a..abe7ebd9f21c 100644 --- a/tests/tests/es.object.entries.js +++ b/tests/tests/es.object.entries.js @@ -19,7 +19,7 @@ QUnit.test('Object.entries', assert => { c: 3 }); `)(entries), [['a', 1], ['b', 2]]); - } catch (e) { /* empty */ } + } catch (error) { /* empty */ } try { assert.deepEqual(Function('entries', ` return entries({ @@ -34,5 +34,5 @@ QUnit.test('Object.entries', assert => { c: 3 }); `)(entries), [['a', 1], ['b', 2]]); - } catch (e) { /* empty */ } + } catch (error) { /* empty */ } }); diff --git a/tests/tests/es.object.values.js b/tests/tests/es.object.values.js index 80d65243b8d6..399205aaa758 100644 --- a/tests/tests/es.object.values.js +++ b/tests/tests/es.object.values.js @@ -15,7 +15,7 @@ QUnit.test('Object.values', assert => { return 2; }, c: 3 }); `)(values), [1, 2]); - } catch (e) { /* empty */ } + } catch (error) { /* empty */ } try { assert.deepEqual(Function('values', ` return values({ a: 1, get b() { @@ -26,5 +26,5 @@ QUnit.test('Object.values', assert => { return 2; }, c: 3 }); `)(values), [1, 2]); - } catch (e) { /* empty */ } + } catch (error) { /* empty */ } }); diff --git a/tests/tests/es.promise.js b/tests/tests/es.promise.js index 23f4745ffa1d..683251f7d587 100644 --- a/tests/tests/es.promise.js +++ b/tests/tests/es.promise.js @@ -205,7 +205,7 @@ QUnit.test('Promise.all', assert => { done = true; }, })).catch(() => { /* empty */ }); - } catch (e) { /* empty */ } + } catch (error) { /* empty */ } Promise.resolve = resolve; assert.ok(done, 'iteration closing'); FakePromise1 = function (executor) { @@ -269,7 +269,7 @@ QUnit.test('Promise.race', assert => { done = true; }, })).catch(() => { /* empty */ }); - } catch (e) { /* empty */ } + } catch (error) { /* empty */ } Promise.resolve = resolve; assert.ok(done, 'iteration closing'); FakePromise1 = function (executor) { diff --git a/tests/tests/es.set.js b/tests/tests/es.set.js index 9cac2d2862c4..a117a7e4d0b1 100644 --- a/tests/tests/es.set.js +++ b/tests/tests/es.set.js @@ -45,7 +45,7 @@ QUnit.test('Set', assert => { return done = true; }, })); - } catch (e) { /* empty */ } + } catch (error) { /* empty */ } // eslint-disable-next-line no-extend-native Set.prototype.add = add; assert.ok(done, '.return #throw'); diff --git a/tests/tests/es.string.match.js b/tests/tests/es.string.match.js index c675c495ce90..d2d9c286769c 100644 --- a/tests/tests/es.string.match.js +++ b/tests/tests/es.string.match.js @@ -1,5 +1,5 @@ // TODO: fix escaping in regexps -/* eslint-disable no-useless-escape */ +/* eslint-disable no-useless-escape, unicorn/no-unsafe-regex */ import { GLOBAL, NATIVE, STRICT } from '../helpers/constants'; import { patchRegExp$exec } from '../helpers/helpers'; @@ -42,8 +42,8 @@ const run = assert => { try { string.match(object); assert.ok(false, 'S15.5.4.10_A1_T11 #1 lead to throwing exception'); - } catch (e) { - assert.strictEqual(e.message, 'intostr', `S15.5.4.10_A1_T11 #1.1: Exception === "intostr". Actual: ${ e }`); + } catch (error) { + assert.strictEqual(error.message, 'intostr', `S15.5.4.10_A1_T11 #1.1: Exception === "intostr". Actual: ${ error }`); } object = { toString() { @@ -57,8 +57,8 @@ const run = assert => { try { string.match(object); assert.ok(false, 'S15.5.4.10_A1_T12 #1 lead to throwing exception'); - } catch (e) { - assert.strictEqual(e.message, 'intostr', `S15.5.4.10_A1_T12 #1.1: Exception === "intostr". Actual: ${ e }`); + } catch (error) { + assert.strictEqual(error.message, 'intostr', `S15.5.4.10_A1_T12 #1.1: Exception === "intostr". Actual: ${ error }`); } object = { toString() { diff --git a/tests/tests/es.string.replace.js b/tests/tests/es.string.replace.js index 5f08a7d02119..bcfaf997905f 100644 --- a/tests/tests/es.string.replace.js +++ b/tests/tests/es.string.replace.js @@ -43,8 +43,8 @@ const run = assert => { }, }); assert.ok(false, 'S15.5.4.11_A1_T11 #1 lead to throwing exception'); - } catch (e) { - assert.strictEqual(e.message, 'insearchValue', 'S15.5.4.11_A1_T11 #2'); + } catch (error) { + assert.strictEqual(error.message, 'insearchValue', 'S15.5.4.11_A1_T11 #2'); } try { Object('ABB\u0041BABAB').replace({ @@ -60,8 +60,8 @@ const run = assert => { }, }); assert.ok(false, 'S15.5.4.11_A1_T12 #1 lead to throwing exception'); - } catch (e) { - assert.strictEqual(e.message, 'insearchValue', 'S15.5.4.11_A1_T12 #2'); + } catch (error) { + assert.strictEqual(error.message, 'insearchValue', 'S15.5.4.11_A1_T12 #2'); } } try { @@ -78,8 +78,8 @@ const run = assert => { }, }); assert.ok(false, 'S15.5.4.11_A1_T13 #1 lead to throwing exception'); - } catch (e) { - assert.strictEqual(e.message, 'insearchValue', 'S15.5.4.11_A1_T13 #2'); + } catch (error) { + assert.strictEqual(error.message, 'insearchValue', 'S15.5.4.11_A1_T13 #2'); } assert.strictEqual('ABB\u0041BABAB\u0037\u0037BBAA'.replace(new RegExp('77'), 1), 'ABBABABAB\u0031BBAA', 'S15.5.4.11_A1_T14'); instance = Object(1100.00777001); @@ -91,8 +91,8 @@ const run = assert => { }, }, 1); assert.ok(false, 'S15.5.4.11_A1_T15 #1 lead to throwing exception'); - } catch (e) { - assert.ok(e instanceof TypeError, 'S15.5.4.11_A1_T15 #2'); + } catch (error) { + assert.ok(error instanceof TypeError, 'S15.5.4.11_A1_T15 #2'); } instance = Object(1100.00777001); instance.replace = String.prototype.replace; @@ -103,8 +103,8 @@ const run = assert => { }, }); assert.ok(false, 'S15.5.4.11_A1_T16 #1 lead to throwing exception'); - } catch (e) { - assert.ok(e instanceof TypeError, 'S15.5.4.11_A1_T16 #2'); + } catch (error) { + assert.ok(error instanceof TypeError, 'S15.5.4.11_A1_T16 #2'); } assert.strictEqual('asdf'.replace(RegExp('', 'g'), '1'), '1a1s1d1f1', 'S15.5.4.11_A1_T17'); assert.strictEqual('She sells seashells by the seashore.'.replace(/sh/g, 'sch'), 'She sells seaschells by the seaschore.', 'S15.5.4.11_A2_T1'); @@ -124,7 +124,7 @@ const run = assert => { assert.strictEqual('She sells seashells by the seashore.'.replace(/sh/, "$'sch"), 'She sells seaells by the seashore.schells by the seashore.', 'S15.5.4.11_A2_T10'); assert.strictEqual('uid=31'.replace(/(uid=)(\d+)/, '$1115'), 'uid=115', 'S15.5.4.11_A3_T1'); assert.strictEqual('uid=31'.replace(/(uid=)(\d+)/, '$11A15'), 'uid=1A15', 'S15.5.4.11_A3_T3'); - assert.strictEqual('abc12 def34'.replace(/([a-z]+)([0-9]+)/, (a, b, c) => c + b), '12abc def34', 'S15.5.4.11_A4_T1'); + assert.strictEqual('abc12 def34'.replace(/([a-z]+)(\d+)/, (a, b, c) => c + b), '12abc def34', 'S15.5.4.11_A4_T1'); assert.strictEqual('aaaaaaaaaa,aaaaaaaaaaaaaaa'.replace(/^(a+)\1*,\1+$/, '$1'), 'aaaaa', 'S15.5.4.11_A5_T1'); // https://github.com/zloirock/core-js/issues/471 @@ -144,7 +144,7 @@ QUnit.test('RegExp#@@replace appearance', assert => { }); QUnit.test('RegExp#@@replace basic behavior', assert => { - assert.strictEqual(/([a-z]+)([0-9]+)/[Symbol.replace]('abc12 def34', (a, b, c) => c + b), '12abc def34'); + assert.strictEqual(/([a-z]+)(\d+)/[Symbol.replace]('abc12 def34', (a, b, c) => c + b), '12abc def34'); }); QUnit.test('String.replace delegates to @@replace', assert => { diff --git a/tests/tests/es.string.search.js b/tests/tests/es.string.search.js index 3672fcf32c52..096f914adcde 100644 --- a/tests/tests/es.string.search.js +++ b/tests/tests/es.string.search.js @@ -35,8 +35,8 @@ const run = assert => { }, }); assert.ok(false, 'S15.5.4.12_A1_T11 #1 lead to throwing exception'); - } catch (e) { - assert.strictEqual(e.message, 'intostr', 'S15.5.4.12_A1_T11 #2'); + } catch (error) { + assert.strictEqual(error.message, 'intostr', 'S15.5.4.12_A1_T11 #2'); } try { Object('ABB\u0041BABAB').search({ @@ -48,8 +48,8 @@ const run = assert => { }, }); assert.ok(false, 'S15.5.4.12_A1_T12 #1 lead to throwing exception'); - } catch (e) { - assert.strictEqual(e.message, 'intostr', 'S15.5.4.12_A1_T12 #2'); + } catch (error) { + assert.strictEqual(error.message, 'intostr', 'S15.5.4.12_A1_T12 #2'); } assert.strictEqual('ABB\u0041B\u0031ABAB\u0031BBAA'.search({ toString() { diff --git a/tests/tests/es.string.split.js b/tests/tests/es.string.split.js index 2edb629eeb82..044f1a73efde 100644 --- a/tests/tests/es.string.split.js +++ b/tests/tests/es.string.split.js @@ -150,8 +150,8 @@ const run = assert => { }, }); assert.ok(false, 'S15.5.4.14_A1_T11 #1 lead to throwing exception'); - } catch (e) { - assert.strictEqual(e.message, 'intointeger', 'S15.5.4.14_A1_T11 #2'); + } catch (error) { + assert.strictEqual(error.message, 'intointeger', 'S15.5.4.14_A1_T11 #2'); } if (NATIVE) { try { @@ -168,8 +168,8 @@ const run = assert => { }, }); assert.ok(false, 'S15.5.4.14_A1_T12 #1 lead to throwing exception'); - } catch (e) { - assert.strictEqual(e.message, 'intointeger', 'S15.5.4.14_A1_T12 #2'); + } catch (error) { + assert.strictEqual(error.message, 'intointeger', 'S15.5.4.14_A1_T12 #2'); } } split = 'ABB\u0041BABAB\u0042cc^^\u0042Bvv%%B\u0042xxx'.split({ @@ -203,8 +203,8 @@ const run = assert => { }, }); assert.ok(false, 'S15.5.4.14_A1_T14 #1 lead to throwing exception'); - } catch (e) { - assert.strictEqual(e.message, 'intoint', 'S15.5.4.14_A1_T14 #2'); + } catch (error) { + assert.strictEqual(error.message, 'intoint', 'S15.5.4.14_A1_T14 #2'); } try { class F { @@ -232,8 +232,8 @@ const run = assert => { }, }); assert.ok(false, 'S15.5.4.14_A1_T15 #1 lead to throwing exception'); - } catch (e) { - assert.strictEqual(e.message, 'intoint', 'S15.5.4.14_A1_T15 #2'); + } catch (error) { + assert.strictEqual(error.message, 'intoint', 'S15.5.4.14_A1_T15 #2'); } } try { @@ -243,8 +243,8 @@ const run = assert => { }, }); assert.ok(false, 'S15.5.4.14_A1_T16 #1 lead to throwing exception'); - } catch (e) { - assert.ok(e instanceof TypeError, 'S15.5.4.14_A1_T16 #2'); + } catch (error) { + assert.ok(error instanceof TypeError, 'S15.5.4.14_A1_T16 #2'); } split = String.prototype.split.call(6776767677.006771122677555, /\u0037\u0037/g); assert.strictEqual(typeof split, 'object', 'S15.5.4.14_A1_T17 #1'); diff --git a/tests/tests/es.string.trim-end.js b/tests/tests/es.string.trim-end.js index 9ab717a0298b..11407275bbfa 100644 --- a/tests/tests/es.string.trim-end.js +++ b/tests/tests/es.string.trim-end.js @@ -9,7 +9,7 @@ QUnit.test('String#trimRight', assert => { assert.nonEnumerable(String.prototype, 'trimRight'); assert.strictEqual(' \n q w e \n '.trimRight(), ' \n q w e', 'removes whitespaces at right side of string'); assert.strictEqual(WHITESPACES.trimRight(), '', 'removes all whitespaces'); - assert.strictEqual('\u200b\u0085'.trimRight(), '\u200b\u0085', "shouldn't remove this symbols"); + assert.strictEqual('\u200B\u0085'.trimRight(), '\u200B\u0085', "shouldn't remove this symbols"); if (STRICT) { assert.throws(() => trimRight.call(null, 0), TypeError); assert.throws(() => trimRight.call(undefined, 0), TypeError); @@ -26,7 +26,7 @@ QUnit.test('String#trimEnd', assert => { assert.same(trimEnd, String.prototype.trimRight, 'same #trimRight'); assert.strictEqual(' \n q w e \n '.trimEnd(), ' \n q w e', 'removes whitespaces at right side of string'); assert.strictEqual(WHITESPACES.trimEnd(), '', 'removes all whitespaces'); - assert.strictEqual('\u200b\u0085'.trimEnd(), '\u200b\u0085', "shouldn't remove this symbols"); + assert.strictEqual('\u200B\u0085'.trimEnd(), '\u200B\u0085', "shouldn't remove this symbols"); if (STRICT) { assert.throws(() => trimEnd.call(null, 0), TypeError); assert.throws(() => trimEnd.call(undefined, 0), TypeError); diff --git a/tests/tests/es.string.trim-start.js b/tests/tests/es.string.trim-start.js index d6388acfa4b3..2bfd7843f164 100644 --- a/tests/tests/es.string.trim-start.js +++ b/tests/tests/es.string.trim-start.js @@ -9,7 +9,7 @@ QUnit.test('String#trimLeft', assert => { assert.nonEnumerable(String.prototype, 'trimLeft'); assert.strictEqual(' \n q w e \n '.trimLeft(), 'q w e \n ', 'removes whitespaces at left side of string'); assert.strictEqual(WHITESPACES.trimLeft(), '', 'removes all whitespaces'); - assert.strictEqual('\u200b\u0085'.trimLeft(), '\u200b\u0085', "shouldn't remove this symbols"); + assert.strictEqual('\u200B\u0085'.trimLeft(), '\u200B\u0085', "shouldn't remove this symbols"); if (STRICT) { assert.throws(() => trimLeft.call(null, 0), TypeError); assert.throws(() => trimLeft.call(undefined, 0), TypeError); @@ -26,7 +26,7 @@ QUnit.test('String#trimStart', assert => { assert.same(trimStart, String.prototype.trimLeft, 'same #trimLeft'); assert.strictEqual(' \n q w e \n '.trimStart(), 'q w e \n ', 'removes whitespaces at left side of string'); assert.strictEqual(WHITESPACES.trimStart(), '', 'removes all whitespaces'); - assert.strictEqual('\u200b\u0085'.trimStart(), '\u200b\u0085', "shouldn't remove this symbols"); + assert.strictEqual('\u200B\u0085'.trimStart(), '\u200B\u0085', "shouldn't remove this symbols"); if (STRICT) { assert.throws(() => trimStart.call(null, 0), TypeError); assert.throws(() => trimStart.call(undefined, 0), TypeError); diff --git a/tests/tests/es.string.trim.js b/tests/tests/es.string.trim.js index f342407eaeb4..8df5df64f007 100644 --- a/tests/tests/es.string.trim.js +++ b/tests/tests/es.string.trim.js @@ -9,7 +9,7 @@ QUnit.test('String#trim', assert => { assert.nonEnumerable(String.prototype, 'trim'); assert.strictEqual(' \n q w e \n '.trim(), 'q w e', 'removes whitespaces at left & right side of string'); assert.strictEqual(WHITESPACES.trim(), '', 'removes all whitespaces'); - assert.strictEqual('\u200b\u0085'.trim(), '\u200b\u0085', "shouldn't remove this symbols"); + assert.strictEqual('\u200B\u0085'.trim(), '\u200B\u0085', "shouldn't remove this symbols"); if (STRICT) { assert.throws(() => trim.call(null, 0), TypeError); assert.throws(() => trim.call(undefined, 0), TypeError); diff --git a/tests/tests/es.weak-map.js b/tests/tests/es.weak-map.js index 290bd9a935bf..860124be806b 100644 --- a/tests/tests/es.weak-map.js +++ b/tests/tests/es.weak-map.js @@ -35,7 +35,7 @@ QUnit.test('WeakMap', assert => { return done = true; }, })); - } catch (e) { /* empty */ } + } catch (error) { /* empty */ } assert.ok(done, '.return #throw'); assert.ok(!('clear' in WeakMap.prototype), 'should not contains `.clear` method'); const array = []; diff --git a/tests/tests/es.weak-set.js b/tests/tests/es.weak-set.js index ed85f6ff679d..527f522f3bd5 100644 --- a/tests/tests/es.weak-set.js +++ b/tests/tests/es.weak-set.js @@ -29,7 +29,7 @@ QUnit.test('WeakSet', assert => { return done = true; }, })); - } catch (e) { /* empty */ } + } catch (error) { /* empty */ } assert.ok(done, '.return #throw'); assert.ok(!('clear' in WeakSet.prototype), 'should not contains `.clear` method'); const array = []; diff --git a/tests/tests/esnext.math.iaddh.js b/tests/tests/esnext.math.iaddh.js index 7a06da65bd11..040a763f0b71 100644 --- a/tests/tests/esnext.math.iaddh.js +++ b/tests/tests/esnext.math.iaddh.js @@ -8,6 +8,6 @@ QUnit.test('Math.iaddh', assert => { assert.same(iaddh(0, 2, 1, 0), 2); assert.same(iaddh(0, 4, 1, 1), 5); assert.same(iaddh(2, 4, 1, 1), 5); - assert.same(iaddh(0xffffffff, 4, 1, 1), 6); - assert.same(iaddh(1, 4, 0xffffffff, 1), 6); + assert.same(iaddh(0xFFFFFFFF, 4, 1, 1), 6); + assert.same(iaddh(1, 4, 0xFFFFFFFF, 1), 6); }); diff --git a/tests/tests/esnext.math.imulh.js b/tests/tests/esnext.math.imulh.js index 42e24a1b0c9b..3c4fa472089f 100644 --- a/tests/tests/esnext.math.imulh.js +++ b/tests/tests/esnext.math.imulh.js @@ -5,8 +5,8 @@ QUnit.test('Math.imulh', assert => { assert.arity(imulh, 2); assert.looksNative(imulh); assert.nonEnumerable(Math, 'imulh'); - assert.same(imulh(0xffffffff, 7), -1); - assert.same(imulh(0xfffffff, 77), 4); + assert.same(imulh(0xFFFFFFFF, 7), -1); + assert.same(imulh(0xFFFFFFF, 77), 4); assert.same(imulh(1, 7), 0); assert.same(imulh(-1, 7), -1); }); diff --git a/tests/tests/esnext.math.isubh.js b/tests/tests/esnext.math.isubh.js index 1d9882d4d672..468b697804eb 100644 --- a/tests/tests/esnext.math.isubh.js +++ b/tests/tests/esnext.math.isubh.js @@ -8,6 +8,6 @@ QUnit.test('Math.isubh', assert => { assert.same(isubh(0, 2, 1, 0), 1); assert.same(isubh(0, 4, 1, 1), 2); assert.same(isubh(2, 4, 1, 1), 3); - assert.same(isubh(0xffffffff, 4, 1, 1), 3); - assert.same(isubh(1, 4, 0xffffffff, 1), 2); + assert.same(isubh(0xFFFFFFFF, 4, 1, 1), 3); + assert.same(isubh(1, 4, 0xFFFFFFFF, 1), 2); }); diff --git a/tests/tests/esnext.math.umulh.js b/tests/tests/esnext.math.umulh.js index bb83d9517513..41fd5405059c 100644 --- a/tests/tests/esnext.math.umulh.js +++ b/tests/tests/esnext.math.umulh.js @@ -5,8 +5,8 @@ QUnit.test('Math.umulh', assert => { assert.arity(umulh, 2); assert.looksNative(umulh); assert.nonEnumerable(Math, 'umulh'); - assert.same(umulh(0xffffffff, 7), 6); - assert.same(umulh(0xfffffff, 77), 4); + assert.same(umulh(0xFFFFFFFF, 7), 6); + assert.same(umulh(0xFFFFFFF, 77), 4); assert.same(umulh(1, 7), 0); assert.same(umulh(-1, 7), 6); }); diff --git a/tests/tests/esnext.promise.any.js b/tests/tests/esnext.promise.any.js index eb7564bbaa6b..ce9214faa636 100644 --- a/tests/tests/esnext.promise.any.js +++ b/tests/tests/esnext.promise.any.js @@ -26,9 +26,9 @@ QUnit.test('Promise.any, rejected #1', assert => { Promise.reject(1), Promise.reject(2), Promise.reject(3), - ]).catch(it => { - assert.ok(it instanceof AggregateError, 'instanceof AggregateError'); - assert.deepEqual(it.errors, [1, 2, 3], 'rejected with a correct value'); + ]).catch(error => { + assert.ok(error instanceof AggregateError, 'instanceof AggregateError'); + assert.deepEqual(error.errors, [1, 2, 3], 'rejected with a correct value'); async(); }); }); @@ -45,9 +45,9 @@ QUnit.test('Promise.any, rejected #2', assert => { QUnit.test('Promise.any, rejected #3', assert => { assert.expect(2); const async = assert.async(); - Promise.any([]).catch(it => { - assert.ok(it instanceof AggregateError, 'instanceof AggregateError'); - assert.deepEqual(it.errors, [], 'rejected with a correct value'); + Promise.any([]).catch(error => { + assert.ok(error instanceof AggregateError, 'instanceof AggregateError'); + assert.deepEqual(error.errors, [], 'rejected with a correct value'); async(); }); }); diff --git a/tests/tests/web.timers.js b/tests/tests/web.timers.js index 3b89a76fd7cb..0dd4ccc0676b 100644 --- a/tests/tests/web.timers.js +++ b/tests/tests/web.timers.js @@ -34,8 +34,8 @@ QUnit.test('setInterval / clearInterval', assert => { }, 5, 'a', 'b'); }).then(() => { assert.ok(true, 'setInterval & clearInterval works with additional args'); - }).catch(args => { - if (!args) args = {}; - assert.ok(false, `setInterval & clearInterval works with additional args: ${ args.a }, ${ args.b }, times: ${ args.i }`); + }).catch(error => { + if (!error) error = {}; + assert.ok(false, `setInterval & clearInterval works with additional args: ${ error.a }, ${ error.b }, times: ${ error.i }`); }).then(assert.async()); }); diff --git a/tests/wpt-url-resources/urltestdata.js b/tests/wpt-url-resources/urltestdata.js index 4efb81c87ee4..ea8445b04bdb 100644 --- a/tests/wpt-url-resources/urltestdata.js +++ b/tests/wpt-url-resources/urltestdata.js @@ -3540,13 +3540,13 @@ export default [ }, 'U+3000 is mapped to U+0020 (space) which is disallowed', { - input: 'http://GOO\u00a0\u3000goo.com', + input: 'http://GOO\u00A0\u3000goo.com', base: 'http://other.com/', failure: true, }, 'Other types of space (no-break, zero-width, zero-width-no-break) are name-prepped away to nothing. U+200B, U+2060, and U+FEFF, are ignored', { - input: 'http://GOO\u200b\u2060\ufeffgoo.com', + input: 'http://GOO\u200B\u2060\uFEFFgoo.com', base: 'http://other.com/', href: 'http://googoo.com/', origin: 'http://googoo.com', @@ -3562,7 +3562,7 @@ export default [ }, 'Leading and trailing C0 control or space', { - input: '\u0000\u001b\u0004\u0012 http://example.com/\u001f \u000d ', + input: '\u0000\u001B\u0004\u0012 http://example.com/\u001F \u000D ', base: 'about:blank', href: 'http://example.com/', origin: 'http://example.com', @@ -3594,7 +3594,7 @@ export default [ }, 'Invalid unicode characters should fail... U+FDD0 is disallowed; %ef%b7%90 is U+FDD0', { - input: 'http://\ufdd0zyx.com', + input: 'http://\uFDD0zyx.com', base: 'http://other.com/', failure: true, }, @@ -3606,7 +3606,7 @@ export default [ }, 'U+FFFD', { - input: 'https://\ufffd', + input: 'https://\uFFFD', base: 'about:blank', failure: true, }, @@ -3616,7 +3616,7 @@ export default [ failure: true, }, { - input: 'https://x/\ufffd?\ufffd#\ufffd', + input: 'https://x/\uFFFD?\uFFFD#\uFFFD', base: 'about:blank', href: 'https://x/%EF%BF%BD?%EF%BF%BD#%EF%BF%BD', origin: 'https://x',