0
0
Fork 0

Upgrade ESlint to v8 (#23305)

This commit is contained in:
Nick Schonning 2023-01-29 19:45:35 -05:00 committed by GitHub
parent b58bf74e35
commit c49213f0ea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
120 changed files with 832 additions and 810 deletions

View file

@ -31,7 +31,7 @@ export default class ActionsModal extends ImmutablePureComponent {
</a>
</li>
);
}
};
render () {
return (

View file

@ -55,20 +55,20 @@ class BlockModal extends React.PureComponent {
handleClick = () => {
this.props.onClose();
this.props.onConfirm(this.props.account);
}
};
handleSecondary = () => {
this.props.onClose();
this.props.onBlockAndReport(this.props.account);
}
};
handleCancel = () => {
this.props.onClose();
}
};
setRef = (c) => {
this.button = c;
}
};
render () {
const { account } = this.props;

View file

@ -62,7 +62,7 @@ class BoostModal extends ImmutablePureComponent {
handleReblog = () => {
this.props.onReblog(this.props.status, this.props.privacy);
this.props.onClose();
}
};
handleAccountClick = (e) => {
if (e.button === 0 && !(e.ctrlKey || e.metaKey)) {
@ -70,7 +70,7 @@ class BoostModal extends ImmutablePureComponent {
this.props.onClose();
this.context.router.history.push(`/@${this.props.status.getIn(['account', 'acct'])}`);
}
}
};
_findContainer = () => {
return document.getElementsByClassName('modal-root__container')[0];
@ -78,7 +78,7 @@ class BoostModal extends ImmutablePureComponent {
setRef = (c) => {
this.button = c;
}
};
render () {
const { status, privacy, intl } = this.props;

View file

@ -15,7 +15,7 @@ class Bundle extends React.PureComponent {
onFetch: PropTypes.func,
onFetchSuccess: PropTypes.func,
onFetchFail: PropTypes.func,
}
};
static defaultProps = {
loading: emptyComponent,
@ -24,14 +24,14 @@ class Bundle extends React.PureComponent {
onFetch: noop,
onFetchSuccess: noop,
onFetchFail: noop,
}
};
static cache = new Map
static cache = new Map;
state = {
mod: undefined,
forceRender: false,
}
};
componentWillMount() {
this.load(this.props);
@ -83,7 +83,7 @@ class Bundle extends React.PureComponent {
this.setState({ mod: null });
onFetchFail(error);
});
}
};
render() {
const { loading: Loading, error: Error, children, renderDelay } = this.props;

View file

@ -31,7 +31,7 @@ class GIF extends React.PureComponent {
if (!animate) {
this.setState({ hovering: true });
}
}
};
handleMouseLeave = () => {
const { animate } = this.props;
@ -39,7 +39,7 @@ class GIF extends React.PureComponent {
if (!animate) {
this.setState({ hovering: false });
}
}
};
render () {
const { src, staticSrc, className, animate } = this.props;
@ -75,7 +75,7 @@ class CopyButton extends React.PureComponent {
navigator.clipboard.writeText(value);
this.setState({ copied: true });
this.timeout = setTimeout(() => this.setState({ copied: false }), 700);
}
};
componentWillUnmount () {
if (this.timeout) clearTimeout(this.timeout);
@ -113,7 +113,7 @@ class BundleColumnError extends React.PureComponent {
if (onRetry) {
onRetry();
}
}
};
render () {
const { errorType, multiColumn, stacktrace } = this.props;

View file

@ -16,11 +16,11 @@ class BundleModalError extends React.PureComponent {
onRetry: PropTypes.func.isRequired,
onClose: PropTypes.func.isRequired,
intl: PropTypes.object.isRequired,
}
};
handleRetry = () => {
this.props.onRetry();
}
};
render () {
const { onClose, intl: { formatMessage } } = this.props;

View file

@ -23,7 +23,7 @@ export default class Column extends React.PureComponent {
}
this._interruptScrollAnimation = scrollTop(scrollable);
}
};
scrollTop () {
const scrollable = this.node.querySelector('.scrollable');
@ -40,11 +40,11 @@ export default class Column extends React.PureComponent {
if (typeof this._interruptScrollAnimation !== 'undefined') {
this._interruptScrollAnimation();
}
}, 200)
}, 200);
setRef = (c) => {
this.node = c;
}
};
render () {
const { heading, icon, children, active, hideHeadingOnMobile } = this.props;

View file

@ -15,7 +15,7 @@ export default class ColumnHeader extends React.PureComponent {
handleClick = () => {
this.props.onClick();
}
};
render () {
const { icon, type, active, columnHeaderId } = this.props;

View file

@ -57,7 +57,7 @@ export default class ColumnsArea extends ImmutablePureComponent {
state = {
renderComposePanel: !(this.mediaQuery && this.mediaQuery.matches),
}
};
componentDidMount() {
if (!this.props.singleColumn) {
@ -111,7 +111,7 @@ export default class ColumnsArea extends ImmutablePureComponent {
handleLayoutChange = (e) => {
this.setState({ renderComposePanel: !e.matches });
}
};
handleWheel = () => {
if (typeof this._interruptScrollAnimation !== 'function') {
@ -119,19 +119,19 @@ export default class ColumnsArea extends ImmutablePureComponent {
}
this._interruptScrollAnimation();
}
};
setRef = (node) => {
this.node = node;
}
};
renderLoading = columnId => () => {
return columnId === 'COMPOSE' ? <DrawerLoading /> : <ColumnLoading multiColumn />;
}
};
renderError = (props) => {
return <BundleColumnError multiColumn errorType='network' {...props} />;
}
};
render () {
const { columns, children, singleColumn, isModalOpen } = this.props;

View file

@ -22,12 +22,12 @@ class ComposePanel extends React.PureComponent {
onFocus = () => {
const { dispatch } = this.props;
dispatch(changeComposing(true));
}
};
onBlur = () => {
const { dispatch } = this.props;
dispatch(changeComposing(false));
}
};
componentDidMount () {
const { dispatch } = this.props;

View file

@ -30,20 +30,20 @@ class ConfirmationModal extends React.PureComponent {
this.props.onClose();
}
this.props.onConfirm();
}
};
handleSecondary = () => {
this.props.onClose();
this.props.onSecondary();
}
};
handleCancel = () => {
this.props.onClose();
}
};
setRef = (c) => {
this.button = c;
}
};
render () {
const { message, confirm, secondary } = this.props;

View file

@ -46,7 +46,7 @@ class DisabledAccountBanner extends React.PureComponent {
this.props.onLogout();
return false;
}
};
render () {
const { disabledAcct, movedToAcct } = this.props;

View file

@ -17,7 +17,7 @@ class EmbedModal extends ImmutablePureComponent {
onClose: PropTypes.func.isRequired,
onError: PropTypes.func.isRequired,
intl: PropTypes.object.isRequired,
}
};
state = {
loading: false,
@ -48,11 +48,11 @@ class EmbedModal extends ImmutablePureComponent {
setIframeRef = c => {
this.iframe = c;
}
};
handleTextareaClick = (e) => {
e.target.select();
}
};
render () {
const { intl, onClose } = this.props;

View file

@ -135,7 +135,7 @@ class FocalPointModal extends ImmutablePureComponent {
this.updatePosition(e);
this.setState({ dragging: true });
}
};
handleTouchStart = e => {
document.addEventListener('touchmove', this.handleMouseMove);
@ -143,25 +143,25 @@ class FocalPointModal extends ImmutablePureComponent {
this.updatePosition(e);
this.setState({ dragging: true });
}
};
handleMouseMove = e => {
this.updatePosition(e);
}
};
handleMouseUp = () => {
document.removeEventListener('mousemove', this.handleMouseMove);
document.removeEventListener('mouseup', this.handleMouseUp);
this.setState({ dragging: false });
}
};
handleTouchEnd = () => {
document.removeEventListener('touchmove', this.handleMouseMove);
document.removeEventListener('touchend', this.handleTouchEnd);
this.setState({ dragging: false });
}
};
updatePosition = e => {
const { x, y } = getPointerPosition(this.node, e);
@ -169,24 +169,24 @@ class FocalPointModal extends ImmutablePureComponent {
const focusY = (y - .5) * -2;
this.props.onChangeFocus(focusX, focusY);
}
};
handleChange = e => {
this.props.onChangeDescription(e.target.value);
}
};
handleKeyDown = (e) => {
if (e.keyCode === 13 && (e.ctrlKey || e.metaKey)) {
this.props.onChangeDescription(e.target.value);
this.handleSubmit(e);
}
}
};
handleSubmit = (e) => {
e.preventDefault();
e.stopPropagation();
this.props.onSave(this.props.description, this.props.focusX, this.props.focusY);
}
};
getCloseConfirmationMessage = () => {
const { intl, dirty } = this.props;
@ -199,15 +199,15 @@ class FocalPointModal extends ImmutablePureComponent {
} else {
return null;
}
}
};
setRef = c => {
this.node = c;
}
};
handleTextDetection = () => {
this._detectText();
}
};
_detectText = (refreshCache = false) => {
const { media } = this.props;
@ -258,21 +258,21 @@ class FocalPointModal extends ImmutablePureComponent {
console.error(e);
this.setState({ detecting: false });
});
}
};
handleThumbnailChange = e => {
if (e.target.files.length > 0) {
this.props.onSelectThumbnail(e.target.files);
}
}
};
setFileInputRef = c => {
this.fileInput = c;
}
};
handleFileInputClick = () => {
this.fileInput.click();
}
};
render () {
const { media, intl, account, onClose, isUploadingThumbnail, description, lang, focusX, focusY, dirty, is_changing_upload } = this.props;

View file

@ -14,7 +14,7 @@ export default class ImageLoader extends PureComponent {
height: PropTypes.number,
onClick: PropTypes.func,
zoomButtonHidden: PropTypes.bool,
}
};
static defaultProps = {
alt: '',
@ -26,7 +26,7 @@ export default class ImageLoader extends PureComponent {
loading: true,
error: false,
width: null,
}
};
removers = [];
canvas = null;
@ -86,7 +86,7 @@ export default class ImageLoader extends PureComponent {
image.addEventListener('load', handleLoad);
image.src = previewSrc;
this.removers.push(removeEventListeners);
})
});
clearPreviewCanvas () {
const { width, height } = this.canvas;
@ -126,7 +126,7 @@ export default class ImageLoader extends PureComponent {
setCanvasRef = c => {
this.canvas = c;
if (c) this.setState({ width: c.offsetWidth });
}
};
render () {
const { alt, src, width, height, onClick } = this.props;

View file

@ -44,7 +44,7 @@ class LinkFooter extends React.PureComponent {
this.props.onLogout();
return false;
}
};
render () {
const { signedIn, permissions } = this.context.identity;

View file

@ -43,27 +43,27 @@ class MediaModal extends ImmutablePureComponent {
handleSwipe = (index) => {
this.setState({ index: index % this.props.media.size });
}
};
handleTransitionEnd = () => {
this.setState({
zoomButtonHidden: false,
});
}
};
handleNextClick = () => {
this.setState({
index: (this.getIndex() + 1) % this.props.media.size,
zoomButtonHidden: true,
});
}
};
handlePrevClick = () => {
this.setState({
index: (this.props.media.size + this.getIndex() - 1) % this.props.media.size,
zoomButtonHidden: true,
});
}
};
handleChangeIndex = (e) => {
const index = Number(e.currentTarget.getAttribute('data-index'));
@ -72,7 +72,7 @@ class MediaModal extends ImmutablePureComponent {
index: index % this.props.media.size,
zoomButtonHidden: true,
});
}
};
handleKeyDown = (e) => {
switch(e.key) {
@ -87,7 +87,7 @@ class MediaModal extends ImmutablePureComponent {
e.stopPropagation();
break;
}
}
};
componentDidMount () {
window.addEventListener('keydown', this.handleKeyDown, false);

View file

@ -79,17 +79,17 @@ export default class ModalRoot extends React.PureComponent {
setBackgroundColor = color => {
this.setState({ backgroundColor: color });
}
};
renderLoading = modalId => () => {
return ['MEDIA', 'VIDEO', 'BOOST', 'CONFIRM', 'ACTIONS'].indexOf(modalId) === -1 ? <ModalLoading /> : null;
}
};
renderError = (props) => {
const { onClose } = this.props;
return <BundleModalError {...props} onClose={onClose} />;
}
};
handleClose = (ignoreFocus = false) => {
const { onClose } = this.props;
@ -102,11 +102,11 @@ export default class ModalRoot extends React.PureComponent {
// This would be much smoother with react-intl 3+ and `forwardRef`.
}
onClose(message, ignoreFocus);
}
};
setModalRef = (c) => {
this._modal = c;
}
};
render () {
const { type, props, ignoreFocus } = this.props;

View file

@ -65,23 +65,23 @@ class MuteModal extends React.PureComponent {
handleClick = () => {
this.props.onClose();
this.props.onConfirm(this.props.account, this.props.notifications, this.props.muteDuration);
}
};
handleCancel = () => {
this.props.onClose();
}
};
setRef = (c) => {
this.button = c;
}
};
toggleNotifications = () => {
this.props.onToggleNotifications();
}
};
changeMuteDuration = (e) => {
this.props.onChangeMuteDuration(e);
}
};
render () {
const { account, notifications, muteDuration, intl } = this.props;

View file

@ -95,7 +95,7 @@ class ReportModal extends ImmutablePureComponent {
} else {
this.setState({ selectedRuleIds: selectedRuleIds.remove(ruleId) });
}
}
};
handleChangeCategory = category => {
this.setState({ category });

View file

@ -22,7 +22,7 @@ export default class UploadArea extends React.PureComponent {
break;
}
}
}
};
componentDidMount () {
window.addEventListener('keyup', this.handleKeyUp, false);

View file

@ -102,7 +102,7 @@ class ZoomableImage extends React.PureComponent {
onClick: PropTypes.func,
zoomButtonHidden: PropTypes.bool,
intl: PropTypes.object.isRequired,
}
};
static defaultProps = {
alt: '',
@ -132,7 +132,7 @@ class ZoomableImage extends React.PureComponent {
dragged: false,
lockScroll: { x: 0, y: 0 },
lockTranslate: { x: 0, y: 0 },
}
};
removers = [];
container = null;
@ -212,7 +212,7 @@ class ZoomableImage extends React.PureComponent {
// lock horizontal scroll
this.container.scrollLeft = Math.max(this.container.scrollLeft + event.pixelX, this.state.lockScroll.x);
}
};
mouseDownHandler = e => {
this.container.style.cursor = 'grabbing';
@ -228,7 +228,7 @@ class ZoomableImage extends React.PureComponent {
this.image.addEventListener('mousemove', this.mouseMoveHandler);
this.image.addEventListener('mouseup', this.mouseUpHandler);
}
};
mouseMoveHandler = e => {
const dx = e.clientX - this.state.dragPosition.x;
@ -238,7 +238,7 @@ class ZoomableImage extends React.PureComponent {
this.container.scrollTop = Math.max(this.state.dragPosition.top - dy, this.state.lockScroll.y);
this.setState({ dragged: true });
}
};
mouseUpHandler = () => {
this.container.style.cursor = 'grab';
@ -246,13 +246,13 @@ class ZoomableImage extends React.PureComponent {
this.image.removeEventListener('mousemove', this.mouseMoveHandler);
this.image.removeEventListener('mouseup', this.mouseUpHandler);
}
};
handleTouchStart = e => {
if (e.touches.length !== 2) return;
this.lastDistance = getDistance(...e.touches);
}
};
handleTouchMove = e => {
const { scrollTop, scrollHeight, clientHeight } = this.container;
@ -275,7 +275,7 @@ class ZoomableImage extends React.PureComponent {
this.lastMidpoint = midpoint;
this.lastDistance = distance;
}
};
zoom(nextScale, midpoint) {
const { scale, zoomMatrix } = this.state;
@ -314,11 +314,11 @@ class ZoomableImage extends React.PureComponent {
const handler = this.props.onClick;
if (handler) handler();
this.setState({ navigationHidden: !this.state.navigationHidden });
}
};
handleMouseDown = e => {
e.preventDefault();
}
};
initZoomMatrix = () => {
const { width, height } = this.props;
@ -350,7 +350,7 @@ class ZoomableImage extends React.PureComponent {
translateY: translateY,
},
});
}
};
handleZoomClick = e => {
e.preventDefault();
@ -392,15 +392,15 @@ class ZoomableImage extends React.PureComponent {
this.container.style.cursor = 'grab';
this.container.style.removeProperty('user-select');
}
};
setContainerRef = c => {
this.container = c;
}
};
setImageRef = c => {
this.image = c;
}
};
render () {
const { alt, src, width, height, intl } = this.props;