From 263c7b1df72de409e9e560ff1114276885d97db3 Mon Sep 17 00:00:00 2001 From: Christopher Hiller Date: Mon, 11 May 2020 12:52:07 -0700 Subject: [PATCH] restrict use of Object.assign --- .eslintrc.yml | 11 ++++++++++- test/unit/mocha.spec.js | 4 ++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/.eslintrc.yml b/.eslintrc.yml index 34c77cabe4..43d8bcfd9e 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -14,6 +14,11 @@ rules: strict: - error - safe + # disallow Object.assign + no-restricted-properties: + - error + - object: 'Object' + property: 'assign' overrides: - files: - scripts/**/*.js @@ -31,6 +36,11 @@ overrides: ecmaVersion: 2018 env: browser: false + rules: + no-restricted-properties: + - off + - object: 'Object' + property: 'assign' - files: - esm-utils.js parserOptions: @@ -79,7 +89,6 @@ overrides: # disallow property access of `global..*` - selector: '*[object.object.name=global][object.property.name=/(Date|(set|clear)(Timeout|Immediate|Interval))/]:expression' message: *GH-237 - - files: - test/**/*.mjs parserOptions: diff --git a/test/unit/mocha.spec.js b/test/unit/mocha.spec.js index 63f7c54847..41b0918d5b 100644 --- a/test/unit/mocha.spec.js +++ b/test/unit/mocha.spec.js @@ -52,7 +52,7 @@ describe('Mocha', function() { reporterInstance = {}; opts = {reporter: sandbox.stub().returns(reporterInstance)}; Base = sandbox.stub().returns({}); - runner = Object.assign(sandbox.createStubInstance(EventEmitter), { + runner = utils.assign(sandbox.createStubInstance(EventEmitter), { run: sandbox .stub() .callsArgAsync(0) @@ -64,7 +64,7 @@ describe('Mocha', function() { // the Runner constructor is the main export, and constants is a static prop. // we don't need the constants themselves, but the object cannot be undefined Runner.constants = {}; - suite = Object.assign(sandbox.createStubInstance(EventEmitter), { + suite = utils.assign(sandbox.createStubInstance(EventEmitter), { slow: sandbox.stub(), timeout: sandbox.stub(), bail: sandbox.stub()