Skip to content

Commit

Permalink
tools: replace custom ESLint rule with built-in
Browse files Browse the repository at this point in the history
ESLint 3.5.0 introduces a `no-restricted-properties` rule. Replace our
custom `no-deepEqual` rule with this rule.

PR-URL: #8478
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
Trott committed Sep 13, 2016
1 parent 2da2625 commit d4061a6
Show file tree
Hide file tree
Showing 13 changed files with 16 additions and 43 deletions.
6 changes: 5 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion benchmark/assert/deepequal-prims-and-objs-big-array.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint no-deepEqual: 0 */
'use strict';
var common = require('../common.js');
var assert = require('assert');
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion benchmark/assert/deepequal-prims-and-objs-big-loop.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint no-deepEqual: 0 */
'use strict';
var common = require('../common.js');
var assert = require('assert');
Expand Down Expand Up @@ -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]));
}

Expand Down
2 changes: 1 addition & 1 deletion benchmark/assert/deepequal-typedarrays.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint no-deepEqual: 0 */
'use strict';
var common = require('../common.js');
var assert = require('assert');
Expand All @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions lib/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-assert-typedarray-deepequal.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint no-deepEqual: 0 */
'use strict';

require('../common');
Expand Down Expand Up @@ -46,6 +45,7 @@ const notEqualArrayPairs = [
];

equalArrayPairs.forEach((arrayPair) => {
// eslint-disable-next-line no-restricted-properties
assert.deepEqual(arrayPair[0], arrayPair[1]);
});

Expand Down
1 change: 0 additions & 1 deletion test/parallel/test-assert.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint no-deepEqual: 0 */
'use strict';
require('../common');
var assert = require('assert');
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-stream2-readable-from-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -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--;
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-stream2-set-encoding.js
Original file line number Diff line number Diff line change
Expand Up @@ -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--;
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-stream2-transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-stream2-writable.js
Original file line number Diff line number Diff line change
Expand Up @@ -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--;
Expand Down
2 changes: 1 addition & 1 deletion test/pummel/test-stream2-basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
32 changes: 0 additions & 32 deletions tools/eslint-rules/no-deepEqual.js

This file was deleted.

0 comments on commit d4061a6

Please sign in to comment.