Skip to content

Commit 60784a5

Browse files
committed
Upgrade XO
1 parent f07eec8 commit 60784a5

Some content is hidden

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

57 files changed

+1633
-778
lines changed

eslint-plugin-helper.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ function load(projectDir, overrides) {
4949
let helperPatterns = [];
5050
if (overrides && overrides.helpers !== undefined) {
5151
if (!Array.isArray(overrides.helpers) || overrides.helpers.length === 0) {
52-
throw new Error('The \'helpers\' override must be an array containing glob patterns.');
52+
throw new Error('The helpers override must be an array containing glob patterns.');
5353
}
5454

5555
helperPatterns = normalizePatterns(overrides.helpers);

index.d.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
export interface Subscribable {
22
subscribe(observer: {
3-
error(err: any): void,
4-
complete(): void,
5-
}): void
3+
error(err: any): void;
4+
complete(): void;
5+
}): void;
66
}
77

8-
export type Constructor = (new (...args: Array<any>) => any);
8+
export type Constructor = (new (...args: any[]) => any);
99

1010
/** Specify one or more expectations the thrown error must satisfy. */
1111
export type ThrowsExpectation = {
@@ -29,8 +29,8 @@ export type CommitDiscardOptions = {
2929
/**
3030
* Whether the logs should be included in those of the parent test.
3131
*/
32-
retainLogs?: boolean
33-
}
32+
retainLogs?: boolean;
33+
};
3434

3535
/** Options that can be passed to the `t.snapshot()` assertion. */
3636
export type SnapshotOptions = {
@@ -316,10 +316,10 @@ export interface ExecutionContext<Context = unknown> extends Assertions {
316316

317317
export interface LogFn {
318318
/** Log one or more values. */
319-
(...values: Array<any>): void;
319+
(...values: any[]): void;
320320

321321
/** Skip logging. */
322-
skip(...values: Array<any>): void;
322+
skip(...values: any[]): void;
323323
}
324324

325325
export interface PlanFn {
@@ -354,7 +354,7 @@ export interface TryFn<Context = unknown> {
354354
* the test will fail. A macro may be provided. The title may help distinguish attempts from
355355
* one another.
356356
*/
357-
<Args extends any[]>(title: string, fn: [EitherMacro<Args, Context>, ...EitherMacro<Args, Context>[]], ...args: Args): Promise<TryResult[]>;
357+
<Args extends any[]>(title: string, fn: [EitherMacro<Args, Context>, ...Array<EitherMacro<Args, Context>>], ...args: Args): Promise<TryResult[]>;
358358

359359
/**
360360
* Requires opt-in. Attempt to run some assertions. The result must be explicitly committed or discarded or else
@@ -366,7 +366,7 @@ export interface TryFn<Context = unknown> {
366366
* Requires opt-in. Attempt to run some assertions. The result must be explicitly committed or discarded or else
367367
* the test will fail. A macro may be provided.
368368
*/
369-
<Args extends any[]>(fn: [EitherMacro<Args, Context>, ...EitherMacro<Args, Context>[]], ...args: Args): Promise<TryResult[]>;
369+
<Args extends any[]>(fn: [EitherMacro<Args, Context>, ...Array<EitherMacro<Args, Context>>], ...args: Args): Promise<TryResult[]>;
370370
}
371371

372372
export interface AssertionError extends Error {}
@@ -427,32 +427,32 @@ export type Macro<Args extends any[], Context = unknown> = UntitledMacro<Args, C
427427
* the title provided when the test or hook was declared. Also receives the remaining test arguments.
428428
*/
429429
title?: (providedTitle: string | undefined, ...args: Args) => string;
430-
}
430+
};
431431

432432
export type EitherMacro<Args extends any[], Context> = Macro<Args, Context> | UntitledMacro<Args, Context>;
433433

434434
/** Alias for a single macro, or an array of macros. */
435-
export type OneOrMoreMacros<Args extends any[], Context> = EitherMacro<Args, Context> | [EitherMacro<Args, Context>, ...EitherMacro<Args, Context>[]];
435+
export type OneOrMoreMacros<Args extends any[], Context> = EitherMacro<Args, Context> | [EitherMacro<Args, Context>, ...Array<EitherMacro<Args, Context>>];
436436

437437
/** A reusable test or hook implementation, for tests & hooks declared with the `.cb` modifier. */
438-
export type UntitledCbMacro<Args extends any[], Context = unknown> = (t: CbExecutionContext<Context>, ...args: Args) => ImplementationResult
438+
export type UntitledCbMacro<Args extends any[], Context = unknown> = (t: CbExecutionContext<Context>, ...args: Args) => ImplementationResult;
439439

440440
/** A reusable test or hook implementation, for tests & hooks declared with the `.cb` modifier. */
441441
export type CbMacro<Args extends any[], Context = unknown> = UntitledCbMacro<Args, Context> & {
442442
title?: (providedTitle: string | undefined, ...args: Args) => string;
443-
}
443+
};
444444

445445
export type EitherCbMacro<Args extends any[], Context> = CbMacro<Args, Context> | UntitledCbMacro<Args, Context>;
446446

447447
/** Alias for a single macro, or an array of macros, used for tests & hooks declared with the `.cb` modifier. */
448-
export type OneOrMoreCbMacros<Args extends any[], Context> = EitherCbMacro<Args, Context> | [EitherCbMacro<Args, Context>, ...EitherCbMacro<Args, Context>[]];
448+
export type OneOrMoreCbMacros<Args extends any[], Context> = EitherCbMacro<Args, Context> | [EitherCbMacro<Args, Context>, ...Array<EitherCbMacro<Args, Context>>];
449449

450450
export interface TestInterface<Context = unknown> {
451451
/** Declare a concurrent test. */
452452
(title: string, implementation: Implementation<Context>): void;
453453

454454
/** Declare a concurrent test that uses one or more macros. Additional arguments are passed to the macro. */
455-
<T extends any[]>(title: string, macros: OneOrMoreMacros<T, Context>, ...rest: T): void
455+
<T extends any[]>(title: string, macros: OneOrMoreMacros<T, Context>, ...rest: T): void;
456456

457457
/** Declare a concurrent test that uses one or more macros. The macro is responsible for generating a unique test title. */
458458
<T extends any[]>(macros: OneOrMoreMacros<T, Context>, ...rest: T): void;

lib/api.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function resolveModules(modules) {
2222
const modulePath = resolveCwd.silent(name);
2323

2424
if (modulePath === undefined) {
25-
throw new Error(`Could not resolve required module '${name}'`);
25+
throw new Error(`Could not resolve required module ${name}`);
2626
}
2727

2828
return modulePath;

lib/assert.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,34 +29,34 @@ function formatPowerAssertValue(value) {
2929
return concordance.format(value, concordanceOptions);
3030
}
3131

32-
const hasOwnProperty = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
32+
const hasOwnProperty = (object, prop) => Object.prototype.hasOwnProperty.call(object, prop);
3333
const noop = () => {};
3434
const notImplemented = () => {
3535
throw new Error('not implemented');
3636
};
3737

3838
class AssertionError extends Error {
39-
constructor(opts) {
40-
super(opts.message || '');
39+
constructor(options) {
40+
super(options.message || '');
4141
this.name = 'AssertionError';
4242

43-
this.assertion = opts.assertion;
44-
this.fixedSource = opts.fixedSource;
45-
this.improperUsage = opts.improperUsage || false;
46-
this.actualStack = opts.actualStack;
47-
this.operator = opts.operator;
48-
this.values = opts.values || [];
43+
this.assertion = options.assertion;
44+
this.fixedSource = options.fixedSource;
45+
this.improperUsage = options.improperUsage || false;
46+
this.actualStack = options.actualStack;
47+
this.operator = options.operator;
48+
this.values = options.values || [];
4949

5050
// Raw expected and actual objects are stored for custom reporters
5151
// (such as wallaby.js), that manage worker processes directly and
5252
// use the values for custom diff views
53-
this.raw = opts.raw;
53+
this.raw = options.raw;
5454

5555
// Reserved for power-assert statements
5656
this.statements = [];
5757

58-
if (opts.savedError) {
59-
this.savedError = opts.savedError;
58+
if (options.savedError) {
59+
this.savedError = options.savedError;
6060
} else {
6161
this.savedError = getErrorWithLongStackTrace();
6262
}
@@ -72,8 +72,8 @@ function getErrorWithLongStackTrace() {
7272
return err;
7373
}
7474

75-
function validateExpectations(assertion, expectations, numArgs) { // eslint-disable-line complexity
76-
if (numArgs === 1 || expectations === null || expectations === undefined) {
75+
function validateExpectations(assertion, expectations, numberArgs) { // eslint-disable-line complexity
76+
if (numberArgs === 1 || expectations === null || expectations === undefined) {
7777
expectations = {};
7878
} else if (
7979
typeof expectations === 'function' ||

lib/cli.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ exports.run = async () => { // eslint-disable-line complexity
106106
'strip-aliased': true,
107107
'unknown-options-as-args': false
108108
})
109-
.usage('$0 [<pattern>...]')
110-
.usage('$0 debug [<pattern>...]')
109+
.usage('$0 [<pattern>...]') // eslint-disable-line unicorn/string-content
110+
.usage('$0 debug [<pattern>...]') // eslint-disable-line unicorn/string-content
111111
.usage('$0 reset-cache')
112112
.options({
113113
color: {
@@ -118,13 +118,13 @@ exports.run = async () => { // eslint-disable-line complexity
118118
description: 'Specific JavaScript file for AVA to read its config from, instead of using package.json or ava.config.* files'
119119
}
120120
})
121-
.command('* [<pattern>...]', 'Run tests', yargs => yargs.options(FLAGS).positional('pattern', {
121+
.command('* [<pattern>...]', 'Run tests', yargs => yargs.options(FLAGS).positional('pattern', { // eslint-disable-line unicorn/string-content
122122
array: true,
123123
describe: 'Glob patterns to select what test files to run. Leave empty if you want AVA to run all test files instead',
124124
type: 'string'
125125
}))
126126
.command(
127-
'debug [<pattern>...]',
127+
'debug [<pattern>...]', // eslint-disable-line unicorn/string-content
128128
'Activate Node.js inspector and run a single test file',
129129
yargs => yargs.options(FLAGS).options({
130130
break: {
@@ -156,7 +156,7 @@ exports.run = async () => { // eslint-disable-line complexity
156156
})
157157
.command(
158158
'reset-cache',
159-
'Reset AVA\'s compilation cache and exit',
159+
'Reset AVAs compilation cache and exit',
160160
yargs => yargs,
161161
() => {
162162
resetCache = true;
@@ -249,11 +249,11 @@ exports.run = async () => { // eslint-disable-line complexity
249249
}
250250

251251
if (Reflect.has(conf, 'helpers')) {
252-
exit('AVA no longer compiles helpers. Add exclusion patterns to the \'files\' configuration and specify \'compileAsTests\' in the Babel options instead.');
252+
exit('AVA no longer compiles helpers. Add exclusion patterns to the files configuration and specify compileAsTests in the Babel options instead.');
253253
}
254254

255255
if (Reflect.has(conf, 'sources')) {
256-
exit('\'sources\' has been removed. Use \'ignoredByWatcher\' to provide glob patterns of files that the watcher should ignore.');
256+
exit('sources has been removed. Use ignoredByWatcher to provide glob patterns of files that the watcher should ignore.');
257257
}
258258

259259
const ciParallelVars = require('ci-parallel-vars');

lib/concordance-options.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ const colorTheme = {
8888
string: {
8989
open: ansiStyles.blue.open,
9090
close: ansiStyles.blue.close,
91-
line: {open: forceColor.blue('\''), close: forceColor.blue('\'')},
91+
line: {open: forceColor.blue('\''), close: forceColor.blue('\'')}, // eslint-disable-line unicorn/string-content
9292
multiline: {start: forceColor.blue('`'), end: forceColor.blue('`')},
9393
controlPicture: ansiStyles.grey,
9494
diff: {

lib/create-chain.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,35 +11,35 @@ function startChain(name, call, defaults) {
1111
return fn;
1212
}
1313

14-
function extendChain(prev, name, flag) {
14+
function extendChain(previous, name, flag) {
1515
if (!flag) {
1616
flag = name;
1717
}
1818

1919
const fn = (...args) => {
20-
callWithFlag(prev, flag, args);
20+
callWithFlag(previous, flag, args);
2121
};
2222

23-
const fullName = `${chainRegistry.get(prev).fullName}.${name}`;
23+
const fullName = `${chainRegistry.get(previous).fullName}.${name}`;
2424
Object.defineProperty(fn, 'name', {value: fullName});
25-
prev[name] = fn;
25+
previous[name] = fn;
2626

27-
chainRegistry.set(fn, {flag, fullName, prev});
27+
chainRegistry.set(fn, {flag, fullName, prev: previous});
2828
return fn;
2929
}
3030

31-
function callWithFlag(prev, flag, args) {
31+
function callWithFlag(previous, flag, args) {
3232
const combinedFlags = {[flag]: true};
3333
do {
34-
const step = chainRegistry.get(prev);
34+
const step = chainRegistry.get(previous);
3535
if (step.call) {
3636
step.call({...step.defaults, ...combinedFlags}, args);
37-
prev = null;
37+
previous = null;
3838
} else {
3939
combinedFlags[step.flag] = true;
40-
prev = step.prev;
40+
previous = step.prev;
4141
}
42-
} while (prev);
42+
} while (previous);
4343
}
4444

4545
function createHookChain(hook, isAfterHook) {

lib/environment-variables.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ function validateEnvironmentVariables(environmentVariables) {
66

77
for (const value of Object.values(environmentVariables)) {
88
if (typeof value !== 'string') {
9-
throw new TypeError('The \'environmentVariables\' configuration must be an object containing string values.');
9+
throw new TypeError('The environmentVariables configuration must be an object containing string values.');
1010
}
1111
}
1212

lib/extensions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ module.exports = (configuredExtensions, providers = []) => {
2121
}
2222

2323
if (duplicates.size > 0) {
24-
throw new Error(`Unexpected duplicate extensions in options: '${[...duplicates].join('\', \'')}'.`);
24+
throw new Error(`Unexpected duplicate extensions in options: ${[...duplicates].join('’, ’')}.`);
2525
}
2626

2727
// Unless the default was used by providers, as long as the extensions aren't explicitly set, set the default.

lib/fork.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const AVA_PATH = path.resolve(__dirname, '..');
1414

1515
const workerPath = require.resolve('./worker/subprocess');
1616

17-
module.exports = (file, opts, execArgv = process.execArgv) => {
17+
module.exports = (file, options, execArgv = process.execArgv) => {
1818
let finished = false;
1919

2020
const emitter = new Emittery();
@@ -24,16 +24,16 @@ module.exports = (file, opts, execArgv = process.execArgv) => {
2424
}
2525
};
2626

27-
opts = {
27+
options = {
2828
file,
2929
baseDir: process.cwd(),
30-
...opts
30+
...options
3131
};
3232

33-
const subprocess = childProcess.fork(workerPath, opts.workerArgv, {
34-
cwd: opts.projectDir,
33+
const subprocess = childProcess.fork(workerPath, options.workerArgv, {
34+
cwd: options.projectDir,
3535
silent: true,
36-
env: {NODE_ENV: 'test', ...process.env, ...opts.environmentVariables, AVA_PATH},
36+
env: {NODE_ENV: 'test', ...process.env, ...options.environmentVariables, AVA_PATH},
3737
execArgv
3838
});
3939

@@ -64,7 +64,7 @@ module.exports = (file, opts, execArgv = process.execArgv) => {
6464
}
6565

6666
if (message.ava.type === 'ready-for-options') {
67-
send({type: 'options', options: opts});
67+
send({type: 'options', options});
6868
return;
6969
}
7070

0 commit comments

Comments
 (0)