Skip to content

Commit d469321

Browse files
danyshaananjasnell
authored andcommitted
tools: add eslint rule prefer-assert-methods
PR-URL: #8622 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Yorkie Liu <[email protected]> Reviewed-By: Jackson Tian <[email protected]> Reviewed-By: Johan Bergström <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Teddy Katz <[email protected]>
1 parent 66dbd9c commit d469321

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+151
-90
lines changed

test/.eslintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
rules:
44
## common module is mandatory in tests
55
required-modules: [2, common]
6+
prefer-assert-methods: 2

test/addons/load-long-path/test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@ fs.writeFileSync(addonDestinationPath, contents);
3030

3131
// Attempt to load at long path destination
3232
var addon = require(addonDestinationPath);
33-
assert(addon != null);
34-
assert(addon.hello() == 'world');
33+
assert.notEqual(addon, null);
34+
assert.equal(addon.hello(), 'world');

test/gc/test-http-client-connaborted.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ function status() {
6464
console.log('Collected: %d/%d', countGC, count);
6565
if (done === todo) {
6666
console.log('All should be collected now.');
67-
assert(count === countGC);
67+
assert.strictEqual(count, countGC);
6868
process.exit(0);
6969
}
7070
}

test/gc/test-http-client-timeout.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,7 @@ function status() {
7373
console.log('Collected: %d/%d', countGC, count);
7474
if (done === todo) {
7575
console.log('All should be collected now.');
76-
assert(count === countGC);
76+
assert.strictEqual(count, countGC);
7777
process.exit(0);
7878
}
7979
}
80-

test/gc/test-http-client.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ function status() {
6262
console.log('Collected: %d/%d', countGC, count);
6363
if (done === todo) {
6464
console.log('All should be collected now.');
65-
assert(count === countGC);
65+
assert.strictEqual(count, countGC);
6666
process.exit(0);
6767
}
6868
}
69-

test/gc/test-net-timeout.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ function status() {
6969
global.gc();
7070
console.log('All should be collected now.');
7171
console.log('Collected: %d/%d', countGC, count);
72-
assert(count === countGC);
72+
assert.strictEqual(count, countGC);
7373
process.exit(0);
7474
}, 200);
7575
}

test/parallel/test-child-process-detached.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,3 @@ process.on('exit', function() {
2323
process.kill(persistentPid);
2424
});
2525
});
26-

test/parallel/test-child-process-fork-regr-gh-2847.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ var server = net.createServer(function(s) {
4545

4646
worker.process.once('close', common.mustCall(function() {
4747
// Otherwise the crash on `_channel.fd` access may happen
48-
assert(worker.process._channel === null);
48+
assert.strictEqual(worker.process._channel, null);
4949
server.close();
5050
}));
5151

test/parallel/test-cluster-setup-master-argv.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ cluster.on('setup', function() {
1212
realArgs[realArgs.length - 1]);
1313
});
1414

15-
assert(process.argv[process.argv.length - 1] !== 'OMG,OMG');
15+
assert.notStrictEqual(process.argv[process.argv.length - 1], 'OMG,OMG');
1616
process.argv.push('OMG,OMG');
1717
process.argv.push('OMG,OMG');
1818
cluster.setupMaster();

test/parallel/test-domain-http-server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ var server = http.createServer(function(req, res) {
3030
var data = JSON.stringify(objects[req.url.replace(/[^a-z]/g, '')]);
3131

3232
// this line will throw if you pick an unknown key
33-
assert(data !== undefined, 'Data should not be undefined');
33+
assert.notStrictEqual(data, undefined, 'Data should not be undefined');
3434

3535
res.writeHead(200);
3636
res.end(data);

0 commit comments

Comments
 (0)