Skip to content

Commit 212340c

Browse files
committed
Run lint:fix for consisten styling
Now that we have our stylistic plugin in eslint we can go ahead and autofix everything. This commit is the result of running `npm run lint:fix` on a prestine checkout.
1 parent bb93a5c commit 212340c

9 files changed

+590
-590
lines changed

eslint.config.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import eslint from "@eslint/js";
2-
import stylistic from "@stylistic/eslint-plugin";
3-
import gitignore from "eslint-config-flat-gitignore";
4-
import perfectionist from "eslint-plugin-perfectionist"
5-
import tseslint from "typescript-eslint";
1+
import eslint from '@eslint/js';
2+
import stylistic from '@stylistic/eslint-plugin';
3+
import gitignore from 'eslint-config-flat-gitignore';
4+
import perfectionist from 'eslint-plugin-perfectionist';
5+
import tseslint from 'typescript-eslint';
66

77
export default tseslint.config(
88
gitignore(),
@@ -13,21 +13,21 @@ export default tseslint.config(
1313
parserOptions: {
1414
projectService: true,
1515
tsconfigRootDir: import.meta.dirname,
16-
}
16+
},
1717
},
1818
rules: {
19-
"@typescript-eslint/no-explicit-any": "off",
19+
'@typescript-eslint/no-explicit-any': 'off',
2020
},
2121
},
2222
{
2323
// disable type-aware linting on JS files
2424
files: ['**/*.js'],
2525
...tseslint.configs.disableTypeChecked,
2626
},
27-
perfectionist.configs["recommended-natural"],
27+
perfectionist.configs['recommended-natural'],
2828
stylistic.configs.customize({
2929
indent: 2,
30-
quotes: "single",
30+
quotes: 'single',
3131
semi: true,
32-
})
32+
}),
3333
);

src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export type { CustomMatcher } from './matcher.js'
1+
export type { CustomMatcher } from './matcher.js';
22
export {
33
toHaveReceivedCommand,
44
toHaveReceivedCommandOnce,
@@ -11,5 +11,5 @@ export {
1111
toReceiveCommandTimes,
1212
toReceiveCommandWith,
1313
toReceiveLastCommandWith,
14-
toReceiveNthCommandWith
15-
} from "./matcher.js";
14+
toReceiveNthCommandWith,
15+
} from './matcher.js';

src/matcher.ts

Lines changed: 60 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
import type { MetadataBearer } from "@smithy/types";
1+
import type { MetadataBearer } from '@smithy/types';
22
import type {
33
ExpectationResult,
44
MatcherState,
5-
} from "@vitest/expect";
6-
import type { AwsCommand, AwsStub } from "aws-sdk-client-mock";
5+
} from '@vitest/expect';
6+
import type { AwsCommand, AwsStub } from 'aws-sdk-client-mock';
77

8-
import { ObjectContaining } from "@vitest/expect";
8+
import { ObjectContaining } from '@vitest/expect';
99

10-
import { notNull, ordinalOf } from "./utils.js";
10+
import { notNull, ordinalOf } from './utils.js';
1111

1212
type AwsCommandConstructur<
1313
Input extends object,
14-
Output extends MetadataBearer
14+
Output extends MetadataBearer,
1515
> = new (input: Input) => AwsCommand<Input, Output>;
1616

1717
/*
@@ -41,38 +41,38 @@ interface BaseMatcher<R> {
4141

4242
toHaveReceivedCommandOnce<
4343
Input extends object,
44-
Ouptut extends MetadataBearer
44+
Ouptut extends MetadataBearer,
4545
>(
4646
command: AwsCommandConstructur<Input, Ouptut>
4747
): R;
4848

4949
toHaveReceivedCommandTimes<
5050
Input extends object,
51-
Ouptut extends MetadataBearer
51+
Ouptut extends MetadataBearer,
5252
>(
5353
command: AwsCommandConstructur<Input, Ouptut>,
5454
times: number
5555
): R;
5656

5757
toHaveReceivedCommandWith<
5858
Input extends object,
59-
Ouptut extends MetadataBearer
59+
Ouptut extends MetadataBearer,
6060
>(
6161
command: AwsCommandConstructur<Input, Ouptut>,
6262
input: Partial<Input>
6363
): R;
6464

6565
toHaveReceivedLastCommandWith<
6666
Input extends object,
67-
Ouptut extends MetadataBearer
67+
Ouptut extends MetadataBearer,
6868
>(
6969
command: AwsCommandConstructur<Input, Ouptut>,
7070
input: Partial<Input>
7171
): R;
7272

7373
toHaveReceivedNthCommandWith<
7474
Input extends object,
75-
Ouptut extends MetadataBearer
75+
Ouptut extends MetadataBearer,
7676
>(
7777
command: AwsCommandConstructur<Input, Ouptut>,
7878
times: number,
@@ -84,12 +84,12 @@ interface BaseMatcher<R> {
8484
* We define some aliases
8585
*/
8686
interface AliasMatcher<R> {
87-
toReceiveCommand: BaseMatcher<R>["toHaveReceivedCommand"];
88-
toReceiveCommandOnce: BaseMatcher<R>["toHaveReceivedCommandOnce"];
89-
toReceiveCommandTimes: BaseMatcher<R>["toHaveReceivedCommandTimes"];
90-
toReceiveCommandWith: BaseMatcher<R>["toHaveReceivedCommandWith"];
91-
toReceiveLastCommandWith: BaseMatcher<R>["toHaveReceivedLastCommandWith"];
92-
toReceiveNthCommandWith: BaseMatcher<R>["toHaveReceivedNthCommandWith"];
87+
toReceiveCommand: BaseMatcher<R>['toHaveReceivedCommand'];
88+
toReceiveCommandOnce: BaseMatcher<R>['toHaveReceivedCommandOnce'];
89+
toReceiveCommandTimes: BaseMatcher<R>['toHaveReceivedCommandTimes'];
90+
toReceiveCommandWith: BaseMatcher<R>['toHaveReceivedCommandWith'];
91+
toReceiveLastCommandWith: BaseMatcher<R>['toHaveReceivedLastCommandWith'];
92+
toReceiveNthCommandWith: BaseMatcher<R>['toHaveReceivedNthCommandWith'];
9393
}
9494

9595
type CustomMatcher<R = unknown> = AliasMatcher<R> & BaseMatcher<R>;
@@ -99,41 +99,41 @@ function formatCalls(
9999
client: AwsStub<any, any, any>,
100100
command: AwsCommandConstructur<any, any>,
101101
expectedCall: Record<string, any> | undefined,
102-
message: string
102+
message: string,
103103
): string {
104104
const calls = client.commandCalls(command);
105105

106106
return calls.length === 0
107107
? message
108108
: [
109-
message,
110-
"",
111-
"Received:",
112-
"",
113-
...calls.flatMap((call, index) => {
109+
message,
110+
'',
111+
'Received:',
112+
'',
113+
...calls.flatMap((call, index) => {
114114
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
115-
const input = call.args[0].input;
116-
return [
117-
` ${ordinalOf(index + 1)} ${command.name} call`,
118-
"",
119-
expectedCall
120-
? context.utils.diff(expectedCall, input, { omitAnnotationLines: true })
121-
: context.utils
122-
.stringify(input)
123-
.split("\n")
124-
.map(line => ` ${line}`)
125-
.join("\n"),
126-
""
127-
].filter(notNull);
128-
}),
129-
`Number of calls: ${calls.length.toString()}`
130-
].join("\n");
115+
const input = call.args[0].input;
116+
return [
117+
` ${ordinalOf(index + 1)} ${command.name} call`,
118+
'',
119+
expectedCall
120+
? context.utils.diff(expectedCall, input, { omitAnnotationLines: true })
121+
: context.utils
122+
.stringify(input)
123+
.split('\n')
124+
.map(line => ` ${line}`)
125+
.join('\n'),
126+
'',
127+
].filter(notNull);
128+
}),
129+
`Number of calls: ${calls.length.toString()}`,
130+
].join('\n');
131131
}
132132

133-
const toHaveReceivedCommandTimes: CustomMatcherFn = function(
133+
const toHaveReceivedCommandTimes: CustomMatcherFn = function (
134134
client: AwsStub<any, any, any>,
135135
command: AwsCommandConstructur<any, any>,
136-
times: number
136+
times: number,
137137
) {
138138
const { isNot } = this;
139139
const callCount = client.commandCalls(command).length;
@@ -146,14 +146,14 @@ const toHaveReceivedCommandTimes: CustomMatcherFn = function(
146146
: `expected "${command.name}" to be called ${times.toString()} times, but got ${callCount.toString()} times`;
147147
return formatCalls(this, client, command, undefined, message);
148148
},
149-
pass
149+
pass,
150150
};
151151
};
152152
const toReceiveCommandTimes = toHaveReceivedCommandTimes;
153153

154-
const toHaveReceivedCommandOnce: CustomMatcherFn = function(
154+
const toHaveReceivedCommandOnce: CustomMatcherFn = function (
155155
client: AwsStub<any, any, any>,
156-
command: AwsCommandConstructur<any, any>
156+
command: AwsCommandConstructur<any, any>,
157157
) {
158158
const { isNot } = this;
159159
const callCount = client.commandCalls(command).length;
@@ -165,14 +165,14 @@ const toHaveReceivedCommandOnce: CustomMatcherFn = function(
165165
: `expected "${command.name}" to be called once, but got ${callCount.toString()} times`;
166166
return formatCalls(this, client, command, undefined, message);
167167
},
168-
pass
168+
pass,
169169
};
170170
};
171171
const toReceiveCommandOnce = toHaveReceivedCommandOnce;
172172

173-
const toHaveReceivedCommand: CustomMatcherFn = function(
173+
const toHaveReceivedCommand: CustomMatcherFn = function (
174174
client: AwsStub<any, any, any>,
175-
command: AwsCommandConstructur<any, any>
175+
command: AwsCommandConstructur<any, any>,
176176
) {
177177
const { isNot } = this;
178178
const callCount = client.commandCalls(command).length;
@@ -184,21 +184,21 @@ const toHaveReceivedCommand: CustomMatcherFn = function(
184184
: `expected "${command.name}" to be called at least once`;
185185
return formatCalls(this, client, command, undefined, message);
186186
},
187-
pass
187+
pass,
188188
};
189189
};
190190
const toReceiveCommand = toHaveReceivedCommand;
191191

192-
const toHaveReceivedCommandWith: CustomMatcherFn = function(
192+
const toHaveReceivedCommandWith: CustomMatcherFn = function (
193193
client: AwsStub<any, any, any>,
194194
command: AwsCommandConstructur<any, any>,
195-
input: Record<string, any>
195+
input: Record<string, any>,
196196
) {
197197
const { isNot, utils } = this;
198198
const calls = client.commandCalls(command);
199199

200200
const pass = calls.some(call =>
201-
new ObjectContaining(input).asymmetricMatch(call.args[0].input)
201+
new ObjectContaining(input).asymmetricMatch(call.args[0].input),
202202
);
203203

204204
return {
@@ -208,18 +208,18 @@ const toHaveReceivedCommandWith: CustomMatcherFn = function(
208208
: `expected "${command.name}" to be called with arguments: ${utils.printExpected(input)}`;
209209
return formatCalls(this, client, command, input, message);
210210
},
211-
pass
211+
pass,
212212
};
213213
};
214214
const toReceiveCommandWith = toHaveReceivedCommandWith;
215215
/*
216216
217217
*/
218-
const toHaveReceivedNthCommandWith: CustomMatcherFn = function(
218+
const toHaveReceivedNthCommandWith: CustomMatcherFn = function (
219219
client: AwsStub<any, any, any>,
220220
command: AwsCommandConstructur<any, any>,
221221
times: number,
222-
input: Record<string, any>
222+
input: Record<string, any>,
223223
) {
224224
const { isNot, utils } = this;
225225
const calls = client.commandCalls(command);
@@ -236,15 +236,15 @@ const toHaveReceivedNthCommandWith: CustomMatcherFn = function(
236236
: `expected ${ordinalOf(times)} "${command.name}" to be called with arguments: ${utils.printExpected(input)}`;
237237
return formatCalls(this, client, command, input, message);
238238
},
239-
pass
239+
pass,
240240
};
241241
};
242242
const toReceiveNthCommandWith = toHaveReceivedNthCommandWith;
243243

244-
const toHaveReceivedLastCommandWith: CustomMatcherFn = function(
244+
const toHaveReceivedLastCommandWith: CustomMatcherFn = function (
245245
client: AwsStub<any, any, any>,
246246
command: AwsCommandConstructur<any, any>,
247-
input: Record<string, any>
247+
input: Record<string, any>,
248248
) {
249249
const { isNot, utils } = this;
250250
const calls = client.commandCalls(command);
@@ -261,12 +261,12 @@ const toHaveReceivedLastCommandWith: CustomMatcherFn = function(
261261
: `expected last "${command.name}" to be called with arguments: ${utils.printExpected(input)}`;
262262
return formatCalls(this, client, command, input, message);
263263
},
264-
pass
264+
pass,
265265
};
266266
};
267267
const toReceiveLastCommandWith = toHaveReceivedLastCommandWith;
268268

269-
export type { CustomMatcher }
269+
export type { CustomMatcher };
270270
export {
271271
toHaveReceivedCommand,
272272
toHaveReceivedCommandOnce,
@@ -279,5 +279,5 @@ export {
279279
toReceiveCommandTimes,
280280
toReceiveCommandWith,
281281
toReceiveLastCommandWith,
282-
toReceiveNthCommandWith
282+
toReceiveNthCommandWith,
283283
};

src/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export function ordinalOf(n: number): string {
22
const j = n % 10;
33
const k = n % 100;
4-
const s = n.toString()
4+
const s = n.toString();
55
if (j === 1 && k !== 11) return `${s}st`;
66
if (j === 2 && k !== 12) return `${s}nd`;
77
if (j === 3 && k !== 13) return `${s}rd`;

tests/index.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { expect, it } from "vitest";
1+
import { expect, it } from 'vitest';
22

33
import {
44
toHaveReceivedCommand,
@@ -12,10 +12,10 @@ import {
1212
toReceiveCommandTimes,
1313
toReceiveCommandWith,
1414
toReceiveLastCommandWith,
15-
toReceiveNthCommandWith
16-
} from "../src/index.js";
15+
toReceiveNthCommandWith,
16+
} from '../src/index.js';
1717

18-
it("should be able to extend with matchers", () => {
18+
it('should be able to extend with matchers', () => {
1919
expect.extend({
2020
toHaveReceivedCommand,
2121
toHaveReceivedCommandOnce,
@@ -28,6 +28,6 @@ it("should be able to extend with matchers", () => {
2828
toReceiveCommandTimes,
2929
toReceiveCommandWith,
3030
toReceiveLastCommandWith,
31-
toReceiveNthCommandWith
31+
toReceiveNthCommandWith,
3232
});
3333
});

0 commit comments

Comments
 (0)