diff --git a/.eslintrc b/.eslintrc index c550bcef..07219de3 100644 --- a/.eslintrc +++ b/.eslintrc @@ -52,5 +52,19 @@ "strict": [0], "multiline-comment-style": 1, - } + }, + + "overrides": [ + { + "files": "tests/**", + "rules": { + "max-len": 0, + "max-lines": 0, + "max-statements-per-line": [2, { "max": 2 }], + }, + "env": { + "jasmine": true + }, + }, + ], } diff --git a/es5-sham.js b/es5-sham.js index fe26290e..94dc0bc4 100644 --- a/es5-sham.js +++ b/es5-sham.js @@ -25,7 +25,7 @@ module.exports = factory(); } else { // Browser globals (root is window) - root.returnExports = factory(); + root.returnExports = factory(); // eslint-disable-line no-param-reassign } }(this, function () { @@ -86,17 +86,16 @@ // ES5 15.2.3.3 // http://es5.github.com/#x15.2.3.3 - var doesGetOwnPropertyDescriptorWork = function doesGetOwnPropertyDescriptorWork(object) { - try { - object.sentinel = 0; - return Object.getOwnPropertyDescriptor(object, 'sentinel').value === 0; - } catch (exception) { - return false; - } - }; - // check whether getOwnPropertyDescriptor works if it's given. Otherwise, shim partially. if (Object.defineProperty) { + var doesGetOwnPropertyDescriptorWork = function doesGetOwnPropertyDescriptorWork(object) { + try { + object.sentinel = 0; // eslint-disable-line no-param-reassign + return Object.getOwnPropertyDescriptor(object, 'sentinel').value === 0; + } catch (exception) { + return false; + } + }; var getOwnPropertyDescriptorWorksOnObject = doesGetOwnPropertyDescriptorWork({}); var getOwnPropertyDescriptorWorksOnDom = typeof document === 'undefined' || doesGetOwnPropertyDescriptorWork(document.createElement('div')); @@ -152,7 +151,7 @@ // Object.getOwnPropertyDescriptor(Object.prototype, 'toString') // or any other Object.prototype accessor if (notPrototypeOfObject) { - object.__proto__ = prototypeOfObject; + object.__proto__ = prototypeOfObject; // eslint-disable-line no-param-reassign } var getter = lookupGetter(object, property); @@ -160,7 +159,7 @@ if (notPrototypeOfObject) { // Once we have getter and setter we can put values back. - object.__proto__ = prototype; + object.__proto__ = prototype; // eslint-disable-line no-param-reassign } if (getter || setter) { @@ -405,7 +404,7 @@ // `__proto__` we can safely override `__proto__` while defining // a property to make sure that we don't hit an inherited // accessor. - /* eslint-disable no-proto */ + /* eslint-disable no-proto, no-param-reassign */ var prototype = object.__proto__; object.__proto__ = prototypeOfObject; // Deleting a property anyway since getter / setter may be @@ -414,9 +413,9 @@ object[property] = descriptor.value; // Setting original `__proto__` back now. object.__proto__ = prototype; - /* eslint-enable no-proto */ + /* eslint-enable no-proto, no-param-reassign */ } else { - object[property] = descriptor.value; + object[property] = descriptor.value; // eslint-disable-line no-param-reassign } } else { var hasGetter = 'get' in descriptor; @@ -550,9 +549,9 @@ while (owns(object, name)) { name += '?'; } - object[name] = true; + object[name] = true; // eslint-disable-line no-param-reassign var returnValue = owns(object, name); - delete object[name]; + delete object[name]; // eslint-disable-line no-param-reassign return returnValue; }; } diff --git a/es5-shim.js b/es5-shim.js index e4f5ed07..433e9ba5 100644 --- a/es5-shim.js +++ b/es5-shim.js @@ -25,7 +25,7 @@ module.exports = factory(); } else { // Browser globals (root is window) - root.returnExports = factory(); + root.returnExports = factory(); // eslint-disable-line no-param-reassign } }(this, function () { /** @@ -106,7 +106,7 @@ if (!forceAssign && (name in object)) { return; } - object[name] = method; + object[name] = method; // eslint-disable-line no-param-reassign }; } return function defineProperties(object, map, forceAssign) { @@ -1930,9 +1930,9 @@ var wrappedReplaceValue = function (match) { var length = arguments.length; var originalLastIndex = searchValue.lastIndex; - searchValue.lastIndex = 0; + searchValue.lastIndex = 0; // eslint-disable-line no-param-reassign var args = searchValue.exec(match) || []; - searchValue.lastIndex = originalLastIndex; + searchValue.lastIndex = originalLastIndex; // eslint-disable-line no-param-reassign pushCall(args, arguments[length - 2], arguments[length - 1]); return replaceValue.apply(this, args); }; diff --git a/package.json b/package.json index 1996362b..226a0ee7 100644 --- a/package.json +++ b/package.json @@ -33,8 +33,8 @@ "lint": "eslint tests/helpers/*.js tests/spec/*.js es5-shim.js es5-sham.js" }, "devDependencies": { - "@ljharb/eslint-config": "^14.0.2", - "eslint": "^6.2.1", + "@ljharb/eslint-config": "^15.1.0", + "eslint": "^6.8.0", "jasmine-node": "^1.16.2", "uglify-js": "2.7.3" }, diff --git a/tests/.eslintrc b/tests/.eslintrc deleted file mode 100644 index c7769419..00000000 --- a/tests/.eslintrc +++ /dev/null @@ -1,11 +0,0 @@ -{ - "rules": { - "max-len": 0, - "max-lines": 0, - "max-statements-per-line": [2, { "max": 2 }], - }, - - "env": { - "jasmine": true - } -} diff --git a/tests/spec/s-array.js b/tests/spec/s-array.js index f3e6df2f..d41ef790 100644 --- a/tests/spec/s-array.js +++ b/tests/spec/s-array.js @@ -667,7 +667,7 @@ describe('Array', function () { it('should not be affected by same-index mutation', function () { var results = [1, 2, 3].filter(function (value, index, array) { - array[index] = 'a'; + array[index] = 'a'; // eslint-disable-line no-param-reassign return true; }); expect(results).toEqual([1, 2, 3]); diff --git a/tests/spec/s-regexp.js b/tests/spec/s-regexp.js index cfa11047..ab7313b1 100644 --- a/tests/spec/s-regexp.js +++ b/tests/spec/s-regexp.js @@ -14,6 +14,7 @@ describe('RegExp', function () { describe('objects', function () { it('should return correct flags and in correct order', function () { + /* eslint prefer-regex-literals: 0 */ expect(String(new RegExp('pattern'))).toBe('/pattern/'); expect(String(new RegExp('pattern', 'i'))).toBe('/pattern/i'); expect(String(new RegExp('pattern', 'mi'))).toBe('/pattern/im');