Skip to content

Commit 063afb2

Browse files
committed
chore: lint happy
1 parent 44a927e commit 063afb2

File tree

6 files changed

+35
-31
lines changed

6 files changed

+35
-31
lines changed

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,7 @@ dev-server:
3333
build-server:
3434
@echo "Build server"
3535
./node_modules/.bin/esbuild $(FLAGS) --define:LIVE_RELOAD=false
36+
37+
lint:
38+
@echo "Lint"
39+
./node_modules/.bin/eslint --fix .

dev/main.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
2+
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
3+
/* eslint-disable @typescript-eslint/no-unsafe-return */
4+
/* eslint-disable @typescript-eslint/no-explicit-any */
15
import { c2m, createTreemap, presetDecorator, sortChildrenByKey } from '../src'
26

37
import './live-reload'
@@ -24,7 +28,7 @@ async function main() {
2428

2529
treemap.init(root)
2630

27-
main()
31+
main().catch(console.error)
2832

2933
treemap.on('click', function(metadata) {
3034
this.zoom(metadata.module)

eslint.config.js

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
11
const { nonzzz } = require('eslint-config-kagura')
22

33
module.exports = nonzzz(
4-
{ ts: true, jsx: true, react: true, unusedImports: true },
4+
{ typescript: true },
55
{
66
ignores: [
7-
'dist',
8-
'node_modules',
9-
'examples/vue/dist/**',
10-
'examples/vue/node_modules',
11-
'__tests__/dist',
12-
'**/*.d.ts'
13-
],
14-
rules: {
15-
'stylistic/indent': 'off',
16-
'stylistic/space-before-function-paren': 'off'
17-
}
7+
'**/node_modules',
8+
'**/dist',
9+
'**/display',
10+
'**/analysis'
11+
]
1812
}
1913
)

src/etoile/graph/box.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export abstract class C extends Display {
77
super()
88
this.elements = []
99
}
10-
abstract get __instanceOf__(): string
10+
abstract get __instanceOf__(): DisplayType
1111

1212
add(...elements: Display[]) {
1313
const cap = elements.length

src/etoile/schedule/render.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ export class Render {
3434
this.c = new Canvas(options)
3535
this.options = options
3636
this.initOptions(options)
37-
!options.shaow && to.appendChild(this.canvas)
37+
if (!options.shaow) {
38+
to.appendChild(this.canvas)
39+
}
3840
}
3941

4042
clear(width: number, height: number) {

src/primitives/event.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ function bindPrimitiveEvent(
173173
native: e,
174174
module: findRelativeNode({ x, y }, treemap.layoutNodes)
175175
}
176-
// @ts-expect-error
176+
// @ts-expect-error safe
177177
bus.emit(evt, event)
178178
}
179179
c.addEventListener(evt, handler)
@@ -234,8 +234,7 @@ export class SelfEvent extends RegisterModule {
234234
// If highlighting is triggered, it needs to be destroyed first
235235
this.self.highlight.reset()
236236
this.self.highlight.setDisplayLayerForHighlight()
237-
// @ts-expect-error
238-
this.self.event.off('mousemove', this.self.onmousemove)
237+
this.self.event.off('mousemove', this.self.onmousemove.bind(this))
239238
this.treemap.event.off(internalEventMappings.ON_ZOOM)
240239
this.self.forceDestroy = true
241240
const { native } = metadata
@@ -263,7 +262,7 @@ export class SelfEvent extends RegisterModule {
263262
this.self.draggingState = { x: 0, y: 0 }
264263
this.self.highlight.reset()
265264
this.self.highlight.setDisplayLayerForHighlight()
266-
this.self.event.bindWithContext(this)('mousemove', this.self.onmousemove)
265+
this.self.event.bindWithContext(this)('mousemove', this.self.onmousemove.bind(this))
267266
}
268267

269268
onmousemove(this: SelfEventContenxt, metadata: PrimitiveEventMetadata<'mousemove'>) {
@@ -285,8 +284,9 @@ export class SelfEvent extends RegisterModule {
285284

286285
onwheel(this: SelfEventContenxt, metadata: PrimitiveEventMetadata<'wheel'>) {
287286
const { self, treemap } = this
288-
// @ts-expect-error
289-
const wheelDelta = metadata.native.wheelDelta
287+
288+
// @ts-expect-error safe
289+
const wheelDelta = metadata.native.wheelDelta as number
290290
const absWheelDelta = Math.abs(wheelDelta)
291291
const offsetX = metadata.native.offsetX
292292
const offsetY = metadata.native.offsetY
@@ -332,17 +332,18 @@ export class SelfEvent extends RegisterModule {
332332
}
333333
]
334334
mixin(app, methods)
335+
const selfCtx = { treemap, self: this }
335336
const selfEvents = [...primitiveEvents, 'wheel'] as const
336337
selfEvents.forEach((evt) => {
337-
nativeEvents.push(bindPrimitiveEvent(treemap.render.canvas, { treemap, self: this }, evt, event))
338+
nativeEvents.push(bindPrimitiveEvent(treemap.render.canvas, selfCtx, evt, event))
338339
})
339-
const selfEvt = event.bindWithContext<SelfEventContenxt>({ treemap, self: this })
340-
selfEvt('mousedown', this.ondragstart)
341-
selfEvt('mousemove', this.ondragmove)
342-
selfEvt('mouseup', this.ondragend)
340+
const selfEvt = event.bindWithContext<SelfEventContenxt>(selfCtx)
341+
selfEvt('mousedown', this.ondragstart.bind(selfCtx))
342+
selfEvt('mousemove', this.ondragmove.bind(selfCtx))
343+
selfEvt('mouseup', this.ondragend.bind(selfCtx))
343344

344345
// wheel
345-
selfEvt('wheel', this.onwheel)
346+
selfEvt('wheel', this.onwheel.bind(selfCtx))
346347

347348
applyZoomEvent({ treemap, self: this })
348349

@@ -352,11 +353,9 @@ export class SelfEvent extends RegisterModule {
352353
this.highlight.init(width, height, root)
353354

354355
if (!installHightlightEvent) {
355-
bindPrimitiveEvent(this.highlight.highlight.render.canvas, { treemap, self: this }, 'mousemove', event)
356-
bindPrimitiveEvent(this.highlight.highlight.render.canvas, { treemap, self: this }, 'mouseout', event)
357356
// highlight
358-
selfEvt('mousemove', this.onmousemove)
359-
selfEvt('mouseout', this.onmouseout)
357+
selfEvt('mousemove', this.onmousemove.bind(selfCtx))
358+
selfEvt('mouseout', this.onmouseout.bind(selfCtx))
360359
installHightlightEvent = true
361360
this.highlight.setDisplayLayerForHighlight()
362361
}
@@ -394,6 +393,7 @@ function estimateZoomingArea(node: LayoutModule, root: LayoutModule | null, w: n
394393
let siblingWeightSum = 0
395394

396395
for (const sibling of siblings) {
396+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
397397
siblingWeightSum += sibling.weight
398398
}
399399

0 commit comments

Comments
 (0)