Skip to content

Commit

Permalink
Update XO and fix problems
Browse files Browse the repository at this point in the history
  • Loading branch information
novemberborn committed Nov 1, 2021
1 parent a7737cd commit 5a48893
Show file tree
Hide file tree
Showing 17 changed files with 1,325 additions and 906 deletions.
6 changes: 3 additions & 3 deletions lib/assert.js
Expand Up @@ -464,7 +464,7 @@ export class Assertions {
retval = fn();
if (isPromise(retval)) {
// Here isPromise() checks if something is "promise like". Cast to an actual promise.
Promise.resolve(retval).catch(noop); // eslint-disable-line promise/prefer-await-to-then
Promise.resolve(retval).catch(noop);
fail(new AssertionError({
assertion: 'throws',
message,
Expand Down Expand Up @@ -528,7 +528,7 @@ export class Assertions {
// Create an error object to record the stack before it gets lost in the promise chain.
const savedError = getErrorWithLongStackTrace();
// Handle "promise like" objects by casting to a real Promise.
const intermediate = Promise.resolve(promise).then(value => { // eslint-disable-line promise/prefer-await-to-then
const intermediate = Promise.resolve(promise).then(value => {
throw new AssertionError({
assertion: 'throwsAsync',
message,
Expand Down Expand Up @@ -637,7 +637,7 @@ export class Assertions {
// Create an error object to record the stack before it gets lost in the promise chain.
const savedError = getErrorWithLongStackTrace();
// Handle "promise like" objects by casting to a real Promise.
const intermediate = Promise.resolve(promise).then(noop, error => { // eslint-disable-line promise/prefer-await-to-then
const intermediate = Promise.resolve(promise).then(noop, error => {
throw new AssertionError({
assertion: 'notThrowsAsync',
message,
Expand Down
2 changes: 1 addition & 1 deletion lib/eslint-plugin-helper-worker.js
Expand Up @@ -41,7 +41,7 @@ const buildGlobs = ({conf, providers, projectDir, overrideExtensions, overrideFi

const resolveGlobs = async (projectDir, overrideExtensions, overrideFiles) => {
if (!configCache.has(projectDir)) {
configCache.set(projectDir, loadConfig({resolveFrom: projectDir}).then(async conf => { // eslint-disable-line promise/prefer-await-to-then
configCache.set(projectDir, loadConfig({resolveFrom: projectDir}).then(async conf => {
const providers = await collectProviders({conf, projectDir});
return {conf, providers};
}));
Expand Down
8 changes: 4 additions & 4 deletions lib/plugin-support/shared-workers.js
Expand Up @@ -38,7 +38,7 @@ function launchWorker(filename, initialData) {
const launched = {
statePromises: {
available: waitForAvailable(worker),
error: events.once(worker, 'error').then(([error]) => error), // eslint-disable-line promise/prefer-await-to-then
error: events.once(worker, 'error').then(([error]) => error),
},
exited: false,
worker,
Expand All @@ -59,7 +59,7 @@ export async function observeWorkerProcess(fork, runStatus) {
signalDeregistered = resolve;
});

fork.promise.finally(() => { // eslint-disable-line promise/prefer-await-to-then
fork.promise.finally(() => {
if (registrationCount === 0) {
signalDeregistered();
}
Expand All @@ -79,7 +79,7 @@ export async function observeWorkerProcess(fork, runStatus) {
}
};

launched.statePromises.error.then(error => { // eslint-disable-line promise/prefer-await-to-then
launched.statePromises.error.then(error => {
signalDeregistered();
launched.worker.off('message', handleWorkerMessage);
runStatus.emitStateChange({type: 'shared-worker-error', err: serializeError('Shared worker error', true, error)});
Expand All @@ -100,7 +100,7 @@ export async function observeWorkerProcess(fork, runStatus) {
port,
}, [port]);

fork.promise.finally(() => { // eslint-disable-line promise/prefer-await-to-then
fork.promise.finally(() => {
launched.worker.postMessage({
type: 'deregister-test-worker',
id: fork.forkId,
Expand Down
4 changes: 2 additions & 2 deletions lib/runner.js
Expand Up @@ -487,7 +487,7 @@ export default class Runner extends Emittery {

// Note that the hooks and tests always begin running asynchronously.
const beforePromise = this.runHooks(this.tasks.before, contextRef);
const serialPromise = beforePromise.then(beforeHooksOk => { // eslint-disable-line promise/prefer-await-to-then
const serialPromise = beforePromise.then(beforeHooksOk => {
// Don't run tests if a `before` hook failed.
if (!beforeHooksOk) {
return false;
Expand All @@ -509,7 +509,7 @@ export default class Runner extends Emittery {
return this.runTest(task, contextRef.copy());
}, true);
});
const concurrentPromise = Promise.all([beforePromise, serialPromise]).then(async ([beforeHooksOk, serialOk]) => { // eslint-disable-line promise/prefer-await-to-then
const concurrentPromise = Promise.all([beforePromise, serialPromise]).then(async ([beforeHooksOk, serialOk]) => {
// Don't run tests if a `before` hook failed, or if `failFast` is enabled
// and a previous serial test failed.
if (!beforeHooksOk || (!serialOk && this.failFast)) {
Expand Down
8 changes: 4 additions & 4 deletions lib/test.js
Expand Up @@ -314,8 +314,8 @@ export default class Test {
this.refreshTimeout();

promise
.catch(error => this.saveFirstError(error)) // eslint-disable-line promise/prefer-await-to-then
.then(() => { // eslint-disable-line promise/prefer-await-to-then
.catch(error => this.saveFirstError(error))
.then(() => {
this.pendingAssertionCount--;
this.refreshTimeout();
});
Expand Down Expand Up @@ -563,14 +563,14 @@ export default class Test {
};

promise
.catch(error => { // eslint-disable-line promise/prefer-await-to-then
.catch(error => {
this.saveFirstError(new AssertionError({
message: 'Rejected promise returned by test',
savedError: error instanceof Error && error,
values: [formatErrorValue('Rejected promise returned by test. Reason:', error)],
}));
})
.then(() => resolve(this.finish())); // eslint-disable-line promise/prefer-await-to-then
.then(() => resolve(this.finish()));
});
}

Expand Down
4 changes: 2 additions & 2 deletions lib/watcher.js
Expand Up @@ -142,7 +142,7 @@ export default class Watcher {
updateSnapshots: updateSnapshots === true,
},
})
.then(runStatus => { // eslint-disable-line promise/prefer-await-to-then
.then(runStatus => {
reporter.endRun();
reporter.lineWriter.writeLine(END_MESSAGE);

Expand All @@ -158,7 +158,7 @@ export default class Watcher {
this.clearLogOnNextRun = false;
}
})
.catch(rethrowAsync); // eslint-disable-line promise/prefer-await-to-then
.catch(rethrowAsync);
};

this.testDependencies = [];
Expand Down
6 changes: 3 additions & 3 deletions lib/worker/base.js
Expand Up @@ -69,7 +69,7 @@ const run = async options => {

refs.runnerChain = runner.chain;

channel.peerFailed.then(() => { // eslint-disable-line promise/prefer-await-to-then
channel.peerFailed.then(() => {
runner.interrupt();
});

Expand Down Expand Up @@ -202,8 +202,8 @@ if (isRunningInThread) {
channel.send({type: 'starting'}); // AVA won't terminate the worker thread until it's seen this message.
const {options} = workerData;
delete workerData.options; // Don't allow user code access.
run(options).catch(onError); // eslint-disable-line promise/prefer-await-to-then
run(options).catch(onError);
} else if (isRunningInChildProcess) {
channel.send({type: 'ready-for-options'});
channel.options.then(run).catch(onError); // eslint-disable-line promise/prefer-await-to-then
channel.options.then(run).catch(onError);
}
8 changes: 4 additions & 4 deletions lib/worker/channel.cjs
Expand Up @@ -110,7 +110,7 @@ exports.unref = handle.unref.bind(handle);
let pendingPings = Promise.resolve();
async function flush() {
handle.ref();
const promise = pendingPings.then(async () => { // eslint-disable-line promise/prefer-await-to-then
const promise = pendingPings.then(async () => {
handle.send({type: 'ping'});
await pEvent(handle.channel, 'message', selectAvaMessage('pong'));
if (promise === pendingPings) {
Expand Down Expand Up @@ -172,9 +172,9 @@ function registerSharedWorker(filename, initialData) {
// The attaching of message listeners will cause the port to be referenced by
// Node.js. In order to keep track, explicitly reference before attaching.
sharedWorkerHandle.ref();
const ready = pEvent(ourPort, 'message', ({type}) => type === 'ready').then(() => { // eslint-disable-line promise/prefer-await-to-then
const ready = pEvent(ourPort, 'message', ({type}) => type === 'ready').then(() => {
currentlyAvailable = error === null;
}).finally(() => { // eslint-disable-line promise/prefer-await-to-then
}).finally(() => {
// Once ready, it's up to user code to subscribe to messages, which (see
// below) causes us to reference the port.
sharedWorkerHandle.unref();
Expand All @@ -184,7 +184,7 @@ function registerSharedWorker(filename, initialData) {

// Errors are received over the test worker channel, not the message port
// dedicated to the shared worker.
pEvent(channelEmitter, 'shared-worker-error').then(() => { // eslint-disable-line promise/prefer-await-to-then
pEvent(channelEmitter, 'shared-worker-error').then(() => {
unsubscribe();
sharedWorkerHandle.forceUnref();
error = new Error('The shared worker is no longer available');
Expand Down

0 comments on commit 5a48893

Please sign in to comment.