Skip to content

Commit bbbf498

Browse files
aduh95RafaelGSS
authored andcommitted
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 9f1ad3c commit bbbf498

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
-112
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';

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy