Skip to content

Commit 1d62caf

Browse files
Upgrade xo to v0.57.0
* Upgrade xo to v0.57.0 and lint sources, tests, and examples Disabled `unicorn/prevent-abbreviations` because it introduces too many opinionated changes. * Update reporter logs which are sensitive to line numbers changing --------- Co-authored-by: Mark Wubben <mark@novemberborn.net>
1 parent 2e0c2b1 commit 1d62caf

20 files changed

+439
-473
lines changed

.xo-config.cjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ module.exports = {
2929
'import/newline-after-import': 'error',
3030
'unicorn/require-post-message-target-origin': 'off',
3131
'unicorn/prefer-event-target': 'off',
32+
'unicorn/prevent-abbreviations': 'off',
3233
},
3334
overrides: [
3435
{

examples/macros/test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const test = require('ava');
22

3-
const {sum} = require('.');
3+
const {sum} = require('./index.js');
44

55
function macro(t, a, b, expected) {
66
t.is(sum(a, b), expected);

examples/timeouts/test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22
const test = require('ava');
33

4-
const {fetchUsers, fetchPosts, createPost} = require('.');
4+
const {fetchUsers, fetchPosts, createPost} = require('./index.js');
55

66
test('retrieve users', async t => {
77
t.timeout(100);

lib/cli.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,9 @@ export default async function loadCli() { // eslint-disable-line complexity
381381

382382
let globs;
383383
try {
384-
globs = normalizeGlobs({files: conf.files, ignoredByWatcher: conf.watchMode?.ignoreChanges, extensions, providers});
384+
globs = normalizeGlobs({
385+
files: conf.files, ignoredByWatcher: conf.watchMode?.ignoreChanges, extensions, providers,
386+
});
385387
} catch (error) {
386388
exit(error.message);
387389
}

lib/create-chain.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ function startChain(name, call, defaults) {
1111
}
1212

1313
function extendChain(previous, name, flag) {
14-
if (!flag) {
15-
flag = name;
16-
}
14+
flag ||= name;
1715

1816
const fn = (...args) => {
1917
callWithFlag(previous, flag, args);
@@ -89,7 +87,9 @@ export default function createChain(fn, defaults, meta) {
8987
// "todo" tests cannot be chained. Allow todo tests to be flagged as needing
9088
// to be serial.
9189
root.todo = startChain('test.todo', fn, {...defaults, type: 'test', todo: true});
92-
root.serial.todo = startChain('test.serial.todo', fn, {...defaults, serial: true, type: 'test', todo: true});
90+
root.serial.todo = startChain('test.serial.todo', fn, {
91+
...defaults, serial: true, type: 'test', todo: true,
92+
});
9393

9494
root.macro = options => {
9595
if (typeof options === 'function') {

lib/eslint-plugin-helper-worker.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ const resolveGlobs = async (projectDir, overrideExtensions, overrideFiles) => {
4848
}
4949

5050
const {conf, providers} = await configCache.get(projectDir);
51-
return buildGlobs({conf, providers, projectDir, overrideExtensions, overrideFiles});
51+
return buildGlobs({
52+
conf, providers, projectDir, overrideExtensions, overrideFiles,
53+
});
5254
};
5355

5456
const data = new Uint8Array(workerData.dataBuffer);

lib/load-config.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const loadConfigFile = async ({projectDir, configFile}) => {
3535

3636
function resolveConfigFile(configFile) {
3737
if (configFile) {
38-
configFile = path.resolve(configFile); // Relative to CWD
38+
return path.resolve(configFile); // Relative to CWD
3939
}
4040

4141
return configFile;
@@ -153,7 +153,9 @@ export async function loadConfig({configFile, resolveFrom = process.cwd(), defau
153153
}
154154
}
155155

156-
const config = {...defaults, nonSemVerExperiments: {}, ...fileConf, ...packageConf, projectDir, configFile};
156+
const config = {
157+
...defaults, nonSemVerExperiments: {}, ...fileConf, ...packageConf, projectDir, configFile,
158+
};
157159

158160
const {nonSemVerExperiments: experiments} = config;
159161
if (!isPlainObject(experiments)) {

lib/plugin-support/shared-worker-loader.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ try {
238238
},
239239
});
240240
} catch (error) {
241-
fatal = fatal ?? error;
241+
fatal ??= error;
242242
} finally {
243243
if (fatal !== undefined) {
244244
process.nextTick(() => {

lib/snapshot-manager.js

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,9 @@ export function extractCompressedSnapshot(buffer, snapPath) {
220220
const compressedOffset = sha256sumOffset + SHA_256_HASH_LENGTH;
221221
const compressed = buffer.slice(compressedOffset);
222222

223-
return {version, compressed, sha256sumOffset, compressedOffset};
223+
return {
224+
version, compressed, sha256sumOffset, compressedOffset,
225+
};
224226
}
225227

226228
function decodeSnapshots(buffer, snapPath) {
@@ -290,11 +292,7 @@ class Manager {
290292
}
291293

292294
recordSerialized({data, label, belongsTo, index}) {
293-
let block = this.newBlocksByTitle.get(belongsTo);
294-
if (!block) {
295-
block = {snapshots: []};
296-
}
297-
295+
const block = this.newBlocksByTitle.get(belongsTo) ?? {snapshots: []};
298296
const {snapshots} = block;
299297

300298
if (index > snapshots.length) {
@@ -319,7 +317,9 @@ class Manager {
319317

320318
return () => { // Must be called in order!
321319
this.hasChanges = true;
322-
this.recordSerialized({data, label, belongsTo, index});
320+
this.recordSerialized({
321+
data, label, belongsTo, index,
322+
});
323323
};
324324
}
325325

@@ -338,11 +338,7 @@ class Manager {
338338

339339
skipSnapshot({belongsTo, index, deferRecording}) {
340340
const oldBlock = this.oldBlocksByTitle.get(belongsTo);
341-
let snapshot = oldBlock?.snapshots[index];
342-
343-
if (!snapshot) {
344-
snapshot = {};
345-
}
341+
const snapshot = oldBlock?.snapshots[index] ?? {};
346342

347343
// Retain the label from the old snapshot, so as not to assume that the
348344
// snapshot.skip() arguments are well-formed.

lib/test.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ import concordance from 'concordance';
22
import isPromise from 'is-promise';
33
import plur from 'plur';
44

5-
import {AssertionError, Assertions, checkAssertionMessage, getAssertionStack} from './assert.js';
5+
import {
6+
AssertionError, Assertions, checkAssertionMessage, getAssertionStack,
7+
} from './assert.js';
68
import concordanceOptions from './concordance-options.js';
79
import nowAndTimers from './now-and-timers.cjs';
810
import parseTestArgs from './parse-test-args.js';
@@ -277,7 +279,9 @@ export default class Test {
277279

278280
const {deferredSnapshotRecordings, error, logs, passed, assertCount, snapshotCount} = await attempt.run();
279281
const errors = error ? [error] : [];
280-
return {assertCount, deferredSnapshotRecordings, errors, logs, passed, snapshotCount, startingSnapshotCount};
282+
return {
283+
assertCount, deferredSnapshotRecordings, errors, logs, passed, snapshotCount, startingSnapshotCount,
284+
};
281285
};
282286

283287
this.assertCount = 0;

lib/watcher.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ import {nodeFileTrace} from '@vercel/nft';
77
import createDebug from 'debug';
88

99
import {chalk} from './chalk.js';
10-
import {applyTestFileFilter, classify, buildIgnoreMatcher, findTests} from './globs.js';
10+
import {
11+
applyTestFileFilter, classify, buildIgnoreMatcher, findTests,
12+
} from './globs.js';
1113
import {levels as providerLevels} from './provider-manager.js';
1214

1315
const debug = createDebug('ava:watcher');
@@ -34,7 +36,9 @@ export function available(projectDir) {
3436

3537
export async function start({api, filter, globs, projectDir, providers, reporter, stdin, signal}) {
3638
providers = providers.filter(({level}) => level >= providerLevels.ava6);
37-
for await (const {files, ...runtimeOptions} of plan({api, filter, globs, projectDir, providers, stdin, abortSignal: signal})) {
39+
for await (const {files, ...runtimeOptions} of plan({
40+
api, filter, globs, projectDir, providers, stdin, abortSignal: signal,
41+
})) {
3842
await api.run({files, filter, runtimeOptions});
3943
reporter.endRun();
4044
reporter.lineWriter.writeLine(END_MESSAGE);
@@ -62,7 +66,9 @@ async function * plan({api, filter, globs, projectDir, providers, stdin, abortSi
6266
const changeFromPath = path => {
6367
const {isTest} = classify(path, cwdAndGlobs);
6468
const stats = fileStats(path);
65-
return {path, isTest, exists: stats !== undefined, isFile: stats?.isFile() ?? false};
69+
return {
70+
path, isTest, exists: stats !== undefined, isFile: stats?.isFile() ?? false,
71+
};
6672
};
6773

6874
// Begin a file trace in the background.

0 commit comments

Comments
 (0)