Skip to content

Commit eb2b48d

Browse files
authored
Update XO & other dependencies
1 parent 50e02d5 commit eb2b48d

File tree

109 files changed

+2070
-2646
lines changed

Some content is hidden

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

109 files changed

+2070
-2646
lines changed

.xo-config.cjs

Lines changed: 0 additions & 100 deletions
This file was deleted.

ava.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import process from 'node:process';
22

33
const skipWatchMode = process.env.TEST_AVA_SKIP_WATCH_MODE ? ['!test/watch-mode/**'] : [];
44

5-
export default { // eslint-disable-line import/no-anonymous-default-export
5+
export default { // eslint-disable-line import-x/no-anonymous-default-export
66
files: ['test/**', '!test/**/{fixtures,helpers}/**', ...skipWatchMode],
77
watchMode: {
88
ignoreChanges: ['{coverage,docs,media,test-types,test-tap}/**'],

entrypoints/main.d.cts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import type {TestFn} from '../types/test-fn.cjs';
22

3-
export * from '../types/assertions.cjs';
4-
export * from '../types/try-fn.cjs';
5-
export * from '../types/test-fn.cjs';
6-
export * from '../types/subscribable.cjs';
3+
export type * from '../types/assertions.cjs';
4+
export type * from '../types/try-fn.cjs';
5+
export type * from '../types/test-fn.cjs';
6+
export type * from '../types/subscribable.cjs';
77

88
/** Call to declare a test, or chain to declare hooks or test modifiers */
99
declare const test: TestFn;

entrypoints/main.d.mts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import type {TestFn} from '../types/test-fn.cjs';
22

3-
export * from '../types/assertions.cjs';
4-
export * from '../types/try-fn.cjs';
5-
export * from '../types/test-fn.cjs';
6-
export * from '../types/subscribable.cjs';
3+
export type * from '../types/assertions.cjs';
4+
export type * from '../types/try-fn.cjs';
5+
export type * from '../types/test-fn.cjs';
6+
export type * from '../types/subscribable.cjs';
77

88
/** Call to declare a test, or chain to declare hooks or test modifiers */
99
declare const test: TestFn;

lib/api.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,14 @@ export default class Api extends Emittery {
152152
if (typeof testFileSelector === 'function') {
153153
selectedFiles = testFileSelector(testFiles, selectedFiles);
154154
} else if (selectedFiles.length === 0) {
155-
selectedFiles = filter.length === 0 ? testFiles : globs.applyTestFileFilter({
156-
cwd: this.options.projectDir,
157-
filter: filter.map(({pattern}) => pattern),
158-
providers,
159-
testFiles,
160-
});
155+
selectedFiles = filter.length === 0
156+
? testFiles
157+
: globs.applyTestFileFilter({
158+
cwd: this.options.projectDir,
159+
filter: filter.map(({pattern}) => pattern),
160+
providers,
161+
testFiles,
162+
});
161163
}
162164
} catch (error) {
163165
selectedFiles = [];
@@ -291,7 +293,7 @@ export default class Api extends Emittery {
291293
deregisteredSharedWorkers.push(observeWorkerProcess(worker, runStatus));
292294

293295
pendingWorkers.add(worker);
294-
worker.promise.then(() => {
296+
worker.promise.then(() => { // eslint-disable-line promise/prefer-await-to-then
295297
pendingWorkers.delete(worker);
296298
});
297299
timeoutTrigger.debounce();

lib/assert.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ export class Assertions {
490490
// Record the stack before it gets lost in the promise chain.
491491
const assertionStack = getAssertionStack();
492492
// Handle "promise like" objects by casting to a real Promise.
493-
const intermediate = Promise.resolve(promise).then(value => { // eslint-disable-line promise/prefer-await-to-then
493+
const intermediate = Promise.resolve(promise).then(value => { // eslint-disable-line promise/prefer-catch, promise/prefer-await-to-then
494494
throw failPending(new AssertionError(message, {
495495
assertion: 't.throwsAsync()',
496496
assertionStack,
@@ -592,7 +592,7 @@ export class Assertions {
592592
// Create an error object to record the stack before it gets lost in the promise chain.
593593
const assertionStack = getAssertionStack();
594594
// Handle "promise like" objects by casting to a real Promise.
595-
const intermediate = Promise.resolve(promise).then(noop, error => { // eslint-disable-line promise/prefer-await-to-then
595+
const intermediate = Promise.resolve(promise).then(noop, error => { // eslint-disable-line promise/prefer-catch, promise/prefer-await-to-then
596596
throw failPending(new AssertionError(message, {
597597
assertion: 't.notThrowsAsync()',
598598
assertionStack,

lib/chalk.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {Chalk} from 'chalk'; // eslint-disable-line unicorn/import-style
22

3-
let chalk = new Chalk(); // eslint-disable-line import/no-mutable-exports
3+
let chalk = new Chalk(); // eslint-disable-line import-x/no-mutable-exports
44

55
export {chalk};
66

lib/cli.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,7 @@ export default async function loadCli() { // eslint-disable-line complexity
100100
const {argv: {config: configFile}} = yargs(hideBin(process.argv)).help(false).version(false);
101101
const loaded = await loadConfig({configFile});
102102
if (loaded.unsupportedFiles.length > 0) {
103-
console.log(chalk.magenta(
104-
` ${figures.warning} AVA does not support JSON config, ignoring:\n\n ${loaded.unsupportedFiles.join('\n ')}`,
105-
));
103+
console.log(chalk.magenta(` ${figures.warning} AVA does not support JSON config, ignoring:\n\n ${loaded.unsupportedFiles.join('\n ')}`));
106104
}
107105

108106
conf = loaded.config;
@@ -130,7 +128,8 @@ export default async function loadCli() { // eslint-disable-line complexity
130128
files: [],
131129
host: undefined,
132130
port: undefined,
133-
} : null;
131+
}
132+
: null;
134133

135134
let resetCache = false;
136135
const {argv} = yargs(hideBin(process.argv))
@@ -165,6 +164,7 @@ export default async function loadCli() { // eslint-disable-line complexity
165164
})
166165
.command('* [<pattern>...]', 'Run tests', yargs => yargs.options(FLAGS).positional('pattern', {
167166
array: true,
167+
// eslint-disable-next-line @stylistic/max-len
168168
describe: 'Select which test files to run. Leave empty if you want AVA to run all test files as per your configuration. Accepts glob patterns, directories that (recursively) contain test files, and file paths optionally suffixed with a colon and comma-separated numbers and/or ranges identifying the 1-based line(s) of specific tests to run',
169169
type: 'string',
170170
}), argv => {
@@ -192,6 +192,7 @@ export default async function loadCli() { // eslint-disable-line complexity
192192
},
193193
}).positional('pattern', {
194194
demand: true,
195+
// eslint-disable-next-line @stylistic/max-len
195196
describe: 'Glob pattern to select a single test file to debug, optionally suffixed with a colon and comma-separated numbers and/or ranges identifying the 1-based line(s) of specific tests to run',
196197
type: 'string',
197198
}),
@@ -203,14 +204,16 @@ export default async function loadCli() { // eslint-disable-line complexity
203204
host: argv.host,
204205
port: argv.port,
205206
};
206-
})
207+
},
208+
)
207209
.command(
208210
'reset-cache',
209211
'Delete any temporary files and state kept by AVA, then exit',
210212
yargs => yargs,
211213
() => {
212214
resetCache = true;
213-
})
215+
},
216+
)
214217
.example('$0')
215218
.example('$0 test.js')
216219
.example('$0 test.js:4,7-9')

lib/line-numbers.js

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,21 @@ const parseNumber = string => Number.parseInt(string, 10);
1616
const removeAllWhitespace = string => string.replaceAll(/\s/g, '');
1717
const range = (start, end) => Array.from({length: end - start + 1}).fill(start).map((element, index) => element + index);
1818

19-
const parseLineNumbers = suffix => sortNumbersAscending(distinctArray(
20-
suffix.split(',').flatMap(part => {
21-
if (NUMBER_REGEX.test(part)) {
22-
return parseNumber(part);
23-
}
19+
const parseLineNumbers = suffix => sortNumbersAscending(distinctArray(suffix.split(',').flatMap(part => {
20+
if (NUMBER_REGEX.test(part)) {
21+
return parseNumber(part);
22+
}
2423

25-
const {groups: {startGroup, endGroup}} = RANGE_REGEX.exec(part);
26-
const start = parseNumber(startGroup);
27-
const end = parseNumber(endGroup);
24+
const {groups: {startGroup, endGroup}} = RANGE_REGEX.exec(part);
25+
const start = parseNumber(startGroup);
26+
const end = parseNumber(endGroup);
2827

29-
if (start > end) {
30-
return range(end, start);
31-
}
28+
if (start > end) {
29+
return range(end, start);
30+
}
3231

33-
return range(start, end);
34-
}),
35-
));
32+
return range(start, end);
33+
})));
3634

3735
export function splitPatternAndLineNumbers(pattern) {
3836
const parts = pattern.split(DELIMITER);
@@ -49,9 +47,7 @@ export function splitPatternAndLineNumbers(pattern) {
4947
}
5048

5149
export function getApplicableLineNumbers(normalizedFilePath, filter) {
52-
return sortNumbersAscending(distinctArray(
53-
filter
54-
.filter(({pattern, lineNumbers}) => lineNumbers && picomatch.isMatch(normalizedFilePath, pattern))
55-
.flatMap(({lineNumbers}) => lineNumbers),
56-
));
50+
return sortNumbersAscending(distinctArray(filter
51+
.filter(({pattern, lineNumbers}) => lineNumbers && picomatch.isMatch(normalizedFilePath, pattern))
52+
.flatMap(({lineNumbers}) => lineNumbers)));
5753
}

lib/reporters/default.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ export default class Reporter {
327327

328328
this.lineWriter.writeLine(colors.error(`${figures.cross} Line numbers for ${this.relativeFile(event.testFile)} did not match any tests`));
329329
} else if (!this.failFastEnabled && fileStats.remainingTests > 0) {
330+
// eslint-disable-next-line @stylistic/max-len
330331
this.lineWriter.writeLine(colors.error(`${figures.cross} ${fileStats.remainingTests} ${plur('test', fileStats.remainingTests)} remaining in ${this.relativeFile(event.testFile)}`));
331332
}
332333
}
@@ -632,6 +633,7 @@ export default class Reporter {
632633
this.lineWriter.writeLine(colors.error(`${figures.cross} Couldn’t find any files to test` + firstLinePostfix));
633634
} else {
634635
const {testFileCount: count} = this.selectionInsights;
636+
// eslint-disable-next-line @stylistic/max-len
635637
this.lineWriter.writeLine(colors.error(`${figures.cross} Based on your configuration, ${count} test ${plur('file was', 'files were', count)} found, but did not match the filters:` + firstLinePostfix));
636638
this.lineWriter.writeLine();
637639
for (const {pattern} of this.selectionInsights.filter) {
@@ -712,8 +714,7 @@ export default class Reporter {
712714
&& this.stats.failedTests === 0
713715
&& this.stats.passedTests > 0
714716
) {
715-
this.lineWriter.writeLine(colors.pass(`${this.stats.passedTests} ${plur('test', this.stats.passedTests)} passed`) + firstLinePostfix,
716-
);
717+
this.lineWriter.writeLine(colors.pass(`${this.stats.passedTests} ${plur('test', this.stats.passedTests)} passed`) + firstLinePostfix);
717718
firstLinePostfix = '';
718719
}
719720

lib/runner.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -254,23 +254,21 @@ export default class Runner extends Emittery {
254254
let waitForSerial = Promise.resolve();
255255
await runnables.reduce((previous, runnable) => { // eslint-disable-line unicorn/no-array-reduce
256256
if (runnable.metadata.serial || this.serial) {
257-
waitForSerial = previous.then(() =>
257+
waitForSerial = previous.then(() => // eslint-disable-line promise/prefer-await-to-then
258258
// Serial runnables run as long as there was no previous failure, unless
259259
// the runnable should always be run.
260-
(allPassed || runnable.metadata.always) && runAndStoreResult(runnable),
261-
);
260+
(allPassed || runnable.metadata.always) && runAndStoreResult(runnable));
262261
return waitForSerial;
263262
}
264263

265264
return Promise.all([
266265
previous,
267-
waitForSerial.then(() =>
266+
waitForSerial.then(() => // eslint-disable-line promise/prefer-await-to-then
268267
// Concurrent runnables are kicked off after the previous serial
269268
// runnables have completed, as long as there was no previous failure
270269
// (or if the runnable should always be run). One concurrent runnable's
271270
// failure does not prevent the next runnable from running.
272-
(allPassed || runnable.metadata.always) && runAndStoreResult(runnable),
273-
),
271+
(allPassed || runnable.metadata.always) && runAndStoreResult(runnable)),
274272
]);
275273
}, waitForSerial);
276274

@@ -379,7 +377,8 @@ export default class Runner extends Emittery {
379377
{
380378
titleSuffix: hookSuffix,
381379
testPassed: testOk,
382-
});
380+
},
381+
);
383382
} else {
384383
this.emit('stateChange', {
385384
type: 'test-failed',
@@ -399,7 +398,8 @@ export default class Runner extends Emittery {
399398
{
400399
titleSuffix: hookSuffix,
401400
testPassed: testOk,
402-
});
401+
},
402+
);
403403
return alwaysOk && hooksOk && testOk;
404404
}
405405

0 commit comments

Comments
 (0)