diff --git a/.eslintrc b/.eslintrc index 9decf5e4..1854a48b 100644 --- a/.eslintrc +++ b/.eslintrc @@ -59,6 +59,7 @@ "wrap-iife": ["error", "outside", { "functionPrototypeMethods": true, }], + "wrap-regex": "error", }, "ignorePatterns": [ "syntax-error.*" ], "overrides": [ diff --git a/lib/default_stream.js b/lib/default_stream.js index 75458a9d..b750eab8 100644 --- a/lib/default_stream.js +++ b/lib/default_stream.js @@ -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 { diff --git a/test/async-await.js b/test/async-await.js index ef88ff01..b380dfaa 100644 --- a/test/async-await.js +++ b/test/async-await.js @@ -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+)$/.test(line); + return !(/^(\s+)at(\s+)$/).test(line); }); t.same(stripFullStack(lines.join('\n')), [ @@ -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'); @@ -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+)$/.test(line); + return !(/^(\s+)at(\s+)$/).test(line); }); stdout = lines.join('\n'); @@ -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'); @@ -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+)$/.test(line); + return !(/^(\s+)at(\s+)$/).test(line); }); stdout = lines.join('\n'); diff --git a/test/ignore_from_gitignore.js b/test/ignore_from_gitignore.js index cda47b84..8260c2ec 100644 --- a/test/ignore_from_gitignore.js +++ b/test/ignore_from_gitignore.js @@ -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') }); diff --git a/test/promise_fail.js b/test/promise_fail.js index fc38fb75..a814917b 100644 --- a/test/promise_fail.js +++ b/test/promise_fail.js @@ -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\.)?(?:$|\s)/.test(line); + return !(/^(\s+)at(\s+)(?:Test\.)?(?:$|\s)/).test(line); }).join('\n'); // hack for consistency across all versions of node @@ -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\.)?(?:$|\s)/.test(line); + return !(/^(\s+)at(\s+)(?:Test\.)?(?:$|\s)/).test(line); }).join('\n'); // hack for consistency across all versions of node diff --git a/test/stackTrace.js b/test/stackTrace.js index 7906884f..fd3fedfd 100644 --- a/test/stackTrace.js +++ b/test/stackTrace.js @@ -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, @@ -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,