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 4442af73f8..96aad6e66c 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) @@ -65,7 +65,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(), @@ -680,8 +680,6 @@ describe('Mocha', function() { }); describe('when the `Mocha` instance is already disposed', function() { - var mocha; - beforeEach(function() { mocha.dispose(); }); @@ -713,8 +711,6 @@ describe('Mocha', function() { }); describe('when a run has finished and is called again', function() { - var mocha; - beforeEach(function(done) { mocha.run(function() { runner.run.reset(); @@ -748,8 +744,6 @@ describe('Mocha', function() { }); describe('when Mocha configured for multiple runs and multiple runs are attempted', function() { - var mocha; - beforeEach(function() { mocha.cleanReferencesAfterRun(false); });