Skip to content

Commit 2baf4e6

Browse files
committed
Fix no-unsafe-call & fix component typing
1 parent 2adcfac commit 2baf4e6

File tree

5 files changed

+46
-24
lines changed

5 files changed

+46
-24
lines changed

ember-basic-dropdown/eslint.config.mjs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,6 @@ export default ts.config(
8585
parserOptions: parserOptions.esm.ts,
8686
},
8787
extends: [...ts.configs.recommendedTypeChecked, ember.configs.gts],
88-
rules: {
89-
'@typescript-eslint/no-unsafe-call': 'off',
90-
},
9188
},
9289
{
9390
files: ['src/**/*'],

ember-basic-dropdown/src/components/basic-dropdown-content.ts

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,17 @@ export default class BasicDropdownContent extends Component<BasicDropdownContent
203203
}
204204

205205
window.addEventListener('resize', this.runloopAwareRepositionBound);
206-
window.addEventListener('orientationchange', this.runloopAwareRepositionBound);
206+
window.addEventListener(
207+
'orientationchange',
208+
this.runloopAwareRepositionBound,
209+
);
207210

208211
if (this.isTouchDevice) {
209-
document.addEventListener('touchstart', this.touchStartHandlerBound, true);
212+
document.addEventListener(
213+
'touchstart',
214+
this.touchStartHandlerBound,
215+
true,
216+
);
210217
document.addEventListener('touchend', this.handleRootMouseDown, true);
211218

212219
if (rootElement) {
@@ -376,7 +383,11 @@ export default class BasicDropdownContent extends Component<BasicDropdownContent
376383
this._contentWormhole.getRootNode() instanceof ShadowRoot
377384
) {
378385
const rootElement = this._contentWormhole.getRootNode() as HTMLElement;
379-
rootElement.addEventListener('touchmove', this.touchMoveHandlerBound, true);
386+
rootElement.addEventListener(
387+
'touchmove',
388+
this.touchMoveHandlerBound,
389+
true,
390+
);
380391
}
381392
}
382393

@@ -390,7 +401,11 @@ export default class BasicDropdownContent extends Component<BasicDropdownContent
390401
this._contentWormhole.getRootNode() instanceof ShadowRoot
391402
) {
392403
const rootElement = this._contentWormhole.getRootNode() as HTMLElement;
393-
rootElement.removeEventListener('touchmove', this.touchMoveHandlerBound, true);
404+
rootElement.removeEventListener(
405+
'touchmove',
406+
this.touchMoveHandlerBound,
407+
true,
408+
);
394409
}
395410
}
396411

@@ -577,8 +592,7 @@ function closestContent(el: Element): Element | null {
577592
return el;
578593
}
579594

580-
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
581-
function waitForAnimations(element: Element, callback: Function): void {
595+
function waitForAnimations(element: Element, callback: () => void): void {
582596
window.requestAnimationFrame(function () {
583597
const computedStyle = window.getComputedStyle(element);
584598
if (

ember-basic-dropdown/src/components/basic-dropdown-wormhole.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export default class BasicDropdownWormholeComponent extends Component<BasicDropd
99
get getDestinationId(): string {
1010
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
1111
// @ts-ignore
12+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
1213
const config = getOwner(this).resolveRegistration('config:environment') as {
1314
'ember-basic-dropdown'?: {
1415
destination?: string;

ember-basic-dropdown/src/components/basic-dropdown.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,18 +68,18 @@ export interface BasicDropdownArgs {
6868
rootEventType?: TRootEventType;
6969
preventScroll?: boolean;
7070
matchTriggerWidth?: boolean;
71-
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
72-
onInit?: Function;
73-
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
74-
registerAPI?: Function;
75-
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
76-
onOpen?: Function;
77-
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
78-
onClose?: Function;
79-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
80-
triggerComponent?: string | ComponentLike<any> | undefined;
81-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
82-
contentComponent?: string | ComponentLike<any> | undefined;
71+
onInit?: (dropdown: Dropdown) => void;
72+
registerAPI?: (dropdown: Dropdown | null) => void;
73+
onOpen?: (dropdown: Dropdown, e?: Event) => boolean | void;
74+
onClose?: (dropdown: Dropdown, e?: Event) => boolean | void;
75+
triggerComponent?:
76+
| string
77+
| ComponentLike<BasicDropdownTriggerSignature>
78+
| undefined;
79+
contentComponent?:
80+
| string
81+
| ComponentLike<BasicDropdownContentSignature>
82+
| undefined;
8383
calculatePosition?: CalculatePosition;
8484
}
8585

@@ -394,6 +394,7 @@ export default class BasicDropdown extends Component<BasicDropdownSignature> {
394394
_getDestinationId(): string {
395395
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
396396
// @ts-ignore
397+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
397398
const config = getOwner(this).resolveRegistration('config:environment') as {
398399
environment: string;
399400
APP: {

ember-basic-dropdown/src/modifiers/basic-dropdown-trigger.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,18 @@ function cleanup(instance: DropdownTriggerModifier) {
238238
}
239239

240240
triggerElement.removeEventListener('click', instance.handleMouseEventBound);
241-
triggerElement.removeEventListener('mousedown', instance.handleMouseEventBound);
241+
triggerElement.removeEventListener(
242+
'mousedown',
243+
instance.handleMouseEventBound,
244+
);
242245
triggerElement.removeEventListener('keydown', instance.handleKeyDownBound);
243-
triggerElement.removeEventListener('touchstart', instance.handleTouchStartBound);
244-
triggerElement.removeEventListener('touchend', instance.handleTouchEndBound);
246+
triggerElement.removeEventListener(
247+
'touchstart',
248+
instance.handleTouchStartBound,
249+
);
250+
triggerElement.removeEventListener(
251+
'touchend',
252+
instance.handleTouchEndBound,
253+
);
245254
}
246255
}

0 commit comments

Comments
 (0)