diff --git a/.eslintrc b/.eslintrc index c51e07b373..f1525a6309 100644 --- a/.eslintrc +++ b/.eslintrc @@ -54,6 +54,11 @@ rules: no-new-require: 2 no-path-concat: 2 no-restricted-modules: [2, sys, _linklist] + no-restricted-properties: [2, { + object: assert, + property: deepEqual, + message: Please use assert.deepStrictEqual(). + }] # Stylistic Issues # http://eslint.org/docs/rules/#stylistic-issues @@ -98,7 +103,6 @@ rules: align-multiline-assignment: 2 assert-fail-single-argument: 2 new-with-error: [2, Error, RangeError, TypeError, SyntaxError, ReferenceError] - no-deepEqual: 2 no-definegetter-definesetter: 2 # Global scoped method and vars diff --git a/benchmark/assert/deepequal-prims-and-objs-big-array.js b/benchmark/assert/deepequal-prims-and-objs-big-array.js index 9bf946a5bf..1b4802c8ff 100644 --- a/benchmark/assert/deepequal-prims-and-objs-big-array.js +++ b/benchmark/assert/deepequal-prims-and-objs-big-array.js @@ -1,4 +1,3 @@ -/* eslint no-deepEqual: 0 */ 'use strict'; var common = require('../common.js'); var assert = require('assert'); @@ -35,6 +34,7 @@ function main(conf) { bench.start(); for (x = 0; x < n; x++) { + // eslint-disable-next-line no-restricted-properties assert.deepEqual(primArray, primArrayCompare); } bench.end(n); diff --git a/benchmark/assert/deepequal-prims-and-objs-big-loop.js b/benchmark/assert/deepequal-prims-and-objs-big-loop.js index 8227d532a4..dea084bc98 100644 --- a/benchmark/assert/deepequal-prims-and-objs-big-loop.js +++ b/benchmark/assert/deepequal-prims-and-objs-big-loop.js @@ -1,4 +1,3 @@ -/* eslint no-deepEqual: 0 */ 'use strict'; var common = require('../common.js'); var assert = require('assert'); @@ -27,6 +26,7 @@ function main(conf) { bench.start(); for (x = 0; x < n; x++) { + // eslint-disable-next-line no-restricted-properties assert.deepEqual(new Array([prim]), new Array([prim])); } diff --git a/benchmark/assert/deepequal-typedarrays.js b/benchmark/assert/deepequal-typedarrays.js index 654b8b4a79..1954c57ee5 100644 --- a/benchmark/assert/deepequal-typedarrays.js +++ b/benchmark/assert/deepequal-typedarrays.js @@ -1,4 +1,3 @@ -/* eslint no-deepEqual: 0 */ 'use strict'; var common = require('../common.js'); var assert = require('assert'); @@ -17,6 +16,7 @@ function main(conf) { var actual = new clazz(n * 1e6); var expected = new clazz(n * 1e6); + // eslint-disable-next-line no-restricted-properties assert.deepEqual(actual, expected); bench.end(n); diff --git a/lib/assert.js b/lib/assert.js index 9378631d27..0458bb0981 100644 --- a/lib/assert.js +++ b/lib/assert.js @@ -126,11 +126,13 @@ assert.notEqual = function notEqual(actual, expected, message) { // 7. The equivalence assertion tests a deep equality relation. // assert.deepEqual(actual, expected, message_opt); +/* eslint-disable no-restricted-properties */ assert.deepEqual = function deepEqual(actual, expected, message) { if (!_deepEqual(actual, expected, false)) { fail(actual, expected, message, 'deepEqual', assert.deepEqual); } }; +/* eslint-enable */ assert.deepStrictEqual = function deepStrictEqual(actual, expected, message) { if (!_deepEqual(actual, expected, true)) { diff --git a/test/parallel/test-assert-typedarray-deepequal.js b/test/parallel/test-assert-typedarray-deepequal.js index 24acd81d6a..2e6c88848a 100644 --- a/test/parallel/test-assert-typedarray-deepequal.js +++ b/test/parallel/test-assert-typedarray-deepequal.js @@ -1,4 +1,3 @@ -/* eslint no-deepEqual: 0 */ 'use strict'; require('../common'); @@ -46,6 +45,7 @@ const notEqualArrayPairs = [ ]; equalArrayPairs.forEach((arrayPair) => { + // eslint-disable-next-line no-restricted-properties assert.deepEqual(arrayPair[0], arrayPair[1]); }); diff --git a/test/parallel/test-assert.js b/test/parallel/test-assert.js index 97242363b4..9767ecfe87 100644 --- a/test/parallel/test-assert.js +++ b/test/parallel/test-assert.js @@ -1,4 +1,3 @@ -/* eslint no-deepEqual: 0 */ 'use strict'; require('../common'); var assert = require('assert'); diff --git a/test/parallel/test-stream2-readable-from-list.js b/test/parallel/test-stream2-readable-from-list.js index a823bf9dc1..2aa0725f73 100644 --- a/test/parallel/test-stream2-readable-from-list.js +++ b/test/parallel/test-stream2-readable-from-list.js @@ -23,7 +23,7 @@ function run() { var fn = next[1]; console.log('# %s', name); fn({ - same: assert.deepEqual, + same: assert.deepStrictEqual, equal: assert.equal, end: function() { count--; diff --git a/test/parallel/test-stream2-set-encoding.js b/test/parallel/test-stream2-set-encoding.js index dd27c1bb29..3deb67d48e 100644 --- a/test/parallel/test-stream2-set-encoding.js +++ b/test/parallel/test-stream2-set-encoding.js @@ -22,7 +22,7 @@ function run() { var fn = next[1]; console.log('# %s', name); fn({ - same: assert.deepEqual, + same: assert.deepStrictEqual, equal: assert.equal, end: function() { count--; diff --git a/test/parallel/test-stream2-transform.js b/test/parallel/test-stream2-transform.js index e25cdc8e49..bc812ff30d 100644 --- a/test/parallel/test-stream2-transform.js +++ b/test/parallel/test-stream2-transform.js @@ -22,7 +22,7 @@ function run() { var fn = next[1]; console.log('# %s', name); fn({ - same: assert.deepEqual, + same: assert.deepStrictEqual, equal: assert.equal, ok: assert, end: function() { diff --git a/test/parallel/test-stream2-writable.js b/test/parallel/test-stream2-writable.js index 6acfcde4ef..a9d526f8c0 100644 --- a/test/parallel/test-stream2-writable.js +++ b/test/parallel/test-stream2-writable.js @@ -45,7 +45,7 @@ function run() { var fn = next[1]; console.log('# %s', name); fn({ - same: assert.deepEqual, + same: assert.deepStrictEqual, equal: assert.equal, end: function() { count--; diff --git a/test/pummel/test-stream2-basic.js b/test/pummel/test-stream2-basic.js index e03c49f13b..6bb2386b0b 100644 --- a/test/pummel/test-stream2-basic.js +++ b/test/pummel/test-stream2-basic.js @@ -85,7 +85,7 @@ function run() { var fn = next[1]; console.log('# %s', name); fn({ - same: assert.deepEqual, + same: assert.deepStrictEqual, ok: assert, equal: assert.equal, end: function() { diff --git a/tools/eslint-rules/no-deepEqual.js b/tools/eslint-rules/no-deepEqual.js deleted file mode 100644 index 46341d7d92..0000000000 --- a/tools/eslint-rules/no-deepEqual.js +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @fileoverview Prohibit use of assert.deepEqual() - * @author Rich Trott - * - * This rule is imperfect, but will find the most common forms of - * assert.deepEqual() usage. - */ -'use strict'; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -const msg = 'assert.deepEqual() disallowed. Use assert.deepStrictEqual()'; - -function isAssert(node) { - return node.callee.object && node.callee.object.name === 'assert'; -} - -function isDeepEqual(node) { - return node.callee.property && node.callee.property.name === 'deepEqual'; -} - -module.exports = function(context) { - return { - 'CallExpression': function(node) { - if (isAssert(node) && isDeepEqual(node)) { - context.report(node, msg); - } - } - }; -};