Skip to content

Commit 41b6e8c

Browse files
committed
Update to latest eslint perfectionist
The new version of `eslint-plugin-perfectionist` does not export the configs directly anymore as of [2a7eec2][1]. As a result we now have to refer to the config differently. [1]: azat-io/eslint-plugin-perfectionist@2a7eec2#diff-7ae45ad102eab3b6d7e7896acd08c427a9b25b346470d7bc6507b6481575d519
1 parent 0417cb7 commit 41b6e8c

File tree

8 files changed

+860
-1095
lines changed

8 files changed

+860
-1095
lines changed

eslint.config.js

+11-7
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,27 @@
11
import eslint from "@eslint/js";
22
import gitignore from "eslint-config-flat-gitignore";
3-
import perfectionistNatural from 'eslint-plugin-perfectionist/configs/recommended-natural'
3+
import perfectionist from 'eslint-plugin-perfectionist'
44
import tseslint from "typescript-eslint";
55

66
export default tseslint.config(
77
gitignore(),
88
eslint.configs.recommended,
9-
...tseslint.configs.recommended,
9+
...tseslint.configs.strictTypeChecked,
1010
{
1111
languageOptions: {
1212
parserOptions: {
13-
ecmaVersion: "latest",
14-
project: "./tsconfig.json",
15-
sourceType: "module",
16-
},
13+
projectService: true,
14+
tsconfigRootDir: import.meta.dirname,
15+
}
1716
},
1817
rules: {
1918
"@typescript-eslint/no-explicit-any": "off",
2019
},
2120
},
22-
perfectionistNatural
21+
{
22+
// disable type-aware linting on JS files
23+
files: ['**/*.js'],
24+
...tseslint.configs.disableTypeChecked,
25+
},
26+
perfectionist.configs["recommended-natural"]
2327
);

package-lock.json

+803-1,044
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+14-14
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
},
1717
"scripts": {
1818
"build": "tsc -p tsconfig.build.json",
19-
"lint": "eslint -c ./eslint.config.js .",
20-
"lint:fix": "eslint -c ./eslint.config.js --fix .",
19+
"lint": "eslint .",
20+
"lint:fix": "eslint --fix .",
2121
"test": "vitest run",
2222
"test:coverage": "vitest run --coverage",
2323
"validate": "tsc --noEmit",
@@ -34,22 +34,22 @@
3434
},
3535
"homepage": "https://github.com/stschulte/aws-sdk-client-mock-vitest#readme",
3636
"dependencies": {
37-
"@vitest/expect": "^2.0.1",
37+
"@vitest/expect": "^2.0.5",
3838
"tslib": "^2.6.3"
3939
},
4040
"devDependencies": {
41-
"@aws-sdk/client-ec2": "^3.609.0",
42-
"@aws-sdk/client-s3": "^3.609.0",
43-
"@eslint/js": "^9.6.0",
41+
"@aws-sdk/client-ec2": "^3.631.0",
42+
"@aws-sdk/client-s3": "^3.631.0",
43+
"@eslint/js": "^9.9.0",
4444
"@smithy/types": "^3.3.0",
45-
"@types/node": "^20.14.10",
46-
"@vitest/coverage-v8": "^2.0.1",
45+
"@types/node": "^22.3.0",
46+
"@vitest/coverage-v8": "^2.0.5",
4747
"aws-sdk-client-mock": "^4.0.1",
48-
"eslint": "^8.57.0",
49-
"eslint-config-flat-gitignore": "^0.1.6",
50-
"eslint-plugin-perfectionist": "^2.11.0",
51-
"typescript": "^5.5.3",
52-
"typescript-eslint": "^7.16.0",
53-
"vitest": "^2.0.1"
48+
"eslint": "^9.9.0",
49+
"eslint-config-flat-gitignore": "^0.1.8",
50+
"eslint-plugin-perfectionist": "^3.2.0",
51+
"typescript": "^5.5.4",
52+
"typescript-eslint": "^8.1.0",
53+
"vitest": "^2.0.5"
5454
}
5555
}

src/matcher.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ function formatCalls(
111111
"Received:",
112112
"",
113113
...calls.flatMap((call, index) => {
114+
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
114115
const input = call.args[0].input;
115116
return [
116117
` ${ordinalOf(index + 1)} ${command.name} call`,
@@ -125,7 +126,7 @@ function formatCalls(
125126
""
126127
].filter(notNull);
127128
}),
128-
`Number of calls: ${calls.length}`
129+
`Number of calls: ${calls.length.toString()}`
129130
].join("\n");
130131
}
131132

@@ -141,8 +142,8 @@ const toHaveReceivedCommandTimes: CustomMatcherFn = function(
141142
return {
142143
message: () => {
143144
const message = isNot
144-
? `expected "${command.name}" to not be called ${times} times`
145-
: `expected "${command.name}" to be called ${times} times, but got ${callCount} times`;
145+
? `expected "${command.name}" to not be called ${times.toString()} times`
146+
: `expected "${command.name}" to be called ${times.toString()} times, but got ${callCount.toString()} times`;
146147
return formatCalls(this, client, command, undefined, message);
147148
},
148149
pass
@@ -161,7 +162,7 @@ const toHaveReceivedCommandOnce: CustomMatcherFn = function(
161162
message: () => {
162163
const message = isNot
163164
? `expected "${command.name}" to not be called once`
164-
: `expected "${command.name}" to be called once, but got ${callCount} times`;
165+
: `expected "${command.name}" to be called once, but got ${callCount.toString()} times`;
165166
return formatCalls(this, client, command, undefined, message);
166167
},
167168
pass
@@ -179,7 +180,7 @@ const toHaveReceivedCommand: CustomMatcherFn = function(
179180
return {
180181
message: () => {
181182
const message = isNot
182-
? `expected "${command.name}" to not be called at all, but actually been called ${callCount} times`
183+
? `expected "${command.name}" to not be called at all, but actually been called ${callCount.toString()} times`
183184
: `expected "${command.name}" to be called at least once`;
184185
return formatCalls(this, client, command, undefined, message);
185186
},

src/utils.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
export function ordinalOf(n: number): string {
22
const j = n % 10;
33
const k = n % 100;
4-
if (j === 1 && k !== 11) return `${n}st`;
5-
if (j === 2 && k !== 12) return `${n}nd`;
6-
if (j === 3 && k !== 13) return `${n}rd`;
7-
return `${n}th`;
4+
const s = n.toString()
5+
if (j === 1 && k !== 11) return `${s}st`;
6+
if (j === 2 && k !== 12) return `${s}nd`;
7+
if (j === 3 && k !== 13) return `${s}rd`;
8+
return `${s}th`;
89
}
910

10-
export function notNull<T>(obj: T | null): obj is T {
11+
export function notNull<T>(obj: null | T): obj is T {
1112
return obj !== null;
1213
}

tests/matcher.test.ts

+18-18
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ expect.extend({
3939
});
4040

4141
describe("toReceiveCommandTimes", () => {
42-
it("should pass with 0 received commands", async () => {
42+
it("should pass with 0 received commands", () => {
4343
const s3Mock = mockClient(S3Client);
4444
expect(s3Mock).toReceiveCommandTimes(PutObjectCommand, 0);
4545
});
@@ -67,7 +67,7 @@ describe("toReceiveCommandTimes", () => {
6767
});
6868

6969
describe("not", () => {
70-
it("should pass when not called", async () => {
70+
it("should pass when not called", () => {
7171
const s3Mock = mockClient(S3Client);
7272
expect(s3Mock).not.toReceiveCommandTimes(PutObjectCommand, 1);
7373
});
@@ -89,7 +89,7 @@ describe("toReceiveCommandTimes", () => {
8989
});
9090

9191
describe("toHaveReceivedCommandTimes", () => {
92-
it("should pass with 0 received commands", async () => {
92+
it("should pass with 0 received commands", () => {
9393
const s3Mock = mockClient(S3Client);
9494
expect(s3Mock).toHaveReceivedCommandTimes(PutObjectCommand, 0);
9595
});
@@ -117,7 +117,7 @@ describe("toHaveReceivedCommandTimes", () => {
117117
});
118118

119119
describe("not", () => {
120-
it("should pass when not called", async () => {
120+
it("should pass when not called", () => {
121121
const s3Mock = mockClient(S3Client);
122122
expect(s3Mock).not.toHaveReceivedCommandTimes(PutObjectCommand, 1);
123123
});
@@ -146,7 +146,7 @@ describe("toReceiveCommandOnce", () => {
146146
expect(s3Mock).toReceiveCommandOnce(GetObjectCommand);
147147
});
148148

149-
it.fails("should fail when not called", async () => {
149+
it.fails("should fail when not called", () => {
150150
const s3Mock = mockClient(S3Client);
151151
expect(s3Mock).toReceiveCommandOnce(GetObjectCommand);
152152
});
@@ -169,7 +169,7 @@ describe("toReceiveCommandOnce", () => {
169169
});
170170

171171
describe("not", () => {
172-
it("should pass when not called", async () => {
172+
it("should pass when not called", () => {
173173
const s3Mock = mockClient(S3Client);
174174
expect(s3Mock).not.toReceiveCommandOnce(GetObjectCommand);
175175
});
@@ -205,7 +205,7 @@ describe("toHaveReceivedCommandOnce", () => {
205205
expect(s3Mock).toHaveReceivedCommandOnce(GetObjectCommand);
206206
});
207207

208-
it.fails("should fail when not called", async () => {
208+
it.fails("should fail when not called", () => {
209209
const s3Mock = mockClient(S3Client);
210210
expect(s3Mock).toHaveReceivedCommandOnce(GetObjectCommand);
211211
});
@@ -228,7 +228,7 @@ describe("toHaveReceivedCommandOnce", () => {
228228
});
229229

230230
describe("not", () => {
231-
it("should pass when not called", async () => {
231+
it("should pass when not called", () => {
232232
const s3Mock = mockClient(S3Client);
233233
expect(s3Mock).not.toHaveReceivedCommandOnce(GetObjectCommand);
234234
});
@@ -258,7 +258,7 @@ describe("toHaveReceivedCommandOnce", () => {
258258
});
259259

260260
describe("toReceiveCommand", () => {
261-
it.fails("should fail when no command received", async () => {
261+
it.fails("should fail when no command received", () => {
262262
const s3Mock = mockClient(S3Client);
263263
expect(s3Mock).toReceiveCommand(GetObjectCommand);
264264
});
@@ -286,7 +286,7 @@ describe("toReceiveCommand", () => {
286286
});
287287

288288
describe("not", () => {
289-
it("should pass when no command received", async () => {
289+
it("should pass when no command received", () => {
290290
const s3Mock = mockClient(S3Client);
291291
expect(s3Mock).not.toReceiveCommand(GetObjectCommand);
292292
});
@@ -316,7 +316,7 @@ describe("toReceiveCommand", () => {
316316
});
317317

318318
describe("toHaveReceivedCommand", () => {
319-
it.fails("should fail when no command received", async () => {
319+
it.fails("should fail when no command received", () => {
320320
const s3Mock = mockClient(S3Client);
321321
expect(s3Mock).toHaveReceivedCommand(GetObjectCommand);
322322
});
@@ -344,7 +344,7 @@ describe("toHaveReceivedCommand", () => {
344344
});
345345

346346
describe("not", () => {
347-
it("should pass when no command received", async () => {
347+
it("should pass when no command received", () => {
348348
const s3Mock = mockClient(S3Client);
349349
expect(s3Mock).not.toHaveReceivedCommand(GetObjectCommand);
350350
});
@@ -471,7 +471,7 @@ describe("toReceiveCommandWith", () => {
471471
});
472472

473473
describe("not", () => {
474-
it("shoud pass when never called", async () => {
474+
it("shoud pass when never called", () => {
475475
const s3Mock = mockClient(S3Client);
476476
expect(s3Mock).not.toReceiveCommandWith(PutObjectCommand, {
477477
Bucket: "foo",
@@ -623,7 +623,7 @@ describe("toHaveReceivedCommandWith", () => {
623623
});
624624

625625
describe("not", () => {
626-
it("shoud pass when never called", async () => {
626+
it("shoud pass when never called", () => {
627627
const s3Mock = mockClient(S3Client);
628628
expect(s3Mock).not.toHaveReceivedCommandWith(PutObjectCommand, {
629629
Bucket: "foo",
@@ -975,7 +975,7 @@ describe("toReceiveLastCommandWith", () => {
975975
});
976976
});
977977

978-
it.fails("should fail when not called at all", async () => {
978+
it.fails("should fail when not called at all", () => {
979979
const s3Mock = mockClient(S3Client);
980980
expect(s3Mock).toReceiveLastCommandWith(GetObjectCommand, {
981981
Bucket: "foo",
@@ -984,7 +984,7 @@ describe("toReceiveLastCommandWith", () => {
984984
});
985985

986986
describe("not", () => {
987-
it("should pass when not called", async () => {
987+
it("should pass when not called", () => {
988988
const s3Mock = mockClient(S3Client);
989989
expect(s3Mock).not.toReceiveLastCommandWith(GetObjectCommand, {
990990
Bucket: "foo",
@@ -1106,7 +1106,7 @@ describe("toHaveReceivedLastCommandWith", () => {
11061106
});
11071107
});
11081108

1109-
it.fails("should fail when not called at all", async () => {
1109+
it.fails("should fail when not called at all", () => {
11101110
const s3Mock = mockClient(S3Client);
11111111
expect(s3Mock).toHaveReceivedLastCommandWith(GetObjectCommand, {
11121112
Bucket: "foo",
@@ -1115,7 +1115,7 @@ describe("toHaveReceivedLastCommandWith", () => {
11151115
});
11161116

11171117
describe("not", () => {
1118-
it("should pass when not called", async () => {
1118+
it("should pass when not called", () => {
11191119
const s3Mock = mockClient(S3Client);
11201120
expect(s3Mock).not.toHaveReceivedLastCommandWith(GetObjectCommand, {
11211121
Bucket: "foo",

tests/utils.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ describe("notNull", () => {
1717
});
1818

1919
describe("ordinalOf", () => {
20-
const cases: Array<[number, string]> = [
20+
const cases: [number, string][] = [
2121
[1, "1st"],
2222
[2, "2nd"],
2323
[3, "3rd"],

tests/vitest.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* eslint-disable @typescript-eslint/no-empty-interface */
1+
/* eslint-disable @typescript-eslint/no-empty-object-type */
22
import "vitest";
33

44
import { CustomMatcher } from "../src/matcher.ts";

0 commit comments

Comments
 (0)