Skip to content

Commit

Permalink
[eslint] enable wrap-regex
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Jul 24, 2021
1 parent ae6de0c commit 7dcbd76
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 17 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Expand Up @@ -59,6 +59,7 @@
"wrap-iife": ["error", "outside", {
"functionPrototypeMethods": true,
}],
"wrap-regex": "error",
},
"ignorePatterns": [ "syntax-error.*" ],
"overrides": [
Expand Down
2 changes: 1 addition & 1 deletion lib/default_stream.js
Expand Up @@ -19,7 +19,7 @@ module.exports = function () {
}

function flush() {
if (fs.writeSync && /^win/.test(process.platform)) {
if (fs.writeSync && (/^win/).test(process.platform)) {
try { fs.writeSync(1, line + '\n'); }
catch (e) { stream.emit('error', e); }
} else {
Expand Down
18 changes: 9 additions & 9 deletions test/async-await.js
Expand Up @@ -36,7 +36,7 @@ tap.test('async2', function (t) {
runProgram('async-await', 'async2.js', function (r) {
var stdout = r.stdout.toString('utf8');
var lines = stdout.split('\n').filter(function (line) {
return !/^(\s+)at(\s+)<anonymous>$/.test(line);
return !(/^(\s+)at(\s+)<anonymous>$/).test(line);
});

t.same(stripFullStack(lines.join('\n')), [
Expand Down Expand Up @@ -184,9 +184,9 @@ tap.test('sync-error', function (t) {
var stderr = r.stderr.toString('utf8');
var lines = stderr.split('\n');
lines = lines.filter(function (line) {
return !/\(timers.js:/.test(line)
&& !/\(internal\/timers.js:/.test(line)
&& !/Immediate\.next/.test(line);
return !(/\(timers.js:/).test(line)
&& !(/\(internal\/timers.js:/).test(line)
&& !(/Immediate\.next/).test(line);
});
stderr = lines.join('\n');

Expand All @@ -211,7 +211,7 @@ tap.test('async-error', function (t) {
var stdout = r.stdout.toString('utf8');
var lines = stdout.split('\n');
lines = lines.filter(function (line) {
return !/^(\s+)at(\s+)<anonymous>$/.test(line);
return !(/^(\s+)at(\s+)<anonymous>$/).test(line);
});
stdout = lines.join('\n');

Expand Down Expand Up @@ -240,9 +240,9 @@ tap.test('async-error', function (t) {
var stderr = r.stderr.toString('utf8');
var lines = stderr.split('\n');
lines = lines.filter(function (line) {
return !/\(timers.js:/.test(line)
&& !/\(internal\/timers.js:/.test(line)
&& !/Immediate\.next/.test(line);
return !(/\(timers.js:/).test(line)
&& !(/\(internal\/timers.js:/).test(line)
&& !(/Immediate\.next/).test(line);
});
stderr = lines.join('\n');

Expand All @@ -256,7 +256,7 @@ tap.test('async-bug', function (t) {
var stdout = r.stdout.toString('utf8');
var lines = stdout.split('\n');
lines = lines.filter(function (line) {
return !/^(\s+)at(\s+)<anonymous>$/.test(line);
return !(/^(\s+)at(\s+)<anonymous>$/).test(line);
});
stdout = lines.join('\n');

Expand Down
2 changes: 1 addition & 1 deletion test/ignore_from_gitignore.js
Expand Up @@ -110,7 +110,7 @@ tap.test('Should fail when ignore file does not exist', { skip: process.platform
};

var testStderr = function (rows) {
tt.ok(/^ENOENT[:,] no such file or directory,? (?:open )?'\$TEST\/ignore\/.gitignore'\n$/m.test(stripFullStack(rows.toString('utf8')).join('\n')));
tt.ok((/^ENOENT[:,] no such file or directory,? (?:open )?'\$TEST\/ignore\/.gitignore'\n$/m).test(stripFullStack(rows.toString('utf8')).join('\n')));
};

var ps = spawn(tapeBin, ['**/*.js', '-i'], { cwd: path.join(__dirname, 'ignore') });
Expand Down
8 changes: 4 additions & 4 deletions test/promise_fail.js
Expand Up @@ -15,12 +15,12 @@ tap.test('callback returning rejected promise should cause that test (and only t
ps.stdout.pipe(concat(function (rows) {
var rowsString = rows.toString('utf8');

if (/^skip\n$/.test(rowsString)) {
if ((/^skip\n$/).test(rowsString)) {
return tt.pass('the test file indicated it should be skipped');
}

var strippedString = stripFullStack(rowsString).filter(function (line) {
return !/^(\s+)at(\s+)(?:Test\.)?<anonymous>(?:$|\s)/.test(line);
return !(/^(\s+)at(\s+)(?:Test\.)?<anonymous>(?:$|\s)/).test(line);
}).join('\n');

// hack for consistency across all versions of node
Expand Down Expand Up @@ -63,12 +63,12 @@ tap.test('subtest callback returning rejected promise should cause that subtest
ps.stdout.pipe(concat(function (rows) {
var rowsString = rows.toString('utf8');

if (/^skip\n$/.test(rowsString)) {
if ((/^skip\n$/).test(rowsString)) {
return tt.pass('the test file indicated it should be skipped');
}

var strippedString = stripFullStack(rowsString).filter(function (line) {
return !/^(\s+)at(\s+)(?:Test\.)?<anonymous>(?:$|\s)/.test(line);
return !(/^(\s+)at(\s+)(?:Test\.)?<anonymous>(?:$|\s)/).test(line);
}).join('\n');

// hack for consistency across all versions of node
Expand Down
4 changes: 2 additions & 2 deletions test/stackTrace.js
Expand Up @@ -171,7 +171,7 @@ tap.test('preserves stack trace for failed assertions', function (tt) {
tt.equal(typeof data.diag.stack, 'string');
var at = data.diag.at || '';
stack = data.diag.stack || '';
tt.ok(/^Error: true should be false(\n at .+)+/.exec(stack), 'stack should be a stack');
tt.ok((/^Error: true should be false(\n at .+)+/).exec(stack), 'stack should be a stack');
tt.deepEqual(data, {
ok: false,
id: 1,
Expand Down Expand Up @@ -236,7 +236,7 @@ tap.test('preserves stack trace for failed assertions where actual===falsy', fun
tt.equal(typeof data.diag.stack, 'string');
var at = data.diag.at || '';
stack = data.diag.stack || '';
tt.ok(/^Error: false should be true(\n at .+)+/.exec(stack), 'stack should be a stack');
tt.ok((/^Error: false should be true(\n at .+)+/).exec(stack), 'stack should be a stack');
tt.deepEqual(data, {
ok: false,
id: 1,
Expand Down

0 comments on commit 7dcbd76

Please sign in to comment.