Skip to content

Commit d219f95

Browse files
committed
fix: update cli and fix linting errors
1 parent 05da7ba commit d219f95

File tree

13 files changed

+2139
-1747
lines changed

13 files changed

+2139
-1747
lines changed

.eslintrc

Lines changed: 0 additions & 14 deletions
This file was deleted.

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ node_modules
44
.sonarlint
55
.scannerwork
66
.nyc_output
7-
coverage
7+
/coverage
88
npm-debug.log
99
/dist
1010
docs
11+
.rete-cli
12+
.sonar

eslint.config.mjs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import tseslint from 'typescript-eslint';
2+
import configs from 'rete-cli/configs/eslint.mjs';
3+
4+
export default tseslint.config(
5+
...configs
6+
)

package-lock.json

Lines changed: 2100 additions & 1698 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@
2828
},
2929
"devDependencies": {
3030
"jest-environment-jsdom": "^29.1.2",
31-
"rete-cli": "^1.0.3",
32-
"typescript": "4.8.4"
31+
"rete-cli": "~2.0.0"
3332
},
3433
"dependencies": {
3534
"@babel/runtime": "^7.21.0"

src/presets/classic.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,9 @@ export class Control {
128128
*/
129129
type InputControlOptions<N> = {
130130
/** Whether the control is readonly. Default is `false` */
131-
readonly?: boolean,
131+
readonly?: boolean
132132
/** Initial value of the control */
133-
initial?: N,
133+
initial?: N
134134
/** Callback function that is called when the control value changes */
135135
change?: (value: N) => void
136136
}
@@ -150,7 +150,7 @@ export class InputControl<T extends 'text' | 'number', N = T extends 'text' ? st
150150
constructor(public type: T, public options?: InputControlOptions<N>) {
151151
super()
152152
this.id = getUID()
153-
this.readonly = options?.readonly
153+
this.readonly = options?.readonly ?? false
154154

155155
if (typeof options?.initial !== 'undefined') this.value = options.initial
156156
}
@@ -161,7 +161,7 @@ export class InputControl<T extends 'text' | 'number', N = T extends 'text' ? st
161161
*/
162162
setValue(value?: N) {
163163
this.value = value
164-
if (this.options?.change) this.options.change(value)
164+
if (this.options?.change) this.options.change(value!)
165165
}
166166
}
167167

src/scope.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable @typescript-eslint/no-explicit-any */
12
/* eslint-disable @typescript-eslint/naming-convention */
23
import {
34
AcceptPartialUnion, CanAssignSignal, GetAssignmentReferences, GetNonAssignableElements, Tail
@@ -19,8 +20,8 @@ export type Pipe<T> = (data: T) => Promise<undefined | T> | undefined | T
1920
export type CanAssignEach<D extends any[], F extends any[]> = D extends [infer H1, ...infer Tail1]
2021
? (
2122
F extends [infer H2, ...infer Tail2] ?
22-
[CanAssignSignal<H1, H2>, ...CanAssignEach<Tail1, Tail2>]
23-
: []
23+
[CanAssignSignal<H1, H2>, ...CanAssignEach<Tail1, Tail2>]
24+
: []
2425
) : []
2526

2627
export type ScopeAsParameter<S extends Scope<any, any[]>, Current extends any[]> = (CanAssignEach<[S['__scope']['produces'], ...S['__scope']['parents']], Current>[number] extends true
@@ -45,8 +46,8 @@ export type NestedScope<S extends Scope<any, any[]>, Current extends any[]> = (C
4546
export function useHelper<S extends Scope<any, any[]>, Signals>() {
4647
type T1 = S['__scope']['parents'][number]
4748
return {
48-
debug<T extends GetNonAssignableElements<T1, Signals>>(f: (p: GetAssignmentReferences<T, Signals>) => T) {
49-
f
49+
debug<T extends GetNonAssignableElements<T1, Signals>>(_f: (p: GetAssignmentReferences<T, Signals>) => T) {
50+
/* placeholder */
5051
}
5152
}
5253
}
@@ -75,17 +76,15 @@ export class Signal<T> {
7576
}
7677
}
7778

78-
type Type<T> = {
79-
new(...args: any[]): T;
80-
} | (abstract new (...args: any[]) => T)
79+
type Type<T> = (new(...args: any[]) => T) | (abstract new (...args: any[]) => T)
8180

8281
/**
8382
* Base class for all plugins and the core. Provides a signals mechanism to modify the data
8483
*/
8584
export class Scope<Produces, Parents extends unknown[] = []> {
8685
signal = new Signal<AcceptPartialUnion<Produces | Parents[number]>>()
8786
parent?: any // Parents['length'] extends 0 ? undefined : Scope<Parents[0], Tail<Parents>>
88-
__scope: {
87+
__scope!: {
8988
produces: Produces
9089
parents: Parents
9190
}

src/utility-types.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/* eslint-disable @typescript-eslint/no-explicit-any */
22

3+
// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
34
export type AcceptPartialUnion<T> = T | any
45

56
export type Tail<T extends any[]> = ((...args: T) => void) extends (head: any, ...tail: infer U) => any ? U : never
@@ -11,7 +12,7 @@ export type UnionToIntersection<U> = (
1112
: never
1213

1314
type StrictExcludeInner<T, U> = 0 extends (
14-
U extends T ? [T] extends [U] ? 0 : never : never
15+
U extends T ? [T] extends [U] ? 0 : never : never
1516
) ? never : T
1617
export type StrictExclude<T, U> = T extends unknown ? StrictExcludeInner<T, U> : never
1718

@@ -25,17 +26,17 @@ export type FilterMatch<T extends any[], V> = T extends [infer Head, ...infer _T
2526
? ([Head] extends [V]
2627
? [Head, ...FilterMatch<_Tail, V>]
2728
: FilterMatch<_Tail, V>
28-
): []
29+
) : []
2930

3031
export type CanAssignToAnyOf<Provides, Requires> = FilterMatch<UnionToTuple<Provides>, Requires> extends [] ? false : true
3132

3233
export type CanAssignEachTupleElemmentToAnyOf<Provides, Requires extends any[]> = Requires extends [infer Head, ...infer _Tail]
33-
? CanAssignToAnyOf<Provides, Head> extends true ?
34-
(_Tail extends []
35-
? true
36-
: CanAssignEachTupleElemmentToAnyOf<Provides, _Tail>
37-
): false
38-
: false
34+
? CanAssignToAnyOf<Provides, Head> extends true ?
35+
(_Tail extends []
36+
? true
37+
: CanAssignEachTupleElemmentToAnyOf<Provides, _Tail>
38+
) : false
39+
: false
3940

4041
export type CanAssignEachToAnyOf<Provides, Requires> = CanAssignEachTupleElemmentToAnyOf<Provides, UnionToTuple<Requires>>
4142

src/utils.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
/* global globalThis*/
2-
3-
const nodeCrypto = () => import('node:crypto')
4-
5-
const crypto = globalThis.crypto as (typeof globalThis.crypto | Awaited<ReturnType<typeof nodeCrypto>>)
1+
const crypto = globalThis.crypto as (typeof globalThis.crypto | typeof import('node:crypto'))
62

73
/**
84
* @returns A unique id

test/presets/classic.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { describe, expect, it } from '@jest/globals'
1+
import { afterEach, beforeEach, describe, expect, it } from '@jest/globals'
22

33
import { mockCryptoFromArray, resetCrypto } from '../mocks/crypto'
44

@@ -39,7 +39,7 @@ describe('ClassicPreset', () => {
3939
node.addInput('a', input)
4040

4141
expect(node.hasInput('a')).toBeTruthy()
42-
expect(node.inputs['a']).toBe(input)
42+
expect(node.inputs.a).toBe(input)
4343
})
4444

4545
it('throws error if Input already exists', () => {
@@ -66,7 +66,7 @@ describe('ClassicPreset', () => {
6666
node.addOutput('a', output)
6767

6868
expect(node.hasOutput('a')).toBeTruthy()
69-
expect(node.outputs['a']).toBe(output)
69+
expect(node.outputs.a).toBe(output)
7070
})
7171

7272
it('throws error if Output already exists', () => {

0 commit comments

Comments
 (0)