Skip to content

Commit

Permalink
chore: lint happy
Browse files Browse the repository at this point in the history
  • Loading branch information
nonzzz committed Dec 9, 2024
1 parent 44a927e commit 063afb2
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 31 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,7 @@ dev-server:
build-server:
@echo "Build server"
./node_modules/.bin/esbuild $(FLAGS) --define:LIVE_RELOAD=false

lint:
@echo "Lint"
./node_modules/.bin/eslint --fix .
6 changes: 5 additions & 1 deletion dev/main.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-return */
/* eslint-disable @typescript-eslint/no-explicit-any */
import { c2m, createTreemap, presetDecorator, sortChildrenByKey } from '../src'

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

treemap.init(root)

main()
main().catch(console.error)

treemap.on('click', function(metadata) {
this.zoom(metadata.module)
Expand Down
18 changes: 6 additions & 12 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
const { nonzzz } = require('eslint-config-kagura')

module.exports = nonzzz(
{ ts: true, jsx: true, react: true, unusedImports: true },
{ typescript: true },
{
ignores: [
'dist',
'node_modules',
'examples/vue/dist/**',
'examples/vue/node_modules',
'__tests__/dist',
'**/*.d.ts'
],
rules: {
'stylistic/indent': 'off',
'stylistic/space-before-function-paren': 'off'
}
'**/node_modules',
'**/dist',
'**/display',
'**/analysis'
]
}
)
2 changes: 1 addition & 1 deletion src/etoile/graph/box.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export abstract class C extends Display {
super()
this.elements = []
}
abstract get __instanceOf__(): string
abstract get __instanceOf__(): DisplayType

add(...elements: Display[]) {
const cap = elements.length
Expand Down
4 changes: 3 additions & 1 deletion src/etoile/schedule/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ export class Render {
this.c = new Canvas(options)
this.options = options
this.initOptions(options)
!options.shaow && to.appendChild(this.canvas)
if (!options.shaow) {
to.appendChild(this.canvas)
}
}

clear(width: number, height: number) {
Expand Down
32 changes: 16 additions & 16 deletions src/primitives/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ function bindPrimitiveEvent(
native: e,
module: findRelativeNode({ x, y }, treemap.layoutNodes)
}
// @ts-expect-error
// @ts-expect-error safe
bus.emit(evt, event)
}
c.addEventListener(evt, handler)
Expand Down Expand Up @@ -234,8 +234,7 @@ export class SelfEvent extends RegisterModule {
// If highlighting is triggered, it needs to be destroyed first
this.self.highlight.reset()
this.self.highlight.setDisplayLayerForHighlight()
// @ts-expect-error
this.self.event.off('mousemove', this.self.onmousemove)
this.self.event.off('mousemove', this.self.onmousemove.bind(this))
this.treemap.event.off(internalEventMappings.ON_ZOOM)
this.self.forceDestroy = true
const { native } = metadata
Expand Down Expand Up @@ -263,7 +262,7 @@ export class SelfEvent extends RegisterModule {
this.self.draggingState = { x: 0, y: 0 }
this.self.highlight.reset()
this.self.highlight.setDisplayLayerForHighlight()
this.self.event.bindWithContext(this)('mousemove', this.self.onmousemove)
this.self.event.bindWithContext(this)('mousemove', this.self.onmousemove.bind(this))
}

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

onwheel(this: SelfEventContenxt, metadata: PrimitiveEventMetadata<'wheel'>) {
const { self, treemap } = this
// @ts-expect-error
const wheelDelta = metadata.native.wheelDelta

// @ts-expect-error safe
const wheelDelta = metadata.native.wheelDelta as number
const absWheelDelta = Math.abs(wheelDelta)
const offsetX = metadata.native.offsetX
const offsetY = metadata.native.offsetY
Expand Down Expand Up @@ -332,17 +332,18 @@ export class SelfEvent extends RegisterModule {
}
]
mixin(app, methods)
const selfCtx = { treemap, self: this }
const selfEvents = [...primitiveEvents, 'wheel'] as const
selfEvents.forEach((evt) => {
nativeEvents.push(bindPrimitiveEvent(treemap.render.canvas, { treemap, self: this }, evt, event))
nativeEvents.push(bindPrimitiveEvent(treemap.render.canvas, selfCtx, evt, event))
})
const selfEvt = event.bindWithContext<SelfEventContenxt>({ treemap, self: this })
selfEvt('mousedown', this.ondragstart)
selfEvt('mousemove', this.ondragmove)
selfEvt('mouseup', this.ondragend)
const selfEvt = event.bindWithContext<SelfEventContenxt>(selfCtx)
selfEvt('mousedown', this.ondragstart.bind(selfCtx))
selfEvt('mousemove', this.ondragmove.bind(selfCtx))
selfEvt('mouseup', this.ondragend.bind(selfCtx))

// wheel
selfEvt('wheel', this.onwheel)
selfEvt('wheel', this.onwheel.bind(selfCtx))

applyZoomEvent({ treemap, self: this })

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

if (!installHightlightEvent) {
bindPrimitiveEvent(this.highlight.highlight.render.canvas, { treemap, self: this }, 'mousemove', event)
bindPrimitiveEvent(this.highlight.highlight.render.canvas, { treemap, self: this }, 'mouseout', event)
// highlight
selfEvt('mousemove', this.onmousemove)
selfEvt('mouseout', this.onmouseout)
selfEvt('mousemove', this.onmousemove.bind(selfCtx))
selfEvt('mouseout', this.onmouseout.bind(selfCtx))
installHightlightEvent = true
this.highlight.setDisplayLayerForHighlight()
}
Expand Down Expand Up @@ -394,6 +393,7 @@ function estimateZoomingArea(node: LayoutModule, root: LayoutModule | null, w: n
let siblingWeightSum = 0

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

Expand Down

0 comments on commit 063afb2

Please sign in to comment.