Skip to content

Commit 08096e0

Browse files
authored
Merge pull request #23 from Zettersten/cursor/run-linter-for-code-quality-68d6
Run linter for code quality
2 parents 22b11da + d0d94d9 commit 08096e0

File tree

9 files changed

+171
-11
lines changed

9 files changed

+171
-11
lines changed

eslint.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ export default tseslint.config(
2020
rules: {
2121
'@typescript-eslint/no-explicit-any': 'warn',
2222
'@typescript-eslint/explicit-module-boundary-types': 'off',
23+
'@typescript-eslint/no-unused-vars': ['error', {
24+
argsIgnorePattern: '^_',
25+
varsIgnorePattern: '^_',
26+
caughtErrorsIgnorePattern: '^_',
27+
}],
2328
},
2429
},
2530
{

package-lock.json

Lines changed: 13 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/adapters/angular.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* eslint-disable @typescript-eslint/triple-slash-reference */
2+
/// <reference path="./module-stubs.d.ts" />
13
import {
24
Component,
35
Input,
@@ -10,8 +12,6 @@ import {
1012
ElementRef,
1113
ViewChild,
1214
ChangeDetectionStrategy,
13-
inject,
14-
effect,
1515
signal,
1616
} from '@angular/core';
1717
import { Gracket } from '../core/Gracket';
@@ -50,7 +50,6 @@ export class GracketComponent implements OnInit, OnDestroy, OnChanges {
5050
// Using signals for reactive state - Angular 18+ best practice
5151
protected error = signal<Error | null>(null);
5252
private gracketInstance = signal<Gracket | null>(null);
53-
private elementRef = inject(ElementRef);
5453

5554
ngOnInit(): void {
5655
// Initialize will happen after view init when container is available

src/adapters/module-stubs.d.ts

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
/* eslint-disable @typescript-eslint/no-explicit-any */
2+
/* eslint-disable @typescript-eslint/no-unsafe-function-type */
3+
/* eslint-disable @typescript-eslint/no-empty-object-type */
4+
/* eslint-disable @typescript-eslint/no-unused-vars */
5+
// Type stubs for optional peer dependencies during build
6+
// These allow TypeScript to compile without having the actual packages installed
7+
// This file provides minimal type definitions to satisfy TypeScript when peer dependencies are not installed
8+
9+
// Svelte 5 runes support
10+
declare function $state<T>(initial: T): T;
11+
declare function $effect(fn: () => void | (() => void)): void;
12+
declare function $derived<T>(fn: () => T): T;
13+
14+
// Solid JSX namespace augmentation
15+
declare namespace JSX {
16+
interface IntrinsicElements {
17+
div: {
18+
ref?: any;
19+
class?: string;
20+
className?: string;
21+
style?: any;
22+
children?: any;
23+
[key: string]: any;
24+
};
25+
[elemName: string]: any;
26+
}
27+
}
28+
29+
declare module '@angular/core' {
30+
export interface Type<T> extends Function {
31+
new (...args: any[]): T;
32+
}
33+
export interface SimpleChange {
34+
firstChange: boolean;
35+
previousValue: any;
36+
currentValue: any;
37+
isFirstChange(): boolean;
38+
}
39+
export interface SimpleChanges {
40+
[propName: string]: SimpleChange;
41+
}
42+
export class EventEmitter<T> {
43+
emit(value?: T): void;
44+
subscribe(generatorOrNext?: any, error?: any, complete?: any): any;
45+
}
46+
export class ElementRef<T = any> {
47+
nativeElement: T;
48+
}
49+
export interface OnInit {
50+
ngOnInit(): void;
51+
}
52+
export interface OnDestroy {
53+
ngOnDestroy(): void;
54+
}
55+
export interface OnChanges {
56+
ngOnChanges(changes: SimpleChanges): void;
57+
}
58+
export const ChangeDetectionStrategy: {
59+
OnPush: number;
60+
Default: number;
61+
};
62+
export function Component(obj: any): any;
63+
export function Input(obj?: any): any;
64+
export function Output(obj?: any): any;
65+
export function ViewChild(selector: string | Type<any>, opts?: any): any;
66+
export function inject<T>(token: Type<T> | any): T;
67+
export function signal<T>(initialValue: T): any;
68+
}
69+
70+
declare module 'solid-js' {
71+
export interface Component<P = {}> {
72+
(props: P): any;
73+
}
74+
export namespace JSX {
75+
export interface CSSProperties {
76+
[key: string]: string | number | undefined;
77+
}
78+
export interface Element {}
79+
export interface IntrinsicElements {
80+
div: any;
81+
[elemName: string]: any;
82+
}
83+
}
84+
export function createSignal<T>(initialValue: T): [() => T, (v: T) => void];
85+
export function createEffect(fn: () => void): void;
86+
export function onMount(fn: () => void): void;
87+
export function onCleanup(fn: () => void): void;
88+
export function mergeProps<T extends object, U extends object>(defaults: Partial<T>, props: U): T & U;
89+
export function mergeProps<A extends object, B extends object, C extends object>(a: A, b: B, c: C): A & B & C;
90+
export function mergeProps(...args: any[]): any;
91+
}
92+
93+
declare module 'svelte' {
94+
export class SvelteComponent<Props = any, Events = any, Slots = any> {
95+
constructor(options: any);
96+
$on(event: string, handler: (e: any) => any): () => void;
97+
$set(props: Partial<Props>): void;
98+
$destroy(): void;
99+
}
100+
export function onMount(fn: () => any): void;
101+
export function onDestroy(fn: () => any): void;
102+
export function createEventDispatcher<T = any>(): (event: string, detail?: any) => void;
103+
}
104+
105+
declare module './svelte.svelte' {
106+
const component: any;
107+
export default component;
108+
}

src/adapters/solid.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* eslint-disable @typescript-eslint/triple-slash-reference */
2+
/// <reference path="./module-stubs.d.ts" />
13
import {
24
createSignal,
35
createEffect,
@@ -27,8 +29,8 @@ export interface GracketSolidProps extends Omit<GracketOptions, 'src'> {
2729
* SolidJS component wrapper for Gracket
2830
* Uses modern SolidJS best practices with fine-grained reactivity
2931
*/
30-
export const GracketSolid: Component<GracketSolidProps> = (props) => {
31-
const merged = mergeProps({ class: '', style: {} }, props);
32+
export const GracketSolid: Component<GracketSolidProps> = (props: GracketSolidProps) => {
33+
const merged = mergeProps({ class: '', style: {} as JSX.CSSProperties }, props) as Required<Pick<GracketSolidProps, 'class' | 'style'>> & GracketSolidProps;
3234

3335
let containerRef: HTMLDivElement | undefined;
3436
let gracketInstance: Gracket | null = null;
@@ -40,7 +42,7 @@ export const GracketSolid: Component<GracketSolidProps> = (props) => {
4042
if (!containerRef || !merged.data?.length) return;
4143

4244
try {
43-
const { data, onInit, onError, class: _, style: __, ...options } = merged;
45+
const { data, class: _class, style: _style, ...options } = merged;
4446

4547
gracketInstance = new Gracket(containerRef, {
4648
...options,

src/adapters/svelte.svelte.d.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Type declaration for Svelte component
2+
import type { SvelteComponent } from 'svelte';
3+
import type { Gracket } from '../core/Gracket';
4+
import type { GracketOptions, TournamentData } from '../types';
5+
6+
export interface GracketSvelteProps {
7+
data: TournamentData;
8+
options?: Omit<GracketOptions, 'src'>;
9+
className?: string;
10+
style?: string;
11+
}
12+
13+
export interface GracketSvelteEvents {
14+
init: CustomEvent<Gracket>;
15+
error: CustomEvent<Error>;
16+
update: CustomEvent<TournamentData>;
17+
}
18+
19+
export default class GracketSvelte extends SvelteComponent<
20+
GracketSvelteProps,
21+
GracketSvelteEvents
22+
> {
23+
updateScore(
24+
roundIndex: number,
25+
gameIndex: number,
26+
teamIndex: number,
27+
score: number
28+
): void;
29+
advanceRound(fromRound?: number): TournamentData | undefined;
30+
getInstance(): Gracket | null;
31+
destroy(): void;
32+
}

src/adapters/svelte.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* eslint-disable @typescript-eslint/triple-slash-reference */
2+
/// <reference path="./module-stubs.d.ts" />
13
import { Gracket } from '../core/Gracket';
24
import type { GracketOptions, TournamentData } from '../types';
35

src/adapters/webcomponent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export class GracketElement extends HTMLElement {
2020
private container: HTMLDivElement | null = null;
2121
private _data: TournamentData = [];
2222
private _options: Omit<GracketOptions, 'src'> = {};
23-
private shadowRoot: ShadowRoot;
23+
declare shadowRoot: ShadowRoot;
2424

2525
// Observed attributes for reactive updates
2626
static get observedAttributes() {

tsconfig.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
"declarationMap": true,
1515
"jsx": "react-jsx",
1616
"strict": true,
17-
"noUnusedLocals": true,
18-
"noUnusedParameters": true,
17+
"noUnusedLocals": false,
18+
"noUnusedParameters": false,
1919
"noFallthroughCasesInSwitch": true,
2020
"esModuleInterop": true,
2121
"allowSyntheticDefaultImports": true,
@@ -24,5 +24,5 @@
2424
"declarationDir": "./dist"
2525
},
2626
"include": ["src"],
27-
"exclude": ["node_modules", "dist", "**/*.test.ts", "**/*.test.tsx"]
27+
"exclude": ["node_modules", "dist", "**/*.test.ts", "**/*.test.tsx", "src/adapters/svelte.svelte"]
2828
}

0 commit comments

Comments
 (0)