vatro / svelthree

Create three.js content using Svelte components.
https://svelthree.dev
MIT License
482 stars 15 forks source link

Fix remaining ESLint Warnings and Errors #170

Closed vatro closed 2 years ago

vatro commented 2 years ago

Current status: #169

Whole project:

vatro commented 2 years ago

Current Status

svelte-check: no errors / warnings / hints lint: 5 errors ( - 0 ), 357 warnings ( - 51 )

vatro commented 2 years ago

8 out of 9 no-explicit-any warnings in components are related to lifecycle functions, since:

// Svelte lifecycle d.ts
export declare function beforeUpdate(fn: () => any): void;
export declare function onMount(fn: () => any): void;
export declare function afterUpdate(fn: () => any): void;
export declare function onDestroy(fn: () => any): void;

... I'll just eslint-ignore them.

vatro commented 2 years ago

Current Status

svelte-check: no errors / warnings / hints lint: 5 errors ( - 0 ), 105 warnings ( - 252 )

vatro commented 2 years ago

Next (e.g. ìn Mesh):

https://github.com/vatro/svelthree/blob/00e3fada8d93f9bf24363fca84e396d37833d177/src/lib/components/Mesh.svelte#L705 https://github.com/vatro/svelthree/blob/00e3fada8d93f9bf24363fca84e396d37833d177/src/lib/components/Mesh.svelte#L725 https://github.com/vatro/svelthree/blob/00e3fada8d93f9bf24363fca84e396d37833d177/src/lib/components/Mesh.svelte#L862

vatro commented 2 years ago

concerning on and onx methods, e.g. ìn Mesh: https://github.com/vatro/svelthree/blob/00e3fada8d93f9bf24363fca84e396d37833d177/src/lib/components/Mesh.svelte#L705 https://github.com/vatro/svelthree/blob/00e3fada8d93f9bf24363fca84e396d37833d177/src/lib/components/Mesh.svelte#L725

there are several $on type definitions in Svelte (runtime + dev):

// svelte/types/runtime/internal/Component.d.ts
export declare class SvelteComponent {
  ...
  $on(type: any, callback: any): () => void;
  ...
}
// svelte/types/runtime/internal/dev.d.ts
export interface SvelteComponentDev {
  ...
  $on(event: string, callback: (event: any) => void): () => void;
  ...
}
// svelte/types/runtime/internal/dev.d.ts
export interface SvelteComponentTyped {
  ...
  $on<K extends Extract<keyof Events, string>>(type: K, callback: (e: Events[K]) => void): () => void;
  ...
}

I believe the first one is the relevant one, so we could a) just ignore no-explicit-any here too b) use the second one + replace any with unknown or ignore no-explicit-any

I'll go with a) for now and reconsider it later.

vatro commented 2 years ago

Current Status

svelte-check: no errors / warnings / hints lint: 5 errors ( - 0 ), 89 warnings ( - 16 )

vatro commented 2 years ago

concerning no-explicit-any warning for get_animation (e.g. in Mesh): https://github.com/vatro/svelthree/blob/00e3fada8d93f9bf24363fca84e396d37833d177/src/lib/components/Mesh.svelte#L862

fix this along with:

.\src\lib\ani\SvelthreeAnimation.ts
   8:13  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any   
  36:25  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any   

.\src\lib\ani\SvelthreeAnimationManager.ts
    7:38  error  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any    
   13:50  error  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any    
  171:18  error  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any    

.\src\lib\ani\SvelthreeAnimationProp.ts
  11:35  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any   
  11:43  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any   
  12:20  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any  
vatro commented 2 years ago

Current Status

svelte-check: no errors / warnings / hints lint: 0 errors ( - 5 ), 69 warnings ( - 20 )

vatro commented 2 years ago

Current Status

svelte-check: no errors / warnings / hints lint: 0 errors, 54 warnings ( - 15 )

vatro commented 2 years ago

Current Status

svelte-check: no errors / warnings / hints lint: 0 errors, 52 warnings ( - 2 )

vatro commented 2 years ago

Current Status

svelte-check: no errors / warnings / hints lint: 0 errors, 49 warnings ( - 2 )

vatro commented 2 years ago
...\lib\utils\LightTarget.ts
48:51  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any

should be fixed by #135

vatro commented 2 years ago
...\lib\components\WebGLRenderer.svelte
   15:19  warning  '_self' is defined but never used         @typescript-eslint/no-unused-vars

will be fixed by #175

vatro commented 2 years ago
...\lib\components\Canvas.svelte
   17:19  warning  '_self' is defined but never used         @typescript-eslint/no-unused-vars   

will be fixed by #176

vatro commented 2 years ago

Current Status

svelte-check: no errors / warnings / hints lint: 0 errors, 44 warnings ( - 5 )

vatro commented 2 years ago

Current Status

svelte-check: no errors / warnings / hints lint: 0 errors, 40 warnings ( - 4 )

vatro commented 2 years ago

Current Status

svelte-check: no errors / warnings / hints lint: 0 errors, 3 warnings ( - 37 )

The remaining 3 warnings should be fixed by: #135, #175 and #176