Skip to content

Commit 685ef0e

Browse files
committed
Fixed snapshots & syntactic invalidities
1 parent 9aa44ab commit 685ef0e

File tree

5 files changed

+112
-94
lines changed

5 files changed

+112
-94
lines changed

crates/biome_js_analyze/tests/specs/style/useUnifiedTypeSignatures/invalid.ts.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -930,7 +930,7 @@ invalid.ts:163:1 lint/style/useUnifiedTypeSignatures FIXABLE ━━━━━
930930
```
931931
invalid.ts:166:1 lint/style/useUnifiedTypeSignatures FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
932932
933-
i Overload signatures are hard to read and maintain.
933+
i Multiple similar overload signatures are hard to read and maintain.
934934
935935
164 │ declare function f10(this: number): void;
936936
165 │
@@ -956,7 +956,7 @@ invalid.ts:166:1 lint/style/useUnifiedTypeSignatures FIXABLE ━━━━━
956956
```
957957
invalid.ts:169:1 lint/style/useUnifiedTypeSignatures FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
958958
959-
i Overload signatures are hard to read and maintain.
959+
i Multiple similar overload signatures are hard to read and maintain.
960960
961961
167 │ function tuple([c, d]: [number, string]): void;
962962
168 │
@@ -982,7 +982,7 @@ invalid.ts:169:1 lint/style/useUnifiedTypeSignatures FIXABLE ━━━━━
982982
```
983983
invalid.ts:174:1 lint/style/useUnifiedTypeSignatures FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
984984
985-
i Overload signatures are hard to read and maintain.
985+
i Multiple similar overload signatures are hard to read and maintain.
986986
987987
173 │ // Merges latter 2 type parameters into 1
988988
> 174 │ function fizzbuzz([a]: SomeType<string>, { c }: Record<"c", void>): void;

crates/biome_js_analyze/tests/specs/style/useUnifiedTypeSignatures/invalidJsdoc.ts.snap

Lines changed: 97 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ function foo(baz: string): string;
1616
function foo(qux: boolean): string;
1717
function foo(whatever: any): any {}
1818
19+
// TODO: Decide on whether to allow or deny this example (TSEslint passes, though of dubious merit)
20+
// /** baba is you */
21+
// export function foo(bar: string): void
22+
// export function foo(bar: number): void
23+
// export function foo(bar: any): void {}
24+
1925
// jsdoc on implementation
2026
2127
function bar(a: number): string;
@@ -61,7 +67,7 @@ declare function f10(this: number): void;
6167
```
6268
invalidJsdoc.ts:2:1 lint/style/useUnifiedTypeSignatures FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
6369
64-
i Overload signatures are hard to read and maintain.
70+
i Multiple similar overload signatures are hard to read and maintain.
6571
6672
1 │ // no jsdoc is still fair game
6773
> 2 │ function f(bar: number): string;
@@ -85,7 +91,7 @@ invalidJsdoc.ts:2:1 lint/style/useUnifiedTypeSignatures FIXABLE ━━━━
8591
```
8692
invalidJsdoc.ts:9:1 lint/style/useUnifiedTypeSignatures FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
8793
88-
i Overload signatures are hard to read and maintain.
94+
i Multiple similar overload signatures are hard to read and maintain.
8995
9096
7 │ /** jsdoc 1 */
9197
8 │ function foo(bar: number): string;
@@ -108,126 +114,138 @@ invalidJsdoc.ts:9:1 lint/style/useUnifiedTypeSignatures FIXABLE ━━━━
108114
```
109115

110116
```
111-
invalidJsdoc.ts:15:1 lint/style/useUnifiedTypeSignatures FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
117+
invalidJsdoc.ts:21:1 lint/style/useUnifiedTypeSignatures FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
112118
113-
i Overload signatures are hard to read and maintain.
119+
i Multiple similar overload signatures are hard to read and maintain.
114120
115-
13 │ // jsdoc on implementation
116-
14
117-
> 15 │ function bar(a: number): string;
121+
19 │ // jsdoc on implementation
122+
20
123+
> 21 │ function bar(a: number): string;
118124
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
119-
16 │ function bar(a: string): string;
120-
17 │ function bar(a: boolean): string;
125+
22 │ function bar(a: string): string;
126+
23 │ function bar(a: boolean): string;
121127
122128
i Unsafe fix: Combine overloads using a type union.
123129
124130
10 10 │ function foo(qux: boolean): string;
125131
11 11 │ function foo(whatever: any): any {}
126132
12 │ -
127-
13 │ - //·jsdoc·on·implementation
128-
14 │ -
129-
15 │ - function·bar(a:·number):·string;
130-
16 │ - function·bar(a:·string):·string;
133+
13 │ - //·TODO:·Decide·on·whether·to·allow·or·deny·this·example·(TSEslint·passes,·though·of·dubious·merit)
134+
14 │ - //·/**·baba·is·you·*/
135+
15 │ - //·export·function·foo(bar:·string):·void→
136+
16 │ - //·export·function·foo(bar:·number):·void
137+
17 │ - //·export·function·foo(bar:·any):·void·{}·
138+
18 │ -
139+
19 │ - //·jsdoc·on·implementation
140+
20 │ -
141+
21 │ - function·bar(a:·number):·string;
142+
22 │ - function·bar(a:·string):·string;
131143
12 │ +
132-
13 │ + //·jsdoc·on·implementation
133-
14 │ +
134-
15 │ + function·bar(a:·string·|·number):·string;
135-
17 16 │ function bar(a: boolean): string;
136-
18 17 │ /** jsdoc 1 */
144+
13 │ + //·TODO:·Decide·on·whether·to·allow·or·deny·this·example·(TSEslint·passes,·though·of·dubious·merit)
145+
14 │ + //·/**·baba·is·you·*/
146+
15 │ + //·export·function·foo(bar:·string):·void→
147+
16 │ + //·export·function·foo(bar:·number):·void
148+
17 │ + //·export·function·foo(bar:·any):·void·{}·
149+
18 │ +
150+
19 │ + //·jsdoc·on·implementation
151+
20 │ +
152+
21 │ + function·bar(a:·string·|·number):·string;
153+
23 22 │ function bar(a: boolean): string;
154+
24 23 │ /** jsdoc 1 */
137155
138156
139157
```
140158

141159
```
142-
invalidJsdoc.ts:26:2 lint/style/useUnifiedTypeSignatures FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
160+
invalidJsdoc.ts:32:2 lint/style/useUnifiedTypeSignatures FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
143161
144-
i Overload signatures are hard to read and maintain.
162+
i Multiple similar overload signatures are hard to read and maintain.
145163
146-
24 │ (a: string, b: number, c: number): string;
147-
25 │ /*************************** HIJKLMNOPQRS */
148-
> 26 │ (a: number, b: number, c: string): string;
164+
30 │ (a: string, b: number, c: number): string;
165+
31 │ /*************************** HIJKLMNOPQRS */
166+
> 32 │ (a: number, b: number, c: string): string;
149167
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
150-
27 │ /* t u v w x y z */
151-
28 │ (a: number, b: string, c: string): string;
168+
33 │ /* t u v w x y z */
169+
34 │ (a: number, b: string, c: string): string;
152170
153171
i Unsafe fix: Combine overloads using a type union.
154172
155-
23 23 │ // a b c d e f g...
156-
24 24 │ (a: string, b: number, c: number): string;
157-
25 │ - → /***************************·HIJKLMNOPQRS·*/
158-
26 │ - → (a:·number,·b:·number,·c:·string):·string;
159-
27 │ - → /*·t·u·v·w·x·y·z·*/
160-
28 │ - → (a:·number,·b:·string,·c:·string):·string;
161-
25 │ + → /***************************·HIJKLMNOPQRS·*/
162-
26 │ + → → /*·t·u·v·w·x·y·z·*/
163-
27 │ + → (a:·number,·b:·string·|·number,·c:·string):·string;
164-
29 28 │ }
165-
30 29
173+
29 29 │ // a b c d e f g...
174+
30 30 │ (a: string, b: number, c: number): string;
175+
31 │ - → /***************************·HIJKLMNOPQRS·*/
176+
32 │ - → (a:·number,·b:·number,·c:·string):·string;
177+
33 │ - → /*·t·u·v·w·x·y·z·*/
178+
34 │ - → (a:·number,·b:·string,·c:·string):·string;
179+
31 │ + → /***************************·HIJKLMNOPQRS·*/
180+
32 │ + → → /*·t·u·v·w·x·y·z·*/
181+
33 │ + → (a:·number,·b:·string·|·number,·c:·string):·string;
182+
35 34 │ }
183+
36 35
166184
167185
168186
```
169187

170188
```
171-
invalidJsdoc.ts:34:2 lint/style/useUnifiedTypeSignatures FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
189+
invalidJsdoc.ts:40:2 lint/style/useUnifiedTypeSignatures FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
172190
173-
i Overload signatures are hard to read and maintain.
191+
i Multiple similar overload signatures are hard to read and maintain.
174192
175-
32 │ class banana {
176-
33/** bake a cake */
177-
> 34public bake(cakeType: string): void;
193+
38 │ class banana {
194+
39/** bake a cake */
195+
> 40public bake(cakeType: string): void;
178196
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
179-
35/** bake a cake */
180-
36public bake(flourAmt: number): void;
197+
41/** bake a cake */
198+
42public bake(flourAmt: number): void;
181199
182200
i Unsafe fix: Combine overloads using a type union.
183201
184-
31 31// same jsdocs
185-
32 32class banana {
186-
33-/**·bake·a·cake·*/
187-
34-public·bake(cakeType:·string):·void;
188-
35 33/** bake a cake */
189-
36-public·bake(flourAmt:·number):·void;
190-
34+ → → /**·bake·a·cake·*/
191-
35+public·bake(flourAmt:·number·|·string):·void;
192-
37 36/** bake a cake */
193-
38 37public bake(ingredients: object): void;
202+
37 37// same jsdocs
203+
38 38class banana {
204+
39-/**·bake·a·cake·*/
205+
40-public·bake(cakeType:·string):·void;
206+
41 39/** bake a cake */
207+
42-public·bake(flourAmt:·number):·void;
208+
40+ → → /**·bake·a·cake·*/
209+
41+public·bake(flourAmt:·number·|·string):·void;
210+
43 42/** bake a cake */
211+
44 43public bake(ingredients: object): void;
194212
195213
196214
```
197215
198216
```
199-
invalidJsdoc.ts:46:1 lint/style/useUnifiedTypeSignatures FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
217+
invalidJsdoc.ts:52:1 lint/style/useUnifiedTypeSignatures FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
200218
201-
i Overload signatures are hard to read and maintain.
219+
i Multiple similar overload signatures are hard to read and maintain.
202220
203-
44/** jsdoc 2 */
204-
45/** jsdoc 3 */
205-
> 46declare function f10(this: string): void;
221+
50/** jsdoc 2 */
222+
51/** jsdoc 3 */
223+
> 52declare function f10(this: string): void;
206224
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
207-
47/** jsdoc 1 */
208-
48/** jsdoc 2 */
225+
53/** jsdoc 1 */
226+
54/** jsdoc 2 */
209227
210228
i Unsafe fix: Combine overloads using a type union.
211229
212-
39 39public bake(whatever: any): void {};
213-
40 40 │ }
214-
41-
215-
42- //·several·identical·jsdocs·(all·get·checked)
216-
43- /**·jsdoc·1·*/
217-
44- /**·jsdoc·2·*/
218-
45- /**·jsdoc·3·*/
219-
46- declare·function·f10(this:·string):·void;
220-
41+
221-
42+ //·several·identical·jsdocs·(all·get·checked)
222-
43+ /**·jsdoc·1·*/
223-
44+ /**·jsdoc·2·*/
224-
45+ /**·jsdoc·3·*/
225-
47 46/** jsdoc 1 */
226-
48 47/** jsdoc 2 */
227-
49 48/** jsdoc 3 */
228-
50- declare·function·f10(this:·number):·void;
229-
49+ declare·function·f10(this:·number·|·string):·void;
230-
51 50
230+
45 45public bake(whatever: any): void {};
231+
46 46 │ }
232+
47-
233+
48- //·several·identical·jsdocs·(all·get·checked)
234+
49- /**·jsdoc·1·*/
235+
50- /**·jsdoc·2·*/
236+
51- /**·jsdoc·3·*/
237+
52- declare·function·f10(this:·string):·void;
238+
47+
239+
48+ //·several·identical·jsdocs·(all·get·checked)
240+
49+ /**·jsdoc·1·*/
241+
50+ /**·jsdoc·2·*/
242+
51+ /**·jsdoc·3·*/
243+
53 52/** jsdoc 1 */
244+
54 53/** jsdoc 2 */
245+
55 54/** jsdoc 3 */
246+
56- declare·function·f10(this:·number):·void;
247+
55+ declare·function·f10(this:·number·|·string):·void;
248+
57 56
231249
232250
233251
```

crates/biome_js_analyze/tests/specs/style/useUnifiedTypeSignatures/invalidParams.ts.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function g(whatever: any): any {}
2525
```
2626
invalidParams.ts:2:1 lint/style/useUnifiedTypeSignatures FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
2727
28-
i Overload signatures are hard to read and maintain.
28+
i Multiple similar overload signatures are hard to read and maintain.
2929
3030
1 │ // different name from implementation, but same between overloads
3131
> 2 │ function f(foo: string): string;
@@ -49,7 +49,7 @@ invalidParams.ts:2:1 lint/style/useUnifiedTypeSignatures FIXABLE ━━━━
4949
```
5050
invalidParams.ts:7:1 lint/style/useUnifiedTypeSignatures FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
5151
52-
i Overload signatures are hard to read and maintain.
52+
i Multiple similar overload signatures are hard to read and maintain.
5353
5454
6 │ // Destructuring doesn't count since they don't have names
5555
> 7 │ function f2(foo: string, {bar}: Record<"bar", string>): string;
@@ -77,7 +77,7 @@ invalidParams.ts:7:1 lint/style/useUnifiedTypeSignatures FIXABLE ━━━━
7777
```
7878
invalidParams.ts:12:1 lint/style/useUnifiedTypeSignatures FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
7979
80-
i Overload signatures are hard to read and maintain.
80+
i Multiple similar overload signatures are hard to read and maintain.
8181
8282
11 │ // neither does array spread
8383
> 12 │ function g(foo: string, [a, b]: [number, string]): string;

crates/biome_js_analyze/tests/specs/style/useUnifiedTypeSignatures/validParams.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@ export function f2(foo: string, bar: string): void;
88
export function f2(foo: number, baz: string): void;
99
export default function f2(foo: string | number, baf: string): void {};
1010

11-
export async function exams(amICooked = 0): Promise<void>;
11+
export async function exams(amICooked?: number): Promise<void>;
1212
export async function exams(reason: string): Promise<void>;
1313
export async function exams(foo: any): Promise<any> {};
1414

1515
interface frotz {
16-
(a: number, b: number, c: string) => string;
17-
(a: number, d: string, c: string) => string;
16+
(a: number, b: number, c: string): string;
17+
(a: number, d: string, c: string): string;
1818
}
1919

2020
class banana {
2121
private bake(cakeType: string): void;
2222
private bake(flourAmt: number): void;
23-
private bake(ingredients: object): void;
23+
private bake(ingredients: object): void {}
2424
}
2525

2626
declare function f10(quux: string): void;

crates/biome_js_analyze/tests/specs/style/useUnifiedTypeSignatures/validParams.ts.snap

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,22 @@ export function f2(foo: string, bar: string): void;
1414
export function f2(foo: number, baz: string): void;
1515
export default function f2(foo: string | number, baf: string): void {};
1616
17-
export async function exams(amICooked = 0): Promise<void>;
17+
export async function exams(amICooked?: number): Promise<void>;
1818
export async function exams(reason: string): Promise<void>;
1919
export async function exams(foo: any): Promise<any> {};
2020
2121
interface frotz {
22-
(a: number, b: number, c: string) => string;
23-
(a: number, d: string, c: string) => string;
22+
(a: number, b: number, c: string): string;
23+
(a: number, d: string, c: string): string;
2424
}
2525
2626
class banana {
2727
private bake(cakeType: string): void;
2828
private bake(flourAmt: number): void;
29-
private bake(ingredients: object): void;
29+
private bake(ingredients: object): void {}
3030
}
3131
3232
declare function f10(quux: string): void;
3333
declare function f10(qux: number): void;
3434
35-
```
35+
```

0 commit comments

Comments
 (0)