Add eslint rules for sonar issues
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import React, { AnchorHTMLAttributes, DetailedHTMLProps, MouseEvent } from 'react';
|
||||
import React, { AnchorHTMLAttributes, DetailedHTMLProps, MouseEvent, useCallback } from 'react';
|
||||
import classNames from 'classnames';
|
||||
import layoutManager from '../../components/layoutManager';
|
||||
import shell from '../../scripts/shell';
|
||||
@@ -23,7 +23,7 @@ const LinkButton: React.FC<LinkButtonProps> = ({
|
||||
children,
|
||||
...rest
|
||||
}) => {
|
||||
const onAnchorClick = (e: MouseEvent<HTMLAnchorElement>) => {
|
||||
const onAnchorClick = useCallback((e: MouseEvent<HTMLAnchorElement>) => {
|
||||
const url = href || '';
|
||||
if (url !== '#') {
|
||||
if (target) {
|
||||
@@ -38,7 +38,7 @@ const LinkButton: React.FC<LinkButtonProps> = ({
|
||||
} else {
|
||||
e.preventDefault();
|
||||
}
|
||||
};
|
||||
}, [ href, target ]);
|
||||
|
||||
if (isAutoHideEnabled === true && !appHost.supports('externallinks')) {
|
||||
return null;
|
||||
|
||||
@@ -29,7 +29,7 @@ const ScrollButtons: FC<ScrollButtonsProps> = ({ scrollerFactoryRef, scrollState
|
||||
}
|
||||
}, [scrollerFactoryRef]);
|
||||
|
||||
const onScrollButtonClick = (direction: Direction) => {
|
||||
const onScrollButtonClick = useCallback((direction: Direction) => {
|
||||
let newPos;
|
||||
if (direction === Direction.LEFT) {
|
||||
newPos = Math.max(0, scrollState.scrollPos - scrollState.scrollSize);
|
||||
@@ -44,7 +44,10 @@ const ScrollButtons: FC<ScrollButtonsProps> = ({ scrollerFactoryRef, scrollState
|
||||
}
|
||||
|
||||
scrollToPosition(newPos, false);
|
||||
};
|
||||
}, [ scrollState.scrollPos, scrollState.scrollSize, scrollToPosition ]);
|
||||
|
||||
const triggerScrollLeft = useCallback(() => onScrollButtonClick(Direction.LEFT), [ onScrollButtonClick ]);
|
||||
const triggerScrollRight = useCallback(() => onScrollButtonClick(Direction.RIGHT), [ onScrollButtonClick ]);
|
||||
|
||||
useEffect(() => {
|
||||
const parent = scrollButtonsRef.current?.parentNode as HTMLDivElement;
|
||||
@@ -63,7 +66,7 @@ const ScrollButtons: FC<ScrollButtonsProps> = ({ scrollerFactoryRef, scrollState
|
||||
<IconButton
|
||||
type='button'
|
||||
className='emby-scrollbuttons-button btnPrev'
|
||||
onClick={() => onScrollButtonClick(Direction.LEFT)}
|
||||
onClick={triggerScrollLeft}
|
||||
icon='chevron_left'
|
||||
disabled={localeScrollPos > 0 ? false : true}
|
||||
/>
|
||||
@@ -71,7 +74,7 @@ const ScrollButtons: FC<ScrollButtonsProps> = ({ scrollerFactoryRef, scrollState
|
||||
<IconButton
|
||||
type='button'
|
||||
className='emby-scrollbuttons-button btnNext'
|
||||
onClick={() => onScrollButtonClick(Direction.RIGHT)}
|
||||
onClick={triggerScrollRight}
|
||||
icon='chevron_right'
|
||||
disabled={scrollState.scrollWidth > 0 && localeScrollPos + scrollState.scrollSize >= scrollState.scrollWidth ? true : false}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user