From d34f5fd325d7de3f190339f597dacff3928103f9 Mon Sep 17 00:00:00 2001 From: James Sumners Date: Mon, 3 May 2021 17:06:08 -0400 Subject: [PATCH] Add eslint for linting --- .eslintrc.js | 15 +++++++++++++++ .gitignore | 1 + bin/jack.js | 2 +- bin/run.js | 7 +++---- lib/mocha.js | 7 ++----- lib/repl.js | 2 +- lib/tap.js | 2 +- lib/watch.js | 9 ++++----- package.json | 6 +++++- test/cb-promise.js | 2 +- test/mocha.js | 10 ++++++---- test/repl.js | 1 - test/run/bad-rcfile.js | 4 +--- test/run/basic.js | 25 +++++++++++-------------- test/run/cat.js | 3 +-- test/run/changed.js | 2 -- test/run/coverage.js | 20 ++++++++++---------- test/run/dump-config.js | 12 ++++++------ test/run/epipe-stdout.js | 2 +- test/run/files.js | 1 - test/run/flow.js | 8 ++++---- test/run/jsx.js | 4 ++-- test/run/libtap-settings.js | 1 - test/run/output-file.js | 5 +---- test/run/rcfile-extensions.js | 4 +--- test/run/save-file.js | 6 ++---- test/run/stdin.js | 2 +- test/run/test-regex.js | 6 ++---- test/run/ts.js | 16 ++++++++-------- test/tap.js | 3 +-- test/watch.js | 2 +- 31 files changed, 93 insertions(+), 97 deletions(-) create mode 100644 .eslintrc.js diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 000000000..1df3c03da --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,15 @@ +module.exports = { + extends: 'eslint:recommended', + + env: { + node: true, + es2020: true + }, + + rules: { + 'no-prototype-builtins': 'off', + 'no-empty': 'off', + 'no-regex-spaces': 'off', + 'no-useless-escape': 'off' + } +} diff --git a/.gitignore b/.gitignore index 0de8cb3e7..d8f6b2c5d 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,4 @@ !coverage-map.js !postpublish.sh !netlify.toml +!.eslintrc.js diff --git a/bin/jack.js b/bin/jack.js index 204ffae5b..6175d25df 100644 --- a/bin/jack.js +++ b/bin/jack.js @@ -6,7 +6,6 @@ const reporters = [...new Set([ ...(require('tap-mocha-reporter').types), ...(require('treport/types')), ])] -const fs = require('fs') // nyc bundles its deps, pull reporters out of it const nycReporters = [ 'clover', @@ -692,6 +691,7 @@ Much more documentation available at: https://www.node-tap.org/ appended to the filenames.`, }), + /* eslint-disable-next-line */ debug: flag({ envDefault: 'TAP_DEBUG', description: 'Turn on debug mode', diff --git a/bin/run.js b/bin/run.js index 469a5b65f..580706622 100755 --- a/bin/run.js +++ b/bin/run.js @@ -20,7 +20,6 @@ const isexe = require('isexe') const yaml = require('tap-yaml') const path = require('path') const exists = require('fs-exists-cached').sync -const os = require('os') const maybeResolve = id => { try { @@ -358,7 +357,7 @@ const runCoverageReportOnly = options => { } /* istanbul ignore next */ -const pipeToCoveralls = async options => { +const pipeToCoveralls = async () => { const reporter = spawn(node, [nycBin, 'report', '--reporter=text-lcov'], { stdio: [ 0, 'pipe', 2 ] }) @@ -398,7 +397,7 @@ const openHtmlCoverageReport = (options, code, signal) => { } } -const nycHelp = _ => fg(node, [nycBin, '--help']) +const nycHelp = () => fg(node, [nycBin, '--help']) // export for easier testing const setupTapEnv = exports.setupTapEnv = options => { @@ -533,7 +532,7 @@ const saveFails = (options, tap) => { } catch (er) {} } - tap.on('bailout', reason => { + tap.on('bailout', () => { // add any pending test files to the fails list. fails.push.apply(fails, options.files.filter(file => successes.indexOf(file) === -1)) diff --git a/lib/mocha.js b/lib/mocha.js index 1c5b4776a..a8c01e2ca 100644 --- a/lib/mocha.js +++ b/lib/mocha.js @@ -2,7 +2,6 @@ const t = require('./tap.js') t.jobs = 1 const tapStack = [ t ] -let level = 0 const suiteStack = [] const describe = (name, fn, opt) => @@ -83,7 +82,6 @@ const it = (name, fn, options) => { name = fn.name options = options || {} const todo = !fn - const suite = suiteStack[ suiteStack.length - 1 ] const t = tapStack[ tapStack.length - 1 ] if (!name) name = '' @@ -119,7 +117,6 @@ function moment (when, fn) { t[when](function () { if (!this.options.tapMochaTest) return - const suite = suiteStack[ suiteStack.length - 1 ] const [cb, p] = cbPromise() const ret = fn.call(this, cb) @@ -144,7 +141,7 @@ exports.beforeEach = beforeEach exports.afterEach = afterEach let saved -exports.global = _ => { +exports.global = () => { if (!saved) saved = new Map() @@ -155,7 +152,7 @@ exports.global = _ => { }) } -exports.deglobal = _ => +exports.deglobal = () => Object.keys(exports).filter(g => g !== 'global').forEach(g => { if (saved && saved.has(g)) global[g] = saved.get(g) diff --git a/lib/repl.js b/lib/repl.js index 83452dbda..2a61ab490 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -175,7 +175,7 @@ class Repl { this.run(null, cb) } - exit (cb) { + exit () { this.watch.pause() this.watch.kill('SIGTERM') this.repl.close() diff --git a/lib/tap.js b/lib/tap.js index 73f0ffb0a..a0f3c9580 100644 --- a/lib/tap.js +++ b/lib/tap.js @@ -1,6 +1,6 @@ 'use strict' const {deprecate} = require('util') -const settings = require('../settings.js') +require('../settings.js') const tap = require('libtap') // Needs to be set before requiring mocha.js diff --git a/lib/watch.js b/lib/watch.js index 9dade6045..b57f117a9 100644 --- a/lib/watch.js +++ b/lib/watch.js @@ -1,10 +1,10 @@ const chokidar = require('chokidar') -const EE = require('events') const Minipass = require('minipass') const bin = require.resolve('../bin/run.js') const {spawn} = require('child_process') const onExit = require('signal-exit') -const {writeFileSync, readFileSync} = require('fs') +const fs = require('fs') +const {writeFileSync, readFileSync} = fs const {stringify} = require('tap-yaml') const {resolve} = require('path') @@ -51,7 +51,6 @@ class Watch extends Minipass { // Since a covered test was definitely included in its own // test run, don't add it a second time, so we don't get // two chokidar events for the same file change. - const cwd = process.cwd() const fileSet = new Set(Object.keys(this.index.files)) Object.keys(this.index.externalIds) .filter(f => !fileSet.has(resolve(f))) @@ -103,7 +102,7 @@ class Watch extends Minipass { this.run() } - run (env) { + run () { const set = [...new Set(this.queue)] this.log('running tests', set) writeFileSync(this.saveFile, set.join('\n') + '\n') @@ -136,7 +135,7 @@ class Watch extends Minipass { // then add those, but ignore if it's not there. const leftover = (() => { try { - return fs.readFileSync(saveFile, 'utf8').trim().split('\n') + return fs.readFileSync(this.saveFile, 'utf8').trim().split('\n') } catch (er) { return [] } diff --git a/package.json b/package.json index bdc2eeb0a..98766449f 100644 --- a/package.json +++ b/package.json @@ -49,6 +49,7 @@ "which": "^2.0.2" }, "devDependencies": { + "eslint": "^7.25.0", "flow-remove-types": "^2.112.0", "node-preload": "^0.2.1", "process-on-spawn": "^1.0.0", @@ -84,6 +85,7 @@ "test": "node bin/run.js -M coverage-map.js", "unit": "bash scripts/unit.sh", "posttest": "rm -rf cli-tests-*", + "preunit": "npm run lint", "postunit": "npm run posttest", "t": "node bin/run.js -J -sfails.txt", "preversion": "npm test", @@ -92,7 +94,8 @@ "www:build": "cd docs; npm ci; npm run build", "www:develop": "cd docs; npm run develop", "start": "npm run www:develop", - "www:serve": "cd docs; npm run serve" + "www:serve": "cd docs; npm run serve", + "lint": "eslint 'bin/*.js' 'lib/*.js' 'test/**/*.js'" }, "tap": { "test-regex": "^test/.*\\.js$", @@ -122,3 +125,4 @@ "url": "https://github.com/sponsors/isaacs" } } + diff --git a/test/cb-promise.js b/test/cb-promise.js index 8079cf2c5..86e46705d 100644 --- a/test/cb-promise.js +++ b/test/cb-promise.js @@ -1,6 +1,6 @@ const t = require('../') const cbPromise = require('../lib/cb-promise.js') -t.test('promise resolved when cb called', async t => { +t.test('promise resolved when cb called', async () => { const [cb, p] = cbPromise() cb() return p diff --git a/test/mocha.js b/test/mocha.js index 65f988aef..a2872a8ad 100644 --- a/test/mocha.js +++ b/test/mocha.js @@ -1,4 +1,6 @@ 'use strict' +/* global deglobal */ + const {mocha} = require('../lib/tap.js') const assert = require('assert') @@ -61,14 +63,14 @@ mocha.describe('globals', () => { }) if (process.version.match(/v[0-9]\./)) { - assert.throws(_ => mocha.after(), + assert.throws(() => mocha.after(), 'cannot call "after" outside of describe()') - assert.throws(_ => mocha.before(), + assert.throws(() => mocha.before(), 'cannot call "before" outside of describe()') } else { - assert.throws(_ => mocha.after(), + assert.throws(() => mocha.after(), new Error('cannot call "after" outside of describe()')) - assert.throws(_ => mocha.before(), + assert.throws(() => mocha.before(), new Error('cannot call "before" outside of describe()')) } diff --git a/test/repl.js b/test/repl.js index d30063ba0..eb1e123c3 100644 --- a/test/repl.js +++ b/test/repl.js @@ -61,7 +61,6 @@ t.teardown(() => { const {Repl} = require('../lib/repl.js') const input = new Minipass({encoding: 'utf8'}) -const {PassThrough} = require('stream') const output = new Minipass({encoding: 'utf8'}) const repl = new Repl({}, input, output) diff --git a/test/run/bad-rcfile.js b/test/run/bad-rcfile.js index 45fb4ed7b..78ccf0909 100644 --- a/test/run/bad-rcfile.js +++ b/test/run/bad-rcfile.js @@ -1,7 +1,5 @@ const { - tmpfile, run, - tap, dir, t, } = require('./') @@ -9,7 +7,7 @@ const { const fs = require('fs') t.test('bad rc file', t => { fs.writeFileSync(`${dir}/.taprc`, 'this : is not : valid : yaml') - run(['--dump-config'], { cwd: dir }, (er, o, e) => { + run(['--dump-config'], { cwd: dir }, (er) => { t.match(er, { code: 1 }) t.end() }) diff --git a/test/run/basic.js b/test/run/basic.js index bd2885ca2..eb1c5b3dc 100644 --- a/test/run/basic.js +++ b/test/run/basic.js @@ -1,11 +1,8 @@ -const fs = require('fs') const mkdirp = require('mkdirp') const { tmpfile, run, - bin, tap, - node, dir, t, } = require('./') @@ -14,7 +11,7 @@ if (process.env.TAP_SNAPSHOT !== '1') t.jobs = require('os').cpus.length t.test('no args', t => { - const c = run([], { + run([], { cwd: dir, }, (er, o, e) => { t.match(er, { code: 1 }) @@ -34,7 +31,7 @@ t.test('stdin parsing', t => { }) t.test('--help', t => { - run(['--help'], null, (er, o, e) => { + run(['--help'], null, (er, o) => { t.equal(er, null) t.match(o, /^Usage:/) t.end() @@ -42,7 +39,7 @@ t.test('--help', t => { }) t.test('--nyc-help', t => { - run(['--nyc-help'], null, (er, o, e) => { + run(['--nyc-help'], null, (er, o) => { t.equal(er, null) t.match(o, /\nOptions:\n/) t.end() @@ -50,7 +47,7 @@ t.test('--nyc-help', t => { }) t.test('--version', t => { - run(['--version'], null, (er, o, e) => { + run(['--version'], null, (er, o) => { t.equal(er, null) t.equal(o.trim(), require('../../package.json').version) t.end() @@ -58,7 +55,7 @@ t.test('--version', t => { }) t.test('--versions', t => { - run(['--versions'], null, (er, o, e) => { + run(['--versions'], null, (er, o) => { t.equal(er, null) t.matchSnapshot(o.replace(/^([^:]+): (.*)$/gm, '$1: {version}'), 'output') t.end() @@ -66,7 +63,7 @@ t.test('--versions', t => { }) t.test('--parser-version', t => { - run(['--parser-version'], null, (er, o, e) => { + run(['--parser-version'], null, (er, o) => { t.equal(er, null) t.matchSnapshot(o, 'output') t.end() @@ -74,7 +71,7 @@ t.test('--parser-version', t => { }) t.test('--nyc-version', t => { - run(['--nyc-version'], null, (er, o, e) => { + run(['--nyc-version'], null, (er, o) => { t.equal(er, null) t.equal(o.trim(), require('nyc/package.json').version) t.end() @@ -100,7 +97,7 @@ t.test('unknown short opt', t => { t.test('basic test run', t => { const ok = tmpfile(t, 'ok.js', `require(${tap}).pass('this is fine')`) const args = ['-iSCbFt0', '-g/nope/i', '--', ok] - run(args, null, (err, stdout, stderr) => { + run(args, null, (err, stdout) => { t.matchSnapshot(stdout, 'ok.js output') t.end() }) @@ -109,11 +106,11 @@ t.test('basic test run', t => { t.test('ignored files', t => { mkdirp.sync(`${dir}/ig/test/node_modules`) mkdirp.sync(`${dir}/ig/node_modules`) - const ok = tmpfile(t, 'ig/test/ok.js', + tmpfile(t, 'ig/test/ok.js', `require(${tap}).pass('this is fine')`) - const nope = tmpfile(t, 'ig/node_modules/nope.test.js', + tmpfile(t, 'ig/node_modules/nope.test.js', `require(${tap}).fail('i should not be included')`) - const nope2 = tmpfile(t, 'ig/test/node_modules/nope.test.js', + tmpfile(t, 'ig/test/node_modules/nope.test.js', `require(${tap}).fail('should also not be included')`) tmpfile(t, 'ig/test/node_modules/foo.test.js', `require(${tap}).fail('no foo included')`) diff --git a/test/run/cat.js b/test/run/cat.js index a387d897d..090b4f29f 100644 --- a/test/run/cat.js +++ b/test/run/cat.js @@ -1,7 +1,6 @@ const { tmpfile, run, - tap, t, } = require('./') @@ -11,7 +10,7 @@ t.test('cat', t => { 1..1 ok 1 - this is fine `) - run([ok], {}, (er, o, e) => { + run([ok], {}, (er, o) => { t.equal(er, null) t.matchSnapshot(o) t.end() diff --git a/test/run/changed.js b/test/run/changed.js index 3430a7f1a..83cbfe6d5 100644 --- a/test/run/changed.js +++ b/test/run/changed.js @@ -17,8 +17,6 @@ const cwd = process.cwd() process.chdir(dir) t.teardown(() => process.chdir(cwd)) -const {resolve} = require('path') - const oktest = tmpfile(t, 'ok.test.js', ` const t = require(${tap}) t.match(require('./ok.js), { ok: true }) diff --git a/test/run/coverage.js b/test/run/coverage.js index ed43ca9e1..a0e4e5546 100644 --- a/test/run/coverage.js +++ b/test/run/coverage.js @@ -12,7 +12,7 @@ const { const { execFile } = require('child_process') const path = require('path') -const ok = tmpfile(t, 'ok.js', `'use strict' +tmpfile(t, 'ok.js', `'use strict' module.exports = (x, y) => { if (x) return y || x @@ -28,7 +28,7 @@ const t2 = tmpfile(t, '2.test.js', `'use strict' const ok = require('./ok.js') require(${tap}).equal(ok(1, 2), 2)`) -const t3 = tmpfile(t, '3.test.js', `'use strict' +tmpfile(t, '3.test.js', `'use strict' const ok = require('./ok.js') require(${tap}).equal(ok(0, 3), 3)`) @@ -69,7 +69,7 @@ const escape = (args, options, cb) => { } t.test('generate some coverage', t => { - escape([t1, t2, '--no-check-coverage'], null, (er, o, e) => { + escape([t1, t2, '--no-check-coverage'], null, (er, o) => { t.equal(er, null) t.matchSnapshot(o, 'output') t.end() @@ -80,7 +80,7 @@ t.test('use a coverage map', t => { const map = tmpfile(t, 'coverage-map.js', ` module.exports = () => 'ok.js' `) - escape(['--no-check-coverage', t1, t2, '-M', map], null, (er, o, e) => { + escape(['--no-check-coverage', t1, t2, '-M', map], null, (er, o) => { t.equal(er, null) t.matchSnapshot(o, 'output') t.end() @@ -88,7 +88,7 @@ module.exports = () => 'ok.js' }) t.test('report only', t => { - escape(['--no-check-coverage', '--coverage-report=text-lcov'], null, (er, o, e) => { + escape(['--no-check-coverage', '--coverage-report=text-lcov'], null, (er, o) => { t.equal(er, null) t.matchSnapshot(o, 'lcov output', { skip: winSkip }) t.end() @@ -96,7 +96,7 @@ t.test('report only', t => { }) t.test('report with checks', t => { - escape(['--100', '--coverage-report=text-lcov'], null, (er, o, e) => { + escape(['--100', '--coverage-report=text-lcov'], null, (er, o) => { t.match(er, { code: 1 }) t.matchSnapshot(o, 'lcov output and 100 check', { skip: winSkip }) t.end() @@ -104,7 +104,7 @@ t.test('report with checks', t => { }) t.test('in 100 mode, <100 is red, not yellow', t => { - escape(['--100', '--coverage-report=text', '--color'], null, (er, o, e) => { + escape(['--100', '--coverage-report=text', '--color'], null, (er, o) => { t.match(er, { code: 1 }) t.matchSnapshot(o, 'text output and 100 check', { skip: winSkip }) t.end() @@ -112,7 +112,7 @@ t.test('in 100 mode, <100 is red, not yellow', t => { }) t.test('pipe to service', t => { - const piper = tmpfile(t, 'piper.js', ` + tmpfile(t, 'piper.js', ` process.stdin.pipe(process.stderr) `) escape(['--no-check-coverage', '--coverage-report=text'], { env: { @@ -126,7 +126,7 @@ t.test('pipe to service', t => { }) t.test('pipe to service along with tests', t => { - const piper = tmpfile(t, 'piper.js', ` + tmpfile(t, 'piper.js', ` process.stdin.pipe(process.stderr) `) escape(['--no-check-coverage', t1, t2, '--coverage-report=text'], { env: { @@ -143,7 +143,7 @@ t.test('borked coverage map means no includes', t => { const map = tmpfile(t, 'coverage-map.js', ` module.exports = () => {} `) - escape([t1, t2, '-M', map], null, (er, o, e) => { + escape([t1, t2, '-M', map], null, (er, o) => { t.equal(er, null) t.matchSnapshot(o, 'output') t.end() diff --git a/test/run/dump-config.js b/test/run/dump-config.js index 8bd774d18..a1918770d 100644 --- a/test/run/dump-config.js +++ b/test/run/dump-config.js @@ -23,7 +23,7 @@ t.test('shotgun a bunch of option parsing junk', t => { ], { env: { TAP: '0', TAP_BAIL: '0', - }}, (er, o, e) => { + }}, (er, o) => { t.equal(er, null) t.matchSnapshot(o, 'output') t.end() @@ -54,7 +54,7 @@ t.test('package.json parsing', t => { const dir = path.dirname(pj) run(['--dump-config', '-B'], { cwd: dir, - }, (er, o, e) => { + }, (er, o) => { t.equal(er, null) t.matchSnapshot(o, 'output') t.end() @@ -68,7 +68,7 @@ t.test('turn color off and back on again', t => { run(['--no-color', '-c', '--dump-config'], { env: { TAP: '0', TAP_COLORS: '1', - }}, (er, o, e) => { + }}, (er, o) => { t.equal(er, null) t.matchSnapshot(o, 'output') t.end() @@ -78,7 +78,7 @@ t.test('turn color off and back on again', t => { t.test('short options as well as short flags', t => { run(['--dump-config','-j2','-Cb','-t=0' ], { env: { TAP: '0' - }}, (er, o, e) => { + }}, (er, o) => { t.equal(er, null) t.matchSnapshot(o, 'output') t.end() @@ -94,7 +94,7 @@ jobs: 3 run(['--dump-config', '-j4'], { env: { TAP_RCFILE: rc, TAP: 0 - }}, (er, o, e) => { + }}, (er, o) => { t.equal(er, null) t.matchSnapshot(o, 'output') t.end() @@ -107,7 +107,7 @@ t.test('empty rc file', t => { TAP_RCFILE: rc, TAP: '0', TAP_COLORS: '1' - }}, (er, o, e) => { + }}, (er, o) => { t.equal(er, null) t.matchSnapshot(o, 'output') t.end() diff --git a/test/run/epipe-stdout.js b/test/run/epipe-stdout.js index 88231ade4..db9001ee0 100644 --- a/test/run/epipe-stdout.js +++ b/test/run/epipe-stdout.js @@ -4,7 +4,7 @@ const { } = require('./') t.plan(2) -const c = run(['-', '-C'], { stdio: 'pipe' }, (er, o, e) => { +const c = run(['-', '-C'], { stdio: 'pipe' }, (er, o) => { t.equal(er, null) t.equal(o, str) }) diff --git a/test/run/files.js b/test/run/files.js index c44111347..231f909c8 100644 --- a/test/run/files.js +++ b/test/run/files.js @@ -5,7 +5,6 @@ const { t, clean, } = require('./') -const yaml = require('tap-yaml') const one = tmpfile(t, 'one.js', ` const t = require(${tap}) diff --git a/test/run/flow.js b/test/run/flow.js index 48e681b31..a218c86c6 100644 --- a/test/run/flow.js +++ b/test/run/flow.js @@ -18,7 +18,7 @@ t.test('flow', t => { const args = [ok, '--flow'] - run(args, {}, (er, o, e) => { + run(args, {}, (er, o) => { t.equal(er, null) t.matchSnapshot(o) t.end() @@ -36,10 +36,10 @@ t.test('flow manually', t => { `) const args = [ok, '--node-arg=--require', '--node-arg=flow-remove-types/register'] - - run(args, {}, (er, o, e) => { + + run(args, {}, (er, o) => { t.equal(er, null) t.matchSnapshot(o) t.end() }) -}) \ No newline at end of file +}) diff --git a/test/run/jsx.js b/test/run/jsx.js index 5d83855a0..3ceb2fc5a 100644 --- a/test/run/jsx.js +++ b/test/run/jsx.js @@ -14,7 +14,7 @@ t.test('jsx', t => { const div = (
Hello
) t.pass('this is fine') `) - run([ok], {}, (er, o, e) => { + run([ok], {}, (er, o) => { t.equal(er, null) t.matchSnapshot(o) t.end() @@ -24,7 +24,7 @@ t.test('jsx', t => { t.test('running jsx thingie directly raises an error', t => { const jsx = require.resolve('../../bin/jsx.js') const {execFile} = require('child_process') - execFile(process.execPath, [jsx], (er, o, e) => { + execFile(process.execPath, [jsx], (er) => { t.match(er, { code: 1 }) t.end() }) diff --git a/test/run/libtap-settings.js b/test/run/libtap-settings.js index 21b711998..c736d614d 100644 --- a/test/run/libtap-settings.js +++ b/test/run/libtap-settings.js @@ -1,5 +1,4 @@ const { - tmpfile, run, tap, t, diff --git a/test/run/output-file.js b/test/run/output-file.js index 7d5fd67f0..097655caf 100644 --- a/test/run/output-file.js +++ b/test/run/output-file.js @@ -1,12 +1,9 @@ const { tmpfile, run, - bin, tap, - node, dir, - t, - winSkip, + t } = require('./') const path = require('path') diff --git a/test/run/rcfile-extensions.js b/test/run/rcfile-extensions.js index 759c18305..8118f66a4 100644 --- a/test/run/rcfile-extensions.js +++ b/test/run/rcfile-extensions.js @@ -1,10 +1,8 @@ const { run, - dir, t, } = require('./') -const fs = require('fs') t.test('finds rc file with .yaml and .yml', t => { const files = [ '.taprc', @@ -18,7 +16,7 @@ t.test('finds rc file with .yaml and .yml', t => { const cwd = t.testdir({ [file]: 'check-coverage: false', }) - run(['--dump-config'], { cwd }, (er, o, e) => { + run(['--dump-config'], { cwd }, (er, o) => { t.match(o, /check-coverage: false/) t.end() }) diff --git a/test/run/save-file.js b/test/run/save-file.js index 50aa02105..b6da06912 100644 --- a/test/run/save-file.js +++ b/test/run/save-file.js @@ -1,9 +1,7 @@ const { tmpfile, run, - bin, tap, - node, dir, t, winSkip, @@ -14,12 +12,12 @@ const { const path = require('path') const fs = require('fs') -const xy1 = tmpfile(t, 'x/y/1.js', ` +tmpfile(t, 'x/y/1.js', ` const t = require(${tap}) t.pass('one') `) -const ab2 = tmpfile(t, 'a/b/2.js', ` +tmpfile(t, 'a/b/2.js', ` const t = require(${tap}) t.pass('2') `) diff --git a/test/run/stdin.js b/test/run/stdin.js index 86a80d6e8..e79da6805 100644 --- a/test/run/stdin.js +++ b/test/run/stdin.js @@ -44,7 +44,7 @@ t.test('with file', t => { }) `) const args = ['-', foo, '-CRclassic', '-ofoo.txt'] - const c = run(args, { env: { TAP: 0, TAP_BUFFER: 1 }}, (er, o, e) => { + const c = run(args, { env: { TAP: 0, TAP_BUFFER: 1 }}, (er, o) => { t.equal(er, null) t.matchSnapshot(fs.readFileSync('foo.txt', 'utf8')) t.match(o, /foo.test.js \.+ 1\/1.*\n\/dev\/stdin \.+ 1\/1\n/) diff --git a/test/run/test-regex.js b/test/run/test-regex.js index 3750b6c3f..12a48aea8 100644 --- a/test/run/test-regex.js +++ b/test/run/test-regex.js @@ -1,8 +1,6 @@ const { tmpfile, - bin, tap, - node, dir, t, run, @@ -21,7 +19,7 @@ t.test('no args, pull in default files, not exclusions', t => { const t = require(${tap}) t.fail('should not run this') `) - run([], { cwd: dir }, (er, o, e) => { + run([], { cwd: dir }, (er, o) => { t.equal(er, null) t.matchSnapshot(o, 'output') t.end() @@ -29,7 +27,7 @@ t.test('no args, pull in default files, not exclusions', t => { }) t.test('error out if loading files fails', t => { - run([], { cwd: '/dev' }, (er, o, e) => { + run([], { cwd: '/dev' }, (er) => { t.match(er, { code: 1 }) t.end() }) diff --git a/test/run/ts.js b/test/run/ts.js index 3e171ecb2..d653d3e3c 100644 --- a/test/run/ts.js +++ b/test/run/ts.js @@ -17,7 +17,7 @@ t.test('via env', t => { import * as t from ${tap} t.pass('this is fine') `) - run([ok], {}, (er, o, e) => { + run([ok], {}, (er, o) => { t.equal(er, null) t.matchSnapshot(o) t.end() @@ -29,7 +29,7 @@ t.test('via env', t => { import * as t from ${tap} t.pass('this is fine') `) - run([ok], {}, (er, o, e) => { + run([ok], {}, (er, o) => { t.ok(er) t.matchSnapshot(o) t.end() @@ -44,7 +44,7 @@ t.test('via env', t => { const div = (
Hello
) t.pass('this is fine') `) - run([ok], {}, (er, o, e) => { + run([ok], {}, (er, o) => { t.ok(er) t.matchSnapshot(o) t.end() @@ -60,7 +60,7 @@ t.test('via env', t => { const div = (
Hello
) t.pass('this is fine') `) - run([ok], {}, (er, o, e) => { + run([ok], {}, (er, o) => { t.equal(er, null) t.matchSnapshot(o) t.end() @@ -76,7 +76,7 @@ t.test('via cli args', t => { import * as t from ${tap} t.pass('this is fine') `) - run([ok, '--ts'], {}, (er, o, e) => { + run([ok, '--ts'], {}, (er, o) => { t.equal(er, null) t.matchSnapshot(o) t.end() @@ -90,7 +90,7 @@ t.test('via cli args', t => { const div = (
Hello
) t.pass('this is fine') `) - run([ok, '--ts'], {}, (er, o, e) => { + run([ok, '--ts'], {}, (er, o) => { t.ok(er) t.matchSnapshot(o) t.end() @@ -104,7 +104,7 @@ t.test('via cli args', t => { const div = (
Hello
) t.pass('this is fine') `) - run([ok, '--ts', '--jsx'], {}, (er, o, e) => { + run([ok, '--ts', '--jsx'], {}, (er, o) => { t.equal(er, null) t.matchSnapshot(o) t.end() @@ -123,7 +123,7 @@ t.test('ts manually', t => { t.pass('this is fine') `) const args = [ok, foots, '--no-ts', '--node-arg=--require', '--node-arg=ts-node/register'] - run(args, {}, (er, o, e) => { + run(args, {}, (er, o) => { t.equal(er, null) t.matchSnapshot(o) t.end() diff --git a/test/tap.js b/test/tap.js index af0999c54..41d47ff5c 100644 --- a/test/tap.js +++ b/test/tap.js @@ -6,8 +6,7 @@ const synonyms = require('../lib/synonyms.js') function testSynonyms(settings) { let warnings; - const {emitWarning} = process; - process.emitWarning = (msg, ...args) => { + process.emitWarning = (msg) => { warnings.push(msg) } diff --git a/test/watch.js b/test/watch.js index 060d0eca4..4f530185e 100644 --- a/test/watch.js +++ b/test/watch.js @@ -188,7 +188,7 @@ t.test('run tests on changes', t => { t.test('change a file', t => { // initial test done, change a file - spawnTrack.once('spawn', proc => { + spawnTrack.once('spawn', () => { t.matchSnapshot(read(saveFile), 'spawn test run on change') t.matchSnapshot(out.join(''), 'logs') out.length = 0