[build] upgrade eslint to 9.37.0 (#88)
Co-authored-by: tobi <tobi.smethurst@protonmail.com> Reviewed-on: https://codeberg.org/superseriousbusiness/masto-fe-standalone/pulls/88 Co-authored-by: Zoë Bijl <moiety@noreply.codeberg.org> Co-committed-by: Zoë Bijl <moiety@noreply.codeberg.org>
This commit is contained in:
@@ -1,31 +1,31 @@
|
||||
import punycode from 'punycode';
|
||||
import punycode from "punycode";
|
||||
|
||||
import PropTypes from 'prop-types';
|
||||
import { PureComponent } from 'react';
|
||||
import PropTypes from "prop-types";
|
||||
import { PureComponent } from "react";
|
||||
|
||||
import { FormattedMessage } from 'react-intl';
|
||||
import { FormattedMessage } from "react-intl";
|
||||
|
||||
import classNames from 'classnames';
|
||||
import classNames from "classnames";
|
||||
|
||||
import Immutable from 'immutable';
|
||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||
import Immutable from "immutable";
|
||||
import ImmutablePropTypes from "react-immutable-proptypes";
|
||||
|
||||
import { Blurhash } from 'mastodon/components/blurhash';
|
||||
import { Icon } from 'mastodon/components/icon';
|
||||
import { RelativeTimestamp } from 'mastodon/components/relative_timestamp';
|
||||
import { useBlurhash } from 'mastodon/initial_state';
|
||||
import { Blurhash } from "mastodon/components/blurhash";
|
||||
import { Icon } from "mastodon/components/icon";
|
||||
import { RelativeTimestamp } from "mastodon/components/relative_timestamp";
|
||||
import { useBlurhash } from "mastodon/initial_state";
|
||||
|
||||
const IDNA_PREFIX = 'xn--';
|
||||
const IDNA_PREFIX = "xn--";
|
||||
|
||||
const decodeIDNA = domain => {
|
||||
return domain
|
||||
.split('.')
|
||||
.split(".")
|
||||
.map(part => part.indexOf(IDNA_PREFIX) === 0 ? punycode.decode(part.slice(IDNA_PREFIX.length)) : part)
|
||||
.join('.');
|
||||
.join(".");
|
||||
};
|
||||
|
||||
const getHostname = url => {
|
||||
const parser = document.createElement('a');
|
||||
const parser = document.createElement("a");
|
||||
parser.href = url;
|
||||
return parser.hostname;
|
||||
};
|
||||
@@ -33,21 +33,21 @@ const getHostname = url => {
|
||||
const domParser = new DOMParser();
|
||||
|
||||
const addAutoPlay = html => {
|
||||
const document = domParser.parseFromString(html, 'text/html').documentElement;
|
||||
const iframe = document.querySelector('iframe');
|
||||
const document = domParser.parseFromString(html, "text/html").documentElement;
|
||||
const iframe = document.querySelector("iframe");
|
||||
|
||||
if (iframe) {
|
||||
if (iframe.src.indexOf('?') !== -1) {
|
||||
iframe.src += '&';
|
||||
if (iframe.src.indexOf("?") !== -1) {
|
||||
iframe.src += "&";
|
||||
} else {
|
||||
iframe.src += '?';
|
||||
iframe.src += "?";
|
||||
}
|
||||
|
||||
iframe.src += 'autoplay=1&auto_play=1';
|
||||
iframe.src += "autoplay=1&auto_play=1";
|
||||
|
||||
// DOM parser creates html/body elements around original HTML fragment,
|
||||
// so we need to get innerHTML out of the body and not the entire document
|
||||
return document.querySelector('body').innerHTML;
|
||||
return document.querySelector("body").innerHTML;
|
||||
}
|
||||
|
||||
return html;
|
||||
@@ -78,11 +78,11 @@ export default class Card extends PureComponent {
|
||||
}
|
||||
|
||||
componentDidMount () {
|
||||
window.addEventListener('resize', this.handleResize, { passive: true });
|
||||
window.addEventListener("resize", this.handleResize, { passive: true });
|
||||
}
|
||||
|
||||
componentWillUnmount () {
|
||||
window.removeEventListener('resize', this.handleResize);
|
||||
window.removeEventListener("resize", this.handleResize);
|
||||
}
|
||||
|
||||
handleEmbedClick = () => {
|
||||
@@ -105,14 +105,14 @@ export default class Card extends PureComponent {
|
||||
|
||||
renderVideo () {
|
||||
const { card } = this.props;
|
||||
const content = { __html: addAutoPlay(card.get('html')) };
|
||||
const content = { __html: addAutoPlay(card.get("html")) };
|
||||
|
||||
return (
|
||||
<div
|
||||
ref={this.setRef}
|
||||
className='status-card__image status-card-video'
|
||||
dangerouslySetInnerHTML={content}
|
||||
style={{ aspectRatio: '16 / 9' }}
|
||||
style={{ aspectRatio: "16 / 9" }}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -125,32 +125,32 @@ export default class Card extends PureComponent {
|
||||
return null;
|
||||
}
|
||||
|
||||
const provider = card.get('provider_name').length === 0 ? decodeIDNA(getHostname(card.get('url'))) : card.get('provider_name');
|
||||
const interactive = card.get('type') === 'video';
|
||||
const language = card.get('language') || '';
|
||||
const largeImage = (card.get('image')?.length > 0 && card.get('width') > card.get('height')) || interactive;
|
||||
const provider = card.get("provider_name").length === 0 ? decodeIDNA(getHostname(card.get("url"))) : card.get("provider_name");
|
||||
const interactive = card.get("type") === "video";
|
||||
const language = card.get("language") || "";
|
||||
const largeImage = (card.get("image")?.length > 0 && card.get("width") > card.get("height")) || interactive;
|
||||
|
||||
const description = (
|
||||
<div className='status-card__content'>
|
||||
<span className='status-card__host'>
|
||||
<span lang={language}>{provider}</span>
|
||||
{card.get('published_at') && <> · <RelativeTimestamp timestamp={card.get('published_at')} /></>}
|
||||
{card.get("published_at") && <> · <RelativeTimestamp timestamp={card.get("published_at")} /></>}
|
||||
</span>
|
||||
|
||||
<strong className='status-card__title' title={card.get('title')} lang={language}>{card.get('title')}</strong>
|
||||
<strong className='status-card__title' title={card.get("title")} lang={language}>{card.get("title")}</strong>
|
||||
|
||||
{card.get('author_name').length > 0 ? <span className='status-card__author'><FormattedMessage id='link_preview.author' defaultMessage='By {name}' values={{ name: <strong>{card.get('author_name')}</strong> }} /></span> : <span className='status-card__description'>{card.get('description')}</span>}
|
||||
{card.get("author_name").length > 0 ? <span className='status-card__author'><FormattedMessage id='link_preview.author' defaultMessage='By {name}' values={{ name: <strong>{card.get("author_name")}</strong> }} /></span> : <span className='status-card__description'>{card.get("description")}</span>}
|
||||
</div>
|
||||
);
|
||||
|
||||
const thumbnailStyle = {
|
||||
visibility: revealed ? null : 'hidden',
|
||||
visibility: revealed ? null : "hidden",
|
||||
};
|
||||
|
||||
if (largeImage && card.get('type') === 'video') {
|
||||
thumbnailStyle.aspectRatio = `16 / 9`;
|
||||
if (largeImage && card.get("type") === "video") {
|
||||
thumbnailStyle.aspectRatio = "16 / 9";
|
||||
} else if (largeImage) {
|
||||
thumbnailStyle.aspectRatio = '1.91 / 1';
|
||||
thumbnailStyle.aspectRatio = "1.91 / 1";
|
||||
} else {
|
||||
thumbnailStyle.aspectRatio = 1;
|
||||
}
|
||||
@@ -159,16 +159,16 @@ export default class Card extends PureComponent {
|
||||
|
||||
let canvas = (
|
||||
<Blurhash
|
||||
className={classNames('status-card__image-preview', {
|
||||
'status-card__image-preview--hidden': revealed && this.state.previewLoaded,
|
||||
className={classNames("status-card__image-preview", {
|
||||
"status-card__image-preview--hidden": revealed && this.state.previewLoaded,
|
||||
})}
|
||||
hash={card.get('blurhash')}
|
||||
hash={card.get("blurhash")}
|
||||
dummy={!useBlurhash}
|
||||
/>
|
||||
);
|
||||
|
||||
const thumbnailDescription = card.get('image_description');
|
||||
const thumbnail = <img src={card.get('image')} alt={thumbnailDescription} title={thumbnailDescription} lang={language} style={thumbnailStyle} onLoad={this.handleImageLoad} className='status-card__image-image' />;
|
||||
const thumbnailDescription = card.get("image_description");
|
||||
const thumbnail = <img src={card.get("image")} alt={thumbnailDescription} title={thumbnailDescription} lang={language} style={thumbnailStyle} onLoad={this.handleImageLoad} className='status-card__image-image' />;
|
||||
|
||||
let spoilerButton = (
|
||||
<button type='button' onClick={this.handleReveal} className='spoiler-button__overlay'>
|
||||
@@ -180,7 +180,7 @@ export default class Card extends PureComponent {
|
||||
);
|
||||
|
||||
spoilerButton = (
|
||||
<div className={classNames('spoiler-button', { 'spoiler-button--minified': revealed })}>
|
||||
<div className={classNames("spoiler-button", { "spoiler-button--minified": revealed })}>
|
||||
{spoilerButton}
|
||||
</div>
|
||||
);
|
||||
@@ -198,7 +198,7 @@ export default class Card extends PureComponent {
|
||||
<div className='status-card__actions' onClick={this.handleEmbedClick} role='none'>
|
||||
<div>
|
||||
<button type='button' onClick={this.handleEmbedClick}><Icon id='play' /></button>
|
||||
<a href={card.get('url')} target='_blank' rel='noopener noreferrer'><Icon id='external-link' /></a>
|
||||
<a href={card.get("url")} target='_blank' rel='noopener noreferrer'><Icon id='external-link' /></a>
|
||||
</div>
|
||||
</div>
|
||||
) : spoilerButton}
|
||||
@@ -207,12 +207,12 @@ export default class Card extends PureComponent {
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={classNames('status-card', { expanded: largeImage })} ref={this.setRef} onClick={revealed ? null : this.handleReveal} role={revealed ? 'button' : null}>
|
||||
<div className={classNames("status-card", { expanded: largeImage })} ref={this.setRef} onClick={revealed ? null : this.handleReveal} role={revealed ? "button" : null}>
|
||||
{embed}
|
||||
<a href={card.get('url')} target='_blank' rel='noopener noreferrer'>{description}</a>
|
||||
<a href={card.get("url")} target='_blank' rel='noopener noreferrer'>{description}</a>
|
||||
</div>
|
||||
);
|
||||
} else if (card.get('image')) {
|
||||
} else if (card.get("image")) {
|
||||
embed = (
|
||||
<div className='status-card__image'>
|
||||
{canvas}
|
||||
@@ -228,7 +228,7 @@ export default class Card extends PureComponent {
|
||||
}
|
||||
|
||||
return (
|
||||
<a href={card.get('url')} className={classNames('status-card', { expanded: largeImage })} target='_blank' rel='noopener noreferrer' ref={this.setRef}>
|
||||
<a href={card.get("url")} className={classNames("status-card", { expanded: largeImage })} target='_blank' rel='noopener noreferrer' ref={this.setRef}>
|
||||
{embed}
|
||||
{description}
|
||||
</a>
|
||||
|
||||
Reference in New Issue
Block a user