Feat/nestjs connectrpc #152
Errors 25, Warnings 1
Found 25 errors and 1 warnings
Annotations
Check failure on line 43 in packages/nestjs-connectrpc/src/connectrpc.decorators.ts
github-actions / Lint
(@typescript-eslint/array-type): Array type using 'MethodKey[]' is forbidden. Use 'Array<MethodKey>' instead.
Array type using 'MethodKey[]' is forbidden. Use 'Array<MethodKey>' instead.
Raw output
40 | const streamMethodKeys: MethodKeys =
41 | Reflect.getMetadata(STREAM_METHOD_DECORATOR_KEY, target) || []
> 42 | const allMethodKeys = [...unaryMethodKeys, ...streamMethodKeys] as MethodKey[]
| ^
43 |
44 | allMethodKeys.forEach((methodImpl) => {
45 | const { key: functionName, methodType } = methodImpl
Check failure on line 25 in packages/nestjs-connectrpc/src/utils/async.utils.ts
github-actions / Lint
(@typescript-eslint/no-unused-vars): 'didComplete' is assigned a value but never used.
'didComplete' is assigned a value but never used.
Raw output
22 | export async function* observableToAsyncGenerator<T>(observable: Observable<T>): AsyncGenerator<T> {
23 | const queue = new Subject<T>()
> 24 | let didComplete = false
| ^
25 |
26 | const subscriber = observable.subscribe({
27 | next: (value) => queue.next(value),
Check failure on line 28 in packages/nestjs-connectrpc/src/utils/async.utils.ts
github-actions / Lint
(@typescript-eslint/no-confusing-void-expression): Returning a void expression from an arrow function shorthand is forbidden. Please add braces to the arrow function.
Returning a void expression from an arrow function shorthand is forbidden. Please add braces to the arrow function.
Raw output
25 |
26 | const subscriber = observable.subscribe({
> 27 | next: (value) => queue.next(value),
| ^
28 | error: (error) => queue.error(error),
29 | complete: () => {
30 | didComplete = true
Check failure on line 29 in packages/nestjs-connectrpc/src/utils/async.utils.ts
github-actions / Lint
(@typescript-eslint/no-confusing-void-expression): Returning a void expression from an arrow function shorthand is forbidden. Please add braces to the arrow function.
Returning a void expression from an arrow function shorthand is forbidden. Please add braces to the arrow function.
Raw output
26 | const subscriber = observable.subscribe({
27 | next: (value) => queue.next(value),
> 28 | error: (error) => queue.error(error),
| ^
29 | complete: () => {
30 | didComplete = true
31 | queue.complete()
Check failure on line 37 in packages/nestjs-connectrpc/src/utils/async.utils.ts
github-actions / Lint
(@typescript-eslint/no-use-before-define): 'asyncIterator' was used before it was defined.
'asyncIterator' was used before it was defined.
Raw output
34 |
35 | try {
> 36 | for await (const item of asyncIterator(queue)) {
| ^
37 | yield item
38 | }
39 | } finally {
Check failure on line 51 in packages/nestjs-connectrpc/src/utils/async.utils.ts
github-actions / Lint
(@typescript-eslint/no-unused-vars): 'values' is assigned a value but never used.
'values' is assigned a value but never used.
Raw output
48 | */
49 | async function* asyncIterator<T>(subject: Subject<T>): AsyncIterableIterator<T> {
> 50 | const values: T[] = []
| ^
51 | const nextValue = () =>
52 | new Promise<T>((resolve, reject) => {
53 | subject.subscribe({
Check failure on line 51 in packages/nestjs-connectrpc/src/utils/async.utils.ts
github-actions / Lint
(@typescript-eslint/array-type): Array type using 'T[]' is forbidden. Use 'Array<T>' instead.
Array type using 'T[]' is forbidden. Use 'Array<T>' instead.
Raw output
48 | */
49 | async function* asyncIterator<T>(subject: Subject<T>): AsyncIterableIterator<T> {
> 50 | const values: T[] = []
| ^
51 | const nextValue = () =>
52 | new Promise<T>((resolve, reject) => {
53 | subject.subscribe({
Check failure on line 52 in packages/nestjs-connectrpc/src/utils/async.utils.ts
github-actions / Lint
(@typescript-eslint/explicit-function-return-type): Missing return type on function.
Missing return type on function.
Raw output
49 | async function* asyncIterator<T>(subject: Subject<T>): AsyncIterableIterator<T> {
50 | const values: T[] = []
> 51 | const nextValue = () =>
| ^
52 | new Promise<T>((resolve, reject) => {
53 | subject.subscribe({
54 | next: (val) => resolve(val),
Check failure on line 52 in packages/nestjs-connectrpc/src/utils/async.utils.ts
github-actions / Lint
(@typescript-eslint/promise-function-async): Functions that return promises must be async.
Functions that return promises must be async.
Raw output
49 | async function* asyncIterator<T>(subject: Subject<T>): AsyncIterableIterator<T> {
50 | const values: T[] = []
> 51 | const nextValue = () =>
| ^
52 | new Promise<T>((resolve, reject) => {
53 | subject.subscribe({
54 | next: (val) => resolve(val),
Check failure on line 55 in packages/nestjs-connectrpc/src/utils/async.utils.ts
github-actions / Lint
(@typescript-eslint/no-confusing-void-expression): Returning a void expression from an arrow function shorthand is forbidden. Please add braces to the arrow function.
Returning a void expression from an arrow function shorthand is forbidden. Please add braces to the arrow function.
Raw output
52 | new Promise<T>((resolve, reject) => {
53 | subject.subscribe({
> 54 | next: (val) => resolve(val),
| ^
55 | error: (err) => reject(err),
56 | complete: () => resolve(null as any),
57 | })
Check failure on line 56 in packages/nestjs-connectrpc/src/utils/async.utils.ts
github-actions / Lint
(@typescript-eslint/no-confusing-void-expression): Returning a void expression from an arrow function shorthand is forbidden. Please add braces to the arrow function.
Returning a void expression from an arrow function shorthand is forbidden. Please add braces to the arrow function.
Raw output
53 | subject.subscribe({
54 | next: (val) => resolve(val),
> 55 | error: (err) => reject(err),
| ^
56 | complete: () => resolve(null as any),
57 | })
58 | })
Check failure on line 57 in packages/nestjs-connectrpc/src/utils/async.utils.ts
github-actions / Lint
(@typescript-eslint/no-confusing-void-expression): Returning a void expression from an arrow function shorthand is forbidden. Please add braces to the arrow function.
Returning a void expression from an arrow function shorthand is forbidden. Please add braces to the arrow function.
Raw output
54 | next: (val) => resolve(val),
55 | error: (err) => reject(err),
> 56 | complete: () => resolve(null as any),
| ^
57 | })
58 | })
59 |
Check failure on line 57 in packages/nestjs-connectrpc/src/utils/async.utils.ts
github-actions / Lint
(@typescript-eslint/no-unsafe-argument): Unsafe argument of type `any` assigned to a parameter of type `T | PromiseLike<T>`.
Unsafe argument of type `any` assigned to a parameter of type `T | PromiseLike<T>`.
Raw output
54 | next: (val) => resolve(val),
55 | error: (err) => reject(err),
> 56 | complete: () => resolve(null as any),
| ^
57 | })
58 | })
59 |
Check failure on line 62 in packages/nestjs-connectrpc/src/utils/async.utils.ts
github-actions / Lint
(no-await-in-loop): Unexpected `await` inside a loop.
Unexpected `await` inside a loop.
Raw output
59 |
60 | while (true) {
> 61 | const item = await nextValue()
| ^
62 | if (item === null) return
63 | yield item
64 | }
Check failure on line 107 in packages/nestjs-connectrpc/src/utils/async.utils.ts
github-actions / Lint
(@typescript-eslint/no-unsafe-call): Unsafe call of an `any` typed value.
Unsafe call of an `any` typed value.
Raw output
104 | if (hasSubscribe(resultOrDeferred)) {
105 | return new Observable<T>((subscriber) => {
> 106 | ;(resultOrDeferred as any).subscribe({
| ^
107 | next: (value: any) => subscriber.next(value as T),
108 | error: (error: any) => subscriber.error(error),
109 | complete: () => subscriber.complete(),
Check failure on line 108 in packages/nestjs-connectrpc/src/utils/async.utils.ts
github-actions / Lint
(@typescript-eslint/no-confusing-void-expression): Returning a void expression from an arrow function shorthand is forbidden. Please add braces to the arrow function.
Returning a void expression from an arrow function shorthand is forbidden. Please add braces to the arrow function.
Raw output
105 | return new Observable<T>((subscriber) => {
106 | ;(resultOrDeferred as any).subscribe({
> 107 | next: (value: any) => subscriber.next(value as T),
| ^
108 | error: (error: any) => subscriber.error(error),
109 | complete: () => subscriber.complete(),
110 | })
Check failure on line 109 in packages/nestjs-connectrpc/src/utils/async.utils.ts
github-actions / Lint
(@typescript-eslint/no-confusing-void-expression): Returning a void expression from an arrow function shorthand is forbidden. Please add braces to the arrow function.
Returning a void expression from an arrow function shorthand is forbidden. Please add braces to the arrow function.
Raw output
106 | ;(resultOrDeferred as any).subscribe({
107 | next: (value: any) => subscriber.next(value as T),
> 108 | error: (error: any) => subscriber.error(error),
| ^
109 | complete: () => subscriber.complete(),
110 | })
111 | })
Check failure on line 110 in packages/nestjs-connectrpc/src/utils/async.utils.ts
github-actions / Lint
(@typescript-eslint/no-confusing-void-expression): Returning a void expression from an arrow function shorthand is forbidden. Please add braces to the arrow function.
Returning a void expression from an arrow function shorthand is forbidden. Please add braces to the arrow function.
Raw output
107 | next: (value: any) => subscriber.next(value as T),
108 | error: (error: any) => subscriber.error(error),
> 109 | complete: () => subscriber.complete(),
| ^
110 | })
111 | })
112 | }
Check failure on line 115 in packages/nestjs-connectrpc/src/utils/async.utils.ts
github-actions / Lint
(@typescript-eslint/no-unsafe-argument): Unsafe argument of type `any` assigned to a parameter of type `Observable<unknown>`.
Unsafe argument of type `any` assigned to a parameter of type `Observable<unknown>`.
Raw output
112 | }
113 | if (hasToPromise(resultOrDeferred)) {
> 114 | return from(lastValueFrom(resultOrDeferred as any)) as Observable<T>
| ^
115 | }
116 | return new Observable<T>((subscriber) => {
117 | subscriber.next(resultOrDeferred as T)
Check failure on line 118 in packages/nestjs-connectrpc/src/utils/async.utils.ts
github-actions / Lint
(@typescript-eslint/no-unnecessary-type-assertion): This assertion is unnecessary since it does not change the type of the expression.
This assertion is unnecessary since it does not change the type of the expression.
Raw output
115 | }
116 | return new Observable<T>((subscriber) => {
> 117 | subscriber.next(resultOrDeferred as T)
| ^
118 | subscriber.complete()
119 | })
120 | }
Check failure on line 71 in packages/nestjs-connectrpc/src/utils/router.utils.ts
github-actions / Lint
(@typescript-eslint/explicit-function-return-type): Missing return type on function.
Missing return type on function.
Raw output
68 | switch (streaming) {
69 | case MethodType.NO_STREAMING:
> 70 | serviceHandlersMap[service][rpc] = async (request: unknown, context: unknown) => {
| ^
71 | const resultOrDeferred = await handlerMetadata(request, context)
72 | return lastValueFrom(transformToObservable(resultOrDeferred))
73 | }
Check failure on line 78 in packages/nestjs-connectrpc/src/utils/router.utils.ts
github-actions / Lint
(@typescript-eslint/explicit-function-return-type): Missing return type on function.
Missing return type on function.
Raw output
75 |
76 | case MethodType.RX_STREAMING:
> 77 | serviceHandlersMap[service][rpc] = async function* (
| ^
78 | request: unknown,
79 | context: unknown
80 | ) {
Check warning on line 78 in packages/nestjs-connectrpc/src/utils/router.utils.ts
github-actions / Lint
(func-names): Unexpected unnamed async generator function.
Unexpected unnamed async generator function.
Raw output
75 |
76 | case MethodType.RX_STREAMING:
> 77 | serviceHandlersMap[service][rpc] = async function* (
| ^
78 | request: unknown,
79 | context: unknown
80 | ) {
Check failure on line 84 in packages/nestjs-connectrpc/src/utils/router.utils.ts
github-actions / Lint
(@typescript-eslint/sort-type-constituents): Union type constituents must be sorted.
Union type constituents must be sorted.
Raw output
81 | const streamOrValue = await handlerMetadata(request, context)
82 | yield* toAsyncGenerator(
> 83 | streamOrValue as Observable<unknown> | AsyncGenerator<unknown>
| ^
84 | )
85 | }
86 | break
Check failure on line 84 in packages/nestjs-connectrpc/src/utils/router.utils.ts
github-actions / Lint
(@typescript-eslint/no-unnecessary-type-arguments): This is the default value for this type parameter, so it can be omitted.
This is the default value for this type parameter, so it can be omitted.
Raw output
81 | const streamOrValue = await handlerMetadata(request, context)
82 | yield* toAsyncGenerator(
> 83 | streamOrValue as Observable<unknown> | AsyncGenerator<unknown>
| ^
84 | )
85 | }
86 | break