From bc7f92822b9019c4906d6fb8983b3adf9c3a5a21 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 14 Nov 2017 01:47:27 -0800 Subject: [PATCH] [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `semver` --- .eslintrc | 5 +- es5-sham.js | 14 +-- es5-shim.js | 226 +++++++++++++++++++++-------------------- package.json | 9 +- tests/.eslintrc | 2 +- tests/spec/s-date.js | 8 +- tests/spec/s-global.js | 6 +- 7 files changed, 137 insertions(+), 133 deletions(-) diff --git a/.eslintrc b/.eslintrc index f21250b9..43fa24e9 100644 --- a/.eslintrc +++ b/.eslintrc @@ -4,6 +4,9 @@ "extends": "@ljharb", "rules": { + "array-bracket-newline": 0, + "array-element-newline": 0, + "object-curly-newline": 0, "camelcase": [0], "complexity": [0, 10], "dot-notation": [2, { "allowKeywords": false }], @@ -41,7 +44,7 @@ "no-restricted-syntax": [2, "ContinueStatement", "DebuggerStatement", "LabeledStatement", "WithStatement"], "no-shadow": [1], "no-unused-vars": [1, { "vars": "all", "args": "after-used" }], - "operator-linebreak": [2, "after"], + "operator-linebreak": [2, "before"], "quote-props": [1, "as-needed", { "keywords": true }], "sort-keys": [0], "spaced-comment": [0], diff --git a/es5-sham.js b/es5-sham.js index e7b284ce..ccdaa629 100644 --- a/es5-sham.js +++ b/es5-sham.js @@ -98,8 +98,8 @@ // check whether getOwnPropertyDescriptor works if it's given. Otherwise, shim partially. if (Object.defineProperty) { var getOwnPropertyDescriptorWorksOnObject = doesGetOwnPropertyDescriptorWork({}); - var getOwnPropertyDescriptorWorksOnDom = typeof document === 'undefined' || - doesGetOwnPropertyDescriptorWork(document.createElement('div')); + var getOwnPropertyDescriptorWorksOnDom = typeof document === 'undefined' + || doesGetOwnPropertyDescriptorWork(document.createElement('div')); if (!getOwnPropertyDescriptorWorksOnDom || !getOwnPropertyDescriptorWorksOnObject) { var getOwnPropertyDescriptorFallback = Object.getOwnPropertyDescriptor; } @@ -200,9 +200,9 @@ // Contributed by Brandon Benvie, October, 2012 var createEmpty; var supportsProto = !({ __proto__: null } instanceof Object); - // the following produces false positives - // in Opera Mini => not a reliable check - // Object.prototype.__proto__ === null + // the following produces false positives + // in Opera Mini => not a reliable check + // Object.prototype.__proto__ === null // Check for document.domain and active x support // No need to use active x approach when document.domain is not set @@ -354,8 +354,8 @@ // shim partially. if (Object.defineProperty) { var definePropertyWorksOnObject = doesDefinePropertyWork({}); - var definePropertyWorksOnDom = typeof document === 'undefined' || - doesDefinePropertyWork(document.createElement('div')); + var definePropertyWorksOnDom = typeof document === 'undefined' + || doesDefinePropertyWork(document.createElement('div')); if (!definePropertyWorksOnObject || !definePropertyWorksOnDom) { var definePropertyFallback = Object.defineProperty, definePropertiesFallback = Object.defineProperties; diff --git a/es5-shim.js b/es5-shim.js index fabf6edd..ba25a8c2 100644 --- a/es5-shim.js +++ b/es5-shim.js @@ -340,21 +340,24 @@ var toStr = call.bind(ObjectPrototype.toString); var arraySlice = call.bind(array_slice); var arraySliceApply = apply.bind(array_slice); + /* globals document */ if (typeof document === 'object' && document && document.documentElement) { try { - arraySlice(document.documentElement.childNodes); + arraySlice(document.documentElement.childNodes); } catch (e) { - var origArraySlice = arraySlice; - var origArraySliceApply = arraySliceApply; - arraySlice = function arraySliceIE(arr) { - var r = []; - var i = arr.length; - while (i-- > 0) { r[i] = arr[i]; } - return origArraySliceApply(r, origArraySlice(arguments, 1)); - }; - arraySliceApply = function arraySliceApplyIE(arr, args) { - return origArraySliceApply(arraySlice(arr), args); - }; + var origArraySlice = arraySlice; + var origArraySliceApply = arraySliceApply; + arraySlice = function arraySliceIE(arr) { + var r = []; + var i = arr.length; + while (i-- > 0) { + r[i] = arr[i]; + } + return origArraySliceApply(r, origArraySlice(arguments, 1)); + }; + arraySliceApply = function arraySliceApplyIE(arr, args) { + return origArraySliceApply(arraySlice(arr), args); + }; } } var strSlice = call.bind(StringPrototype.slice); @@ -1058,12 +1061,12 @@ return toStr(value) === '[object Arguments]'; }; var isLegacyArguments = function isArguments(value) { - return value !== null && - typeof value === 'object' && - typeof value.length === 'number' && - value.length >= 0 && - !isArray(value) && - isCallable(value.callee); + return value !== null + && typeof value === 'object' + && typeof value.length === 'number' + && value.length >= 0 + && !isArray(value) + && isCallable(value.callee); }; var isArguments = isStandardArguments(arguments) ? isStandardArguments : isLegacyArguments; @@ -1252,13 +1255,13 @@ var hour = originalGetUTCHours(this); var minute = originalGetUTCMinutes(this); var second = originalGetUTCSeconds(this); - return dayName[day] + ', ' + - (date < 10 ? '0' + date : date) + ' ' + - monthName[month] + ' ' + - year + ' ' + - (hour < 10 ? '0' + hour : hour) + ':' + - (minute < 10 ? '0' + minute : minute) + ':' + - (second < 10 ? '0' + second : second) + ' GMT'; + return dayName[day] + ', ' + + (date < 10 ? '0' + date : date) + ' ' + + monthName[month] + ' ' + + year + ' ' + + (hour < 10 ? '0' + hour : hour) + ':' + + (minute < 10 ? '0' + minute : minute) + ':' + + (second < 10 ? '0' + second : second) + ' GMT'; } }, hasNegativeMonthYearBug || hasToUTCStringFormatBug); @@ -1272,10 +1275,10 @@ var date = this.getDate(); var month = this.getMonth(); var year = this.getFullYear(); - return dayName[day] + ' ' + - monthName[month] + ' ' + - (date < 10 ? '0' + date : date) + ' ' + - year; + return dayName[day] + ' ' + + monthName[month] + ' ' + + (date < 10 ? '0' + date : date) + ' ' + + year; } }, hasNegativeMonthYearBug || hasToDateStringFormatBug); @@ -1295,16 +1298,16 @@ var timezoneOffset = this.getTimezoneOffset(); var hoursOffset = Math.floor(Math.abs(timezoneOffset) / 60); var minutesOffset = Math.floor(Math.abs(timezoneOffset) % 60); - return dayName[day] + ' ' + - monthName[month] + ' ' + - (date < 10 ? '0' + date : date) + ' ' + - year + ' ' + - (hour < 10 ? '0' + hour : hour) + ':' + - (minute < 10 ? '0' + minute : minute) + ':' + - (second < 10 ? '0' + second : second) + ' GMT' + - (timezoneOffset > 0 ? '-' : '+') + - (hoursOffset < 10 ? '0' + hoursOffset : hoursOffset) + - (minutesOffset < 10 ? '0' + minutesOffset : minutesOffset); + return dayName[day] + ' ' + + monthName[month] + ' ' + + (date < 10 ? '0' + date : date) + ' ' + + year + ' ' + + (hour < 10 ? '0' + hour : hour) + ':' + + (minute < 10 ? '0' + minute : minute) + ':' + + (second < 10 ? '0' + second : second) + ' GMT' + + (timezoneOffset > 0 ? '-' : '+') + + (hoursOffset < 10 ? '0' + hoursOffset : hoursOffset) + + (minutesOffset < 10 ? '0' + minutesOffset : minutesOffset); }; if (supportsDescriptors) { $Object.defineProperty(Date.prototype, 'toString', { @@ -1352,8 +1355,8 @@ originalGetUTCSeconds(this) ]; year = ( - (year < 0 ? '-' : (year > 9999 ? '+' : '')) + - strSlice('00000' + Math.abs(year), (0 <= year && year <= 9999) ? -4 : -6) + (year < 0 ? '-' : (year > 9999 ? '+' : '')) + + strSlice('00000' + Math.abs(year), (0 <= year && year <= 9999) ? -4 : -6) ); for (var i = 0; i < result.length; ++i) { @@ -1362,9 +1365,9 @@ } // pad milliseconds to have three digits. return ( - year + '-' + arraySlice(result, 0, 2).join('-') + - 'T' + arraySlice(result, 2).join(':') + '.' + - strSlice('000' + originalGetUTCMilliseconds(this), -3) + 'Z' + year + '-' + arraySlice(result, 0, 2).join('-') + + 'T' + arraySlice(result, 2).join(':') + '.' + + strSlice('000' + originalGetUTCMilliseconds(this), -3) + 'Z' ); } }, hasNegativeDateBug || hasSafari51DateBug); @@ -1375,10 +1378,10 @@ // JSON.stringify (15.12.3). var dateToJSONIsSupported = (function () { try { - return Date.prototype.toJSON && - new Date(NaN).toJSON() === null && - new Date(negativeDate).toJSON().indexOf(negativeYearString) !== -1 && - Date.prototype.toJSON.call({ // generic + return Date.prototype.toJSON + && new Date(NaN).toJSON() === null + && new Date(negativeDate).toJSON().indexOf(negativeYearString) !== -1 + && Date.prototype.toJSON.call({ // generic toISOString: function () { return true; } }); } catch (e) { @@ -1450,19 +1453,19 @@ seconds += sToShift; millis -= sToShift * 1e3; } - date = length === 1 && $String(Y) === Y ? // isString(Y) + date = length === 1 && $String(Y) === Y // isString(Y) // We explicitly pass it through parse: - new NativeDate(DateShim.parse(Y)) : + ? new NativeDate(DateShim.parse(Y)) // We have to manually make calls depending on argument // length here - length >= 7 ? new NativeDate(Y, M, D, h, m, seconds, millis) : - length >= 6 ? new NativeDate(Y, M, D, h, m, seconds) : - length >= 5 ? new NativeDate(Y, M, D, h, m) : - length >= 4 ? new NativeDate(Y, M, D, h) : - length >= 3 ? new NativeDate(Y, M, D) : - length >= 2 ? new NativeDate(Y, M) : - length >= 1 ? new NativeDate(Y instanceof NativeDate ? +Y : Y) : - new NativeDate(); + : length >= 7 ? new NativeDate(Y, M, D, h, m, seconds, millis) + : length >= 6 ? new NativeDate(Y, M, D, h, m, seconds) + : length >= 5 ? new NativeDate(Y, M, D, h, m) + : length >= 4 ? new NativeDate(Y, M, D, h) + : length >= 3 ? new NativeDate(Y, M, D) + : length >= 2 ? new NativeDate(Y, M) + : length >= 1 ? new NativeDate(Y instanceof NativeDate ? +Y : Y) + : new NativeDate(); } else { date = NativeDate.apply(this, arguments); } @@ -1474,38 +1477,37 @@ }; // 15.9.1.15 Date Time String Format. - var isoDateExpression = new RegExp('^' + - '(\\d{4}|[+-]\\d{6})' + // four-digit year capture or sign + - // 6-digit extended year - '(?:-(\\d{2})' + // optional month capture - '(?:-(\\d{2})' + // optional day capture - '(?:' + // capture hours:minutes:seconds.milliseconds - 'T(\\d{2})' + // hours capture - ':(\\d{2})' + // minutes capture - '(?:' + // optional :seconds.milliseconds - ':(\\d{2})' + // seconds capture - '(?:(\\.\\d{1,}))?' + // milliseconds capture - ')?' + - '(' + // capture UTC offset component - 'Z|' + // UTC capture - '(?:' + // offset specifier +/-hours:minutes - '([-+])' + // sign capture - '(\\d{2})' + // hours offset capture - ':(\\d{2})' + // minutes offset capture - ')' + - ')?)?)?)?' + - '$'); + var isoDateExpression = new RegExp('^' + + '(\\d{4}|[+-]\\d{6})' // four-digit year capture or sign + 6-digit extended year + + '(?:-(\\d{2})' // optional month capture + + '(?:-(\\d{2})' // optional day capture + + '(?:' // capture hours:minutes:seconds.milliseconds + + 'T(\\d{2})' // hours capture + + ':(\\d{2})' // minutes capture + + '(?:' // optional :seconds.milliseconds + + ':(\\d{2})' // seconds capture + + '(?:(\\.\\d{1,}))?' // milliseconds capture + + ')?' + + '(' // capture UTC offset component + + 'Z|' // UTC capture + + '(?:' // offset specifier +/-hours:minutes + + '([-+])' // sign capture + + '(\\d{2})' // hours offset capture + + ':(\\d{2})' // minutes offset capture + + ')' + + ')?)?)?)?' + + '$'); var months = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365]; var dayFromMonth = function dayFromMonth(year, month) { var t = month > 1 ? 1 : 0; return ( - months[month] + - Math.floor((year - 1969 + t) / 4) - - Math.floor((year - 1901 + t) / 100) + - Math.floor((year - 1601 + t) / 400) + - (365 * (year - 1970)) + months[month] + + Math.floor((year - 1969 + t) / 4) + - Math.floor((year - 1901 + t) / 100) + + Math.floor((year - 1601 + t) / 400) + + (365 * (year - 1970)) ); }; @@ -1561,21 +1563,21 @@ result; var hasMinutesOrSecondsOrMilliseconds = minute > 0 || second > 0 || millisecond > 0; if ( - hour < (hasMinutesOrSecondsOrMilliseconds ? 24 : 25) && - minute < 60 && second < 60 && millisecond < 1000 && - month > -1 && month < 12 && hourOffset < 24 && - minuteOffset < 60 && // detect invalid offsets - day > -1 && - day < (dayFromMonth(year, month + 1) - dayFromMonth(year, month)) + hour < (hasMinutesOrSecondsOrMilliseconds ? 24 : 25) + && minute < 60 && second < 60 && millisecond < 1000 + && month > -1 && month < 12 && hourOffset < 24 + && minuteOffset < 60 // detect invalid offsets + && day > -1 + && day < (dayFromMonth(year, month + 1) - dayFromMonth(year, month)) ) { result = ( - ((dayFromMonth(year, month) + day) * 24) + - hour + - (hourOffset * signOffset) + ((dayFromMonth(year, month) + day) * 24) + + hour + + (hourOffset * signOffset) ) * 60; result = (( - ((result + minute + (minuteOffset * signOffset)) * 60) + - second + ((result + minute + (minuteOffset * signOffset)) * 60) + + second ) * 1000) + millisecond; if (isLocalTime) { result = toUTC(result); @@ -1611,10 +1613,10 @@ // ES5.1 15.7.4.5 // http://es5.github.com/#x15.7.4.5 var hasToFixedBugs = NumberPrototype.toFixed && ( - (0.00008).toFixed(3) !== '0.000' || - (0.9).toFixed(0) !== '1' || - (1.255).toFixed(2) !== '1.25' || - (1000000000000000128).toFixed(0) !== '1000000000000000128' + (0.00008).toFixed(3) !== '0.000' + || (0.9).toFixed(0) !== '1' + || (1.255).toFixed(2) !== '1.25' + || (1000000000000000128).toFixed(0) !== '1000000000000000128' ); var toFixedHelpers = { @@ -1792,12 +1794,12 @@ // '.'.split(/()()/) should be ["."], not ["", "", "."] if ( - 'ab'.split(/(?:ab)*/).length !== 2 || - '.'.split(/(.?)(.?)/).length !== 4 || - 'tesst'.split(/(s)*/)[1] === 't' || - 'test'.split(/(?:)/, -1).length !== 4 || - ''.split(/.?/).length || - '.'.split(/()()/).length > 1 + 'ab'.split(/(?:ab)*/).length !== 2 + || '.'.split(/(.?)(.?)/).length !== 4 + || 'tesst'.split(/(s)*/)[1] === 't' + || 'test'.split(/(?:)/, -1).length !== 4 + || ''.split(/.?/).length + || '.'.split(/()()/).length > 1 ) { (function () { var compliantExecNpcg = typeof (/()??/).exec('')[1] === 'undefined'; // NPCG: nonparticipating capturing group @@ -1815,10 +1817,10 @@ } var output = []; - var flags = (separator.ignoreCase ? 'i' : '') + - (separator.multiline ? 'm' : '') + - (separator.unicode ? 'u' : '') + // in ES6 - (separator.sticky ? 'y' : ''), // Firefox 3+ and ES6 + var flags = (separator.ignoreCase ? 'i' : '') + + (separator.multiline ? 'm' : '') + + (separator.unicode ? 'u' : '') // in ES6 + + (separator.sticky ? 'y' : ''), // Firefox 3+ and ES6 lastLastIndex = 0, // Make `global` and avoid `lastIndex` issues by working with a copy separator2, match, lastIndex, lastLength; @@ -1943,9 +1945,9 @@ // ES5 15.5.4.20 // whitespace from: http://es5.github.io/#x15.5.4.20 - var ws = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003' + - '\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028' + - '\u2029\uFEFF'; + var ws = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003' + + '\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028' + + '\u2029\uFEFF'; var zeroWidth = '\u200b'; var wsRegexChars = '[' + ws + ']'; var trimBeginRegexp = new RegExp('^' + wsRegexChars + wsRegexChars + '*'); diff --git a/package.json b/package.json index 36554175..6e2abc50 100644 --- a/package.json +++ b/package.json @@ -34,13 +34,13 @@ "jscs": "jscs tests/helpers/*.js tests/spec/*.js es5-shim.js es5-sham.js" }, "devDependencies": { - "eslint": "^3.19.0", - "@ljharb/eslint-config": "^11.0.0", + "@ljharb/eslint-config": "^12.2.1", + "eslint": "^4.11.0", "jasmine-node": "^1.14.5", "jscs": "^3.0.7", - "uglify-js": "2.7.3", "replace": "^0.3.0", - "semver": "^5.3.0" + "semver": "^5.4.1", + "uglify-js": "2.7.3" }, "engines": { "node": ">=0.4.0" @@ -76,4 +76,3 @@ ] } } - diff --git a/tests/.eslintrc b/tests/.eslintrc index 5ed940c9..ca0e2c84 100644 --- a/tests/.eslintrc +++ b/tests/.eslintrc @@ -2,6 +2,6 @@ "rules": { "max-len": 0, "max-lines": 0, - "max-statements-per-line": [2, { "max": 2 }] + "max-statements-per-line": [2, { "max": 2 }], } } diff --git a/tests/spec/s-date.js b/tests/spec/s-date.js index b1b2f7f6..397a5bbd 100644 --- a/tests/spec/s-date.js +++ b/tests/spec/s-date.js @@ -132,8 +132,8 @@ describe('Date', function () { expect(+new Date('2011-03-01T12:00:00.000Z')).toBe(1298980800000); // 1298980800000 1298980800000 1298980800000 1298980800000 1298980800000 // https://github.com/es-shims/es5-shim/issues/80 Safari bug with leap day - expect(new Date('2034-03-01T00:00:00.000Z') - - new Date('2034-02-27T23:59:59.999Z')).toBe(86400001); // 86400001 86400001 86400001 86400001 1 + expect(new Date('2034-03-01T00:00:00.000Z') + - new Date('2034-02-27T23:59:59.999Z')).toBe(86400001); // 86400001 86400001 86400001 86400001 1 }); @@ -221,8 +221,8 @@ describe('Date', function () { } // https://github.com/es-shims/es5-shim/issues/80 Safari bug with leap day - expect(Date.parse('2034-03-01T00:00:00.000Z') - - Date.parse('2034-02-27T23:59:59.999Z')).toBe(86400001); // 86400001 86400001 86400001 86400001 1 + expect(Date.parse('2034-03-01T00:00:00.000Z') + - Date.parse('2034-02-27T23:59:59.999Z')).toBe(86400001); // 86400001 86400001 86400001 86400001 1 }); diff --git a/tests/spec/s-global.js b/tests/spec/s-global.js index 707a134b..515553ed 100644 --- a/tests/spec/s-global.js +++ b/tests/spec/s-global.js @@ -48,9 +48,9 @@ describe('global methods', function () { expect(parseInt(' 42')).toBe(parseInt('42', 10)); expect(parseInt(' 08')).toBe(parseInt('08', 10)); - var ws = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003' + - '\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028' + - '\u2029\uFEFF'; + var ws = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003' + + '\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028' + + '\u2029\uFEFF'; expect(parseInt(ws + '08')).toBe(parseInt('08', 10)); expect(parseInt(ws + '0x16')).toBe(parseInt('0x16', 16)); });