Skip to content

Commit 32a55b8

Browse files
authored
Merge pull request #24 from retejs/new-linter
fix: update cli and fix linting errors
2 parents f373142 + fbdd3af commit 32a55b8

20 files changed

+2227
-1955
lines changed

.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/configs/eslint.mjs';
3+
import gloals from 'globals'
4+
5+
export default tseslint.config(
6+
...configs,
7+
{
8+
languageOptions: {
9+
globals: {
10+
...gloals.browser
11+
}
12+
}
13+
}
14+
)

package-lock.json

Lines changed: 2129 additions & 1892 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 & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@
2626
"rete": "^2.0.0"
2727
},
2828
"devDependencies": {
29+
"globals": "^15.9.0",
2930
"rete": "^2.0.0",
30-
"rete-cli": "^1.0.2",
31+
"rete-cli": "~2.0.1",
3132
"rollup-plugin-sass": "^0.9.2"
3233
},
3334
"dependencies": {

src/area.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ type Events = {
1717
reordered: (element: HTMLElement) => Promise<unknown>
1818
}
1919
type Guards = {
20-
translate: (params: TranslateEventParams) => Promise<unknown | boolean>
21-
zoom: (params: ZoomEventParams) => Promise<unknown | boolean>
20+
translate: (params: TranslateEventParams) => Promise<unknown>
21+
zoom: (params: ZoomEventParams) => Promise<unknown>
2222
}
2323

2424
export class Area {
@@ -111,12 +111,12 @@ export class Area {
111111
}
112112

113113
private onTranslate = (x: number, y: number) => {
114-
if (this.zoomHandler && this.zoomHandler.isTranslating()) return // lock translation while zoom on multitouch
115-
this.translate(x, y)
114+
if (this.zoomHandler?.isTranslating()) return // lock translation while zoom on multitouch
115+
void this.translate(x, y)
116116
}
117117

118118
private onZoom = (delta: number, ox: number, oy: number, source?: ZoomSource) => {
119-
this.zoom(this.transform.k * (1 + delta), ox, oy, source)
119+
void this.zoom(this.transform.k * (1 + delta), ox, oy, source)
120120

121121
this.update()
122122
}
@@ -162,7 +162,7 @@ export class Area {
162162

163163
if (!result) return true
164164

165-
const d = (k - result.data.zoom) / ((k - zoom) || 1)
165+
const d = (k - result.data.zoom) / (k - zoom || 1)
166166

167167
this.transform.k = result.data.zoom || 1
168168
this.transform.x += ox * d

src/base.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable @typescript-eslint/no-invalid-void-type */
12
import { BaseSchemes, ConnectionId, NodeId, Root, Scope } from 'rete'
23

34
import { NodeResizeEventParams, NodeTranslateEventParams } from './node-view'

src/drag.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { PointerListener, usePointerListener } from './utils'
33

44
type Events = {
55
start: (e: PointerEvent) => void
6-
translate: (x: number, y: number, e: PointerEvent) => void
6+
translate: (x: number, y: number, e: PointerEvent) => unknown
77
drag: (e: PointerEvent) => void
88
}
99

@@ -69,7 +69,7 @@ export class Drag {
6969
const x = this.startPosition.x + delta.x / zoom
7070
const y = this.startPosition.y + delta.y / zoom
7171

72-
this.events.translate(x, y, e)
72+
void this.events.translate(x, y, e)
7373
}
7474

7575
private up = (e: PointerEvent) => {

src/extensions/bounding-box.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ import { getNodesRect } from './shared/utils'
1313
*/
1414
export function getBoundingBox<Schemes extends BaseSchemes, K>(plugin: BaseAreaPlugin<Schemes, K>, nodes: NodeRef<Schemes>[]) {
1515
const editor = plugin.parentScope<NodeEditor<Schemes>>(NodeEditor)
16-
const list = nodes.map(node => typeof node === 'object' ? node : editor.getNode(node))
16+
const list = nodes.map(node => typeof node === 'object'
17+
? node
18+
: editor.getNode(node))
1719
const rects = getNodesRect(list, plugin.nodeViews)
1820

1921
return getBBox(rects)

src/extensions/restrictor.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,21 @@ export type Params = {
2626
*/
2727
export function restrictor<Schemes extends BaseSchemes, K>(plugin: AreaPlugin<Schemes, K>, params?: Params) {
2828
const scaling = params?.scaling
29-
? params.scaling === true ? { min: 0.1, max: 1 } : params.scaling
29+
? params.scaling === true
30+
? { min: 0.1, max: 1 }
31+
: params.scaling
3032
: false
3133
const translation = params?.translation
32-
? params.translation === true ? { left: 0, top: 0, right: 1000, bottom: 1000 } : params.translation
34+
? params.translation === true
35+
? { left: 0, top: 0, right: 1000, bottom: 1000 }
36+
: params.translation
3337
: false
3438

3539
function restrictZoom(zoom: number) {
3640
if (!scaling) throw new Error('scaling param isnt defined')
37-
const { min, max } = typeof scaling === 'function' ? scaling() : scaling
41+
const { min, max } = typeof scaling === 'function'
42+
? scaling()
43+
: scaling
3844

3945
if (zoom < min) {
4046
return min
@@ -82,7 +88,7 @@ export function restrictor<Schemes extends BaseSchemes, K>(plugin: AreaPlugin<Sc
8288
if (translation && context.type === 'zoomed') {
8389
const position = restrictPosition(plugin.area.transform)
8490

85-
plugin.area.translate(position.x, position.y)
91+
void plugin.area.translate(position.x, position.y)
8692
}
8793
if (translation && context.type === 'translate') {
8894
return {

0 commit comments

Comments
 (0)