Skip to content

Commit dc732b1

Browse files
committed
tools: enable linter in test/fixtures/test-runner/output
PR-URL: #57698 Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Pietro Marchini <pietro.marchini94@gmail.com>
1 parent 1788223 commit dc732b1

Some content is hidden

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

45 files changed

+178
-106
lines changed

eslint.config.mjs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { readdirSync } from 'node:fs';
12
import Module from 'node:module';
23
import { fileURLToPath, URL } from 'node:url';
34

@@ -25,6 +26,12 @@ const { default: stylisticJs } = await importEslintTool('@stylistic/eslint-plugi
2526

2627
nodeCore.RULES_DIR = fileURLToPath(new URL('./tools/eslint-rules', import.meta.url));
2728

29+
function filterFilesInDir(dirpath, filterFn) {
30+
return readdirSync(dirpath)
31+
.filter(filterFn)
32+
.map((f) => `${dirpath}/${f}`);
33+
}
34+
2835
// The Module._resolveFilename() monkeypatching is to make it so that ESLint is able to
2936
// dynamically load extra modules that we install with it.
3037
const ModuleResolveFilename = Module._resolveFilename;
@@ -54,6 +61,14 @@ export default [
5461
'test/fixtures/*',
5562
'!test/fixtures/console',
5663
'!test/fixtures/eval',
64+
'!test/fixtures/test-runner',
65+
'test/fixtures/test-runner/*',
66+
'!test/fixtures/test-runner/output',
67+
...filterFilesInDir(
68+
'test/fixtures/test-runner/output',
69+
// Filtering tsc output files (i.e. if there a foo.ts, we ignore foo.js):
70+
(f, _, files) => f.endsWith('js') && files.includes(f.replace(/\.[cm]?js$/, '.ts')),
71+
),
5772
'!test/fixtures/v8',
5873
'!test/fixtures/vm',
5974
]),

test/fixtures/test-runner/output/abort_hooks.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ describe('1 before describe', () => {
55
const ac = new AbortController();
66
before(() => {
77
console.log('before');
8-
ac.abort()
9-
}, {signal: ac.signal});
8+
ac.abort();
9+
}, { signal: ac.signal });
1010

1111
it('test 1', () => {
1212
console.log('1.1');
@@ -20,8 +20,8 @@ describe('2 after describe', () => {
2020
const ac = new AbortController();
2121
after(() => {
2222
console.log('after');
23-
ac.abort()
24-
}, {signal: ac.signal});
23+
ac.abort();
24+
}, { signal: ac.signal });
2525

2626
it('test 1', () => {
2727
console.log('2.1');
@@ -35,8 +35,8 @@ describe('3 beforeEach describe', () => {
3535
const ac = new AbortController();
3636
beforeEach(() => {
3737
console.log('beforeEach');
38-
ac.abort()
39-
}, {signal: ac.signal});
38+
ac.abort();
39+
}, { signal: ac.signal });
4040

4141
it('test 1', () => {
4242
console.log('3.1');
@@ -50,8 +50,8 @@ describe('4 afterEach describe', () => {
5050
const ac = new AbortController();
5151
afterEach(() => {
5252
console.log('afterEach');
53-
ac.abort()
54-
}, {signal: ac.signal});
53+
ac.abort();
54+
}, { signal: ac.signal });
5555

5656
it('test 1', () => {
5757
console.log('4.1');

test/fixtures/test-runner/output/arbitrary-output-colored.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,8 @@ const fixtures = require('../../../common/fixtures');
88
const test = fixtures.path('test-runner/output/arbitrary-output-colored-1.js');
99
const reset = fixtures.path('test-runner/output/reset-color-depth.js');
1010
await once(spawn(process.execPath, ['-r', reset, '--test', test], { stdio: 'inherit' }), 'exit');
11-
await once(spawn(process.execPath, ['-r', reset, '--test', '--test-reporter', 'tap', test], { stdio: 'inherit' }), 'exit');
11+
await once(
12+
spawn(process.execPath, ['-r', reset, '--test', '--test-reporter', 'tap', test], { stdio: 'inherit' }),
13+
'exit',
14+
);
1215
})().then(common.mustCall());

test/fixtures/test-runner/output/arbitrary-output.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,19 @@ const v8_reporter = require('internal/test_runner/reporter/v8-serializer');
55
const { Buffer } = require('buffer');
66

77

8-
(async function () {
8+
// eslint-disable-next-line node-core/async-iife-no-unused-result
9+
(async function() {
910
const reported = v8_reporter([
10-
{ type: "test:pass", data: { name: "test", nesting: 0, file: __filename, testNumber: 1, details: { duration_ms: 0 } } }
11+
{
12+
type: 'test:pass',
13+
data: { name: 'test', nesting: 0, file: __filename, testNumber: 1, details: { duration_ms: 0 } },
14+
},
1115
]);
1216

1317
for await (const chunk of reported) {
1418
process.stdout.write(chunk);
15-
process.stdout.write(Buffer.concat([Buffer.from("arbitrary - pre"), chunk]));
16-
process.stdout.write(Buffer.from("arbitrary - mid"));
17-
process.stdout.write(Buffer.concat([chunk, Buffer.from("arbitrary - post")]));
19+
process.stdout.write(Buffer.concat([Buffer.from('arbitrary - pre'), chunk]));
20+
process.stdout.write(Buffer.from('arbitrary - mid'));
21+
process.stdout.write(Buffer.concat([chunk, Buffer.from('arbitrary - post')]));
1822
}
1923
})();
20-
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import assert from 'node:assert/strict'
2-
import { test } from 'node:test'
1+
import assert from 'node:assert/strict';
2+
import { test } from 'node:test';
33

44
test('failing assertion', () => {
5-
assert.strictEqual('!Hello World', 'Hello World!')
6-
})
5+
assert.strictEqual('!Hello World', 'Hello World!');
6+
});

test/fixtures/test-runner/output/before-and-after-each-too-many-listeners.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'use strict';
2-
const { beforeEach, afterEach, test} = require("node:test");
2+
const { beforeEach, afterEach, test } = require('node:test');
33
beforeEach(() => {});
44
afterEach(() => {});
55

test/fixtures/test-runner/output/before-and-after-each-with-timeout-too-many-listeners.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
2-
const { beforeEach, afterEach, test} = require("node:test");
3-
beforeEach(() => {}, {timeout: 10000});
4-
afterEach(() => {}, {timeout: 10000});
2+
const { beforeEach, afterEach, test } = require('node:test');
3+
beforeEach(() => {}, { timeout: 10000 });
4+
afterEach(() => {}, { timeout: 10000 });
55

66
for (let i = 1; i <= 11; ++i) {
77
test(`${i}`, () => {});

test/fixtures/test-runner/output/coverage-width-100-uncovered-lines.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
// Flags: --experimental-test-coverage
22
// here we can't import common module as the coverage will be different based on the system
33
// Unused imports are here in order to populate the coverage report
4+
// eslint-disable-next-line no-unused-vars
45
import * as a from '../coverage-snap/b.js';
6+
// eslint-disable-next-line no-unused-vars
57
import * as b from '../coverage-snap/a.js';
8+
// eslint-disable-next-line no-unused-vars
69
import * as c from '../coverage-snap/many-uncovered-lines.js';
710

811
import { test } from 'node:test';

test/fixtures/test-runner/output/coverage-width-100-uncovered-lines.snapshot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ ok 1 - Coverage Print Fixed Width 100
2828
# output | | | |
2929
# coverage-width-100-uncovered-lines.mjs | 100.00 | 100.00 | 100.00 |
3030
# --------------------------------------------------------------------------------------------------
31-
# all files | 52.80 | 60.00 | 1.61 |
31+
# all files | 53.13 | 60.00 | 1.61 |
3232
# --------------------------------------------------------------------------------------------------
3333
# end of coverage report

test/fixtures/test-runner/output/coverage-width-100.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// Flags: --experimental-test-coverage
22
// here we can't import common module as the coverage will be different based on the system
33
// Unused imports are here in order to populate the coverage report
4+
// eslint-disable-next-line no-unused-vars
45
import * as a from '../coverage-snap/b.js';
6+
// eslint-disable-next-line no-unused-vars
57
import * as b from '../coverage-snap/a.js';
68

79
import { test } from 'node:test';

test/fixtures/test-runner/output/coverage-width-100.snapshot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ ok 1 - Coverage Print Fixed Width 100
2727
# output | | | |
2828
# coverage-width-100.mjs | 100.00 | 100.00 | 100.00 |
2929
# --------------------------------------------------------------------------------------------------
30-
# all files | 60.81 | 100.00 | 0.00 |
30+
# all files | 61.84 | 100.00 | 0.00 |
3131
# --------------------------------------------------------------------------------------------------
3232
# end of coverage report

test/fixtures/test-runner/output/coverage-width-150-uncovered-lines.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
// Flags: --experimental-test-coverage
22
// here we can't import common module as the coverage will be different based on the system
33
// Unused imports are here in order to populate the coverage report
4+
// eslint-disable-next-line no-unused-vars
45
import * as a from '../coverage-snap/b.js';
6+
// eslint-disable-next-line no-unused-vars
57
import * as b from '../coverage-snap/a.js';
8+
// eslint-disable-next-line no-unused-vars
69
import * as c from '../coverage-snap/many-uncovered-lines.js';
710

811
import { test } from 'node:test';

test/fixtures/test-runner/output/coverage-width-150-uncovered-lines.snapshot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ ok 1 - Coverage Print Fixed Width 150
2828
# output | | | |
2929
# coverage-width-150-uncovered-lines.mjs | 100.00 | 100.00 | 100.00 |
3030
# ----------------------------------------------------------------------------------------------------------------------------------------------------
31-
# all files | 52.80 | 60.00 | 1.61 |
31+
# all files | 53.13 | 60.00 | 1.61 |
3232
# ----------------------------------------------------------------------------------------------------------------------------------------------------
3333
# end of coverage report

test/fixtures/test-runner/output/coverage-width-150.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// Flags: --experimental-test-coverage
22
// here we can't import common module as the coverage will be different based on the system
33
// Unused imports are here in order to populate the coverage report
4+
// eslint-disable-next-line no-unused-vars
45
import * as a from '../coverage-snap/b.js';
6+
// eslint-disable-next-line no-unused-vars
57
import * as b from '../coverage-snap/a.js';
68

79
import { test } from 'node:test';

test/fixtures/test-runner/output/coverage-width-150.snapshot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ ok 1 - Coverage Print Fixed Width 150
2727
# output | | | |
2828
# coverage-width-150.mjs | 100.00 | 100.00 | 100.00 |
2929
# --------------------------------------------------------------------------------------------------------
30-
# all files | 60.81 | 100.00 | 0.00 |
30+
# all files | 61.84 | 100.00 | 0.00 |
3131
# --------------------------------------------------------------------------------------------------------
3232
# end of coverage report

test/fixtures/test-runner/output/coverage-width-40.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
// Flags: --experimental-test-coverage
22
// here we can't import common module as the coverage will be different based on the system
33
// Unused imports are here in order to populate the coverage report
4+
// eslint-disable-next-line no-unused-vars
45
import * as a from '../coverage-snap/b.js';
6+
// eslint-disable-next-line no-unused-vars
57
import * as b from '../coverage-snap/a.js';
8+
// eslint-disable-next-line no-unused-vars
69
import * as c from '../coverage-snap/a-very-long-long-long-sub-dir/c.js';
710

811
import { test } from 'node:test';

test/fixtures/test-runner/output/coverage-width-40.snapshot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ ok 1 - Coverage Print Fixed Width 40
2929
# output | | | |
3030
# …e-width-40.mjs | 100.00 | 100.00 | 100.00 |
3131
# --------------------------------------
32-
# all files | 59.06 | 100.00 | 0.00 |
32+
# all files | 60.00 | 100.00 | 0.00 |
3333
# --------------------------------------
3434
# end of coverage report

test/fixtures/test-runner/output/coverage-width-80-color.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// Flags: --experimental-test-coverage
22
// here we can't import common module as the coverage will be different based on the system
33
// Unused imports are here in order to populate the coverage report
4+
// eslint-disable-next-line no-unused-vars
45
import * as a from '../coverage-snap/b.js';
6+
// eslint-disable-next-line no-unused-vars
57
import * as b from '../coverage-snap/a.js';
68

79
import { test } from 'node:test';

test/fixtures/test-runner/output/coverage-width-80-uncovered-lines-color.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
// Flags: --experimental-test-coverage
22
// here we can't import common module as the coverage will be different based on the system
33
// Unused imports are here in order to populate the coverage report
4+
// eslint-disable-next-line no-unused-vars
45
import * as a from '../coverage-snap/b.js';
6+
// eslint-disable-next-line no-unused-vars
57
import * as b from '../coverage-snap/a.js';
8+
// eslint-disable-next-line no-unused-vars
69
import * as c from '../coverage-snap/many-uncovered-lines.js';
710

811
import { test } from 'node:test';

test/fixtures/test-runner/output/coverage-width-80-uncovered-lines.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
// Flags: --experimental-test-coverage
22
// here we can't import common module as the coverage will be different based on the system
33
// Unused imports are here in order to populate the coverage report
4+
// eslint-disable-next-line no-unused-vars
45
import * as a from '../coverage-snap/b.js';
6+
// eslint-disable-next-line no-unused-vars
57
import * as b from '../coverage-snap/a.js';
8+
// eslint-disable-next-line no-unused-vars
69
import * as c from '../coverage-snap/many-uncovered-lines.js';
710

811
import { test } from 'node:test';

test/fixtures/test-runner/output/coverage-width-80-uncovered-lines.snapshot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ ok 1 - Coverage Print Fixed Width 100
2828
# output | | | |
2929
# coverage-width-80-uncovered-lines.mjs | 100.00 | 100.00 | 100.00 |
3030
# --------------------------------------------------------------------------------------------------
31-
# all files | 52.80 | 60.00 | 1.61 |
31+
# all files | 53.13 | 60.00 | 1.61 |
3232
# --------------------------------------------------------------------------------------------------
3333
# end of coverage report

test/fixtures/test-runner/output/coverage-width-80.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// Flags: --experimental-test-coverage
22
// here we can't import common module as the coverage will be different based on the system
33
// Unused imports are here in order to populate the coverage report
4+
// eslint-disable-next-line no-unused-vars
45
import * as a from '../coverage-snap/b.js';
6+
// eslint-disable-next-line no-unused-vars
57
import * as b from '../coverage-snap/a.js';
68

79
import { test } from 'node:test';

test/fixtures/test-runner/output/coverage-width-80.snapshot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ ok 1 - Coverage Print Fixed Width 80
2727
# output | | | |
2828
# coverage-width-80.mjs | 100.00 | 100.00 | 100.00 |
2929
# ------------------------------------------------------------------------------
30-
# all files | 60.81 | 100.00 | 0.00 |
30+
# all files | 61.84 | 100.00 | 0.00 |
3131
# ------------------------------------------------------------------------------
3232
# end of coverage report

test/fixtures/test-runner/output/coverage-width-infinity-uncovered-lines.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
// Flags: --experimental-test-coverage
22
// here we can't import common module as the coverage will be different based on the system
33
// Unused imports are here in order to populate the coverage report
4+
// eslint-disable-next-line no-unused-vars
45
import * as a from '../coverage-snap/b.js';
6+
// eslint-disable-next-line no-unused-vars
57
import * as b from '../coverage-snap/a.js';
8+
// eslint-disable-next-line no-unused-vars
69
import * as c from '../coverage-snap/many-uncovered-lines.js';
710

811
import { test } from 'node:test';

test/fixtures/test-runner/output/coverage-width-infinity-uncovered-lines.snapshot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ ok 1 - Coverage Print Fixed Width Infinity
2828
# output | | | |
2929
# coverage-width-infinity-uncovered-lines.mjs | 100.00 | 100.00 | 100.00 |
3030
# -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
31-
# all files | 52.80 | 60.00 | 1.61 |
31+
# all files | 53.13 | 60.00 | 1.61 |
3232
# -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
3333
# end of coverage report

test/fixtures/test-runner/output/coverage-width-infinity.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// Flags: --experimental-test-coverage
22
// here we can't import common module as the coverage will be different based on the system
33
// Unused imports are here in order to populate the coverage report
4+
// eslint-disable-next-line no-unused-vars
45
import * as a from '../coverage-snap/b.js';
6+
// eslint-disable-next-line no-unused-vars
57
import * as b from '../coverage-snap/a.js';
68

79
import { test } from 'node:test';

test/fixtures/test-runner/output/coverage-width-infinity.snapshot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ ok 1 - Coverage Print Fixed Width Infinity
2727
# output | | | |
2828
# coverage-width-infinity.mjs | 100.00 | 100.00 | 100.00 |
2929
# -------------------------------------------------------------------------------------------------------------
30-
# all files | 60.81 | 100.00 | 0.00 |
30+
# all files | 61.84 | 100.00 | 0.00 |
3131
# -------------------------------------------------------------------------------------------------------------
3232
# end of coverage report

test/fixtures/test-runner/output/coverage_failure.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,3 @@ mock.method(TestCoverage.prototype, 'summary', () => {
1010
});
1111

1212
test('ok');
13-

test/fixtures/test-runner/output/describe_it.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ describe('timeouts', () => {
311311

312312
it('timed out callback test', { timeout: 5 }, (t, done) => {
313313
setTimeout(() => {
314-
// Empty timer so the process doesn't exit before the timeout triggers.
314+
// Empty timer so the process doesn't exit before the timeout triggers.
315315
}, 5);
316316
setTimeout(done, 30_000_000).unref();
317317
});
@@ -372,20 +372,20 @@ describe('rejected thenable', () => {
372372
};
373373
});
374374

375-
describe("async describe function", async () => {
375+
describe('async describe function', async () => {
376376
await null;
377377

378-
await it("it inside describe 1", async () => {
379-
await null
378+
await it('it inside describe 1', async () => {
379+
await null;
380380
});
381-
await it("it inside describe 2", async () => {
381+
await it('it inside describe 2', async () => {
382382
await null;
383383
});
384384

385-
describe("inner describe", async () => {
385+
describe('inner describe', async () => {
386386
await null;
387387

388-
it("it inside inner describe", async () => {
388+
it('it inside inner describe', async () => {
389389
await null;
390390
});
391391
});

test/fixtures/test-runner/output/filtered-suite-order.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ after(() => { console.log('with global after()'); });
55
await Promise.resolve();
66

77
console.log('Execution order was:');
8-
const ll = (t) => { console.log(` * ${t.fullName}`) };
8+
const ll = (t) => { console.log(` * ${t.fullName}`); };
99

1010
describe('A', () => {
1111
test.only('A', ll);

test/fixtures/test-runner/output/filtered-suite-throws.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const { suite, test } = require('node:test');
55

66
suite('suite 1', () => {
77
throw new Error('boom 1');
8+
// eslint-disable-next-line no-unreachable
89
test('enabled - should not run', common.mustNotCall());
910
});
1011

0 commit comments

Comments
 (0)