Skip to content

Commit 8ba9d87

Browse files
authored
Merge pull request #91 from retejs/new-linter
fix: update cli and fix linting errors
2 parents 75368ff + a71d4dc commit 8ba9d87

11 files changed

Lines changed: 2130 additions & 1679 deletions

File tree

.eslintrc

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

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@ node_modules
44
npm-debug.log
55
dist
66
docs
7+
/coverage
8+
.rete-cli
9+
.sonar

eslint.config.mjs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import tseslint from 'typescript-eslint';
2+
import configs from 'rete-cli/eslint.config.mjs';
3+
import globals from 'globals'
4+
5+
export default tseslint.config(
6+
...configs,
7+
{
8+
languageOptions: {
9+
globals: {
10+
...globals.browser
11+
}
12+
}
13+
}
14+
)

package-lock.json

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

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@
2727
"rete-area-plugin": "^2.0.0"
2828
},
2929
"devDependencies": {
30+
"globals": "^15.9.0",
3031
"rete": "^2.0.1",
3132
"rete-area-plugin": "^2.0.0",
32-
"rete-cli": "^1.0.2",
33-
"typescript": "5.0"
33+
"rete-cli": "~2.0.1"
3434
},
3535
"dependencies": {
3636
"@babel/runtime": "^7.21.0"

src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,21 +84,21 @@ export class ContextMenuPlugin<Schemes extends BaseSchemes> extends Scope<never,
8484
element.style.top = `${context.data.event.clientY}px`
8585
element.style.display = ''
8686

87-
parent.emit({
87+
void parent.emit({
8888
type: 'render',
8989
data: {
9090
type: 'contextmenu',
9191
element,
9292
searchBar,
9393
onHide() {
94-
parent.emit({ type: 'unmount', data: { element } })
94+
void parent.emit({ type: 'unmount', data: { element } })
9595
},
9696
items: list
9797
}
9898
})
9999
} else if (context.type === 'pointerdown') {
100100
if (!context.data.event.composedPath().includes(element)) {
101-
parent.emit({ type: 'unmount', data: { element } })
101+
void parent.emit({ type: 'unmount', data: { element } })
102102
}
103103
}
104104
return context

src/presets/classic/factory.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,29 @@ export function createItem<S extends BSchemes>(
99
key: string | number,
1010
context: { editor: NodeEditor<S>, area: BaseAreaPlugin<S, any> }
1111
): Item {
12-
const item = {
12+
const item: Item = {
1313
label,
14-
key: String(key)
14+
key: String(key),
15+
handler() {
16+
/* noop */
17+
}
1518
}
1619

1720
if (typeof factory === 'function') {
18-
return <Item>{
21+
return {
1922
...item,
2023
async handler() {
2124
const node = await factory()
2225

2326
await context.editor.addNode(node)
2427

25-
context.area.translate(node.id, context.area.area.pointer)
28+
void context.area.translate(node.id, context.area.area.pointer)
2629
}
27-
}
30+
} satisfies Item
2831
}
29-
return <Item>{
32+
return {
3033
...item,
31-
handler() {/* do nothing */},
34+
handler() { /* do nothing */ },
3235
subitems: factory.map((data, i) => createItem(data, i, context))
33-
}
36+
} satisfies Item
3437
}

src/presets/classic/index.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ import { BSchemes, ItemDefinition } from './types'
1010
* Configures nodes/actions items for root and Delete/Clone items for nodes
1111
* @param nodes List of items
1212
* @example Presets.classic.setup([
13-
["Math", [
14-
["Number", () => new NumberNode()],
15-
]]
16-
])
13+
* ["Math", [
14+
* ["Number", () => new NumberNode()],
15+
* ]]
16+
*])
1717
*/
1818
export function setup<Schemes extends BSchemes>(nodes: ItemDefinition<Schemes>[]) {
19-
return <Items<Schemes>>(function (context, plugin) {
19+
return function (context, plugin) {
2020
const area = plugin.parentScope<BaseAreaPlugin<Schemes, any>>(BaseAreaPlugin)
2121
const editor = area.parentScope<NodeEditor<Schemes>>(NodeEditor)
2222

@@ -60,16 +60,18 @@ export function setup<Schemes extends BSchemes>(nodes: ItemDefinition<Schemes>[]
6060

6161
await editor.addNode(node)
6262

63-
area.translate(node.id, area.area.pointer)
63+
void area.translate(node.id, area.area.pointer)
6464
}
6565
}
6666

6767
return {
6868
searchBar: false,
6969
list: [
7070
deleteItem,
71-
...(cloneItem ? [cloneItem] : [])
71+
...cloneItem
72+
? [cloneItem]
73+
: []
7274
]
7375
}
74-
})
76+
} satisfies Items<Schemes>
7577
}

src/presets/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* Presets that create items for root and node specific context menu.
33
* @module
4-
*/
4+
*/
55

66
export * as classic from './classic'

src/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ export type Position = { x: number, y: number }
1010
export type Item = {
1111
label: string
1212
key: string
13-
handler(): void
13+
handler(): void | Promise<void>
1414
subitems?: Item[]
1515
}
1616

1717
export type ItemsCollection = {
18-
searchBar?: boolean,
18+
searchBar?: boolean
1919
list: Item[]
2020
}
2121

0 commit comments

Comments
 (0)