mirror of
https://github.com/mastodon/mastodon.git
synced 2024-12-28 22:15:06 +01:00
Enable stricter Typescript options (#30435)
This commit is contained in:
parent
564ebfefcf
commit
3750e8050c
@ -65,7 +65,7 @@ window.addEventListener('message', (e) => {
|
|||||||
{
|
{
|
||||||
type: 'setHeight',
|
type: 'setHeight',
|
||||||
id: data.id,
|
id: data.id,
|
||||||
height: document.getElementsByTagName('html')[0].scrollHeight,
|
height: document.getElementsByTagName('html')[0]?.scrollHeight,
|
||||||
},
|
},
|
||||||
'*',
|
'*',
|
||||||
);
|
);
|
||||||
@ -135,7 +135,7 @@ function loaded() {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
const todayFormat = new IntlMessageFormat(
|
const todayFormat = new IntlMessageFormat(
|
||||||
localeData['relative_format.today'] || 'Today at {time}',
|
localeData['relative_format.today'] ?? 'Today at {time}',
|
||||||
locale,
|
locale,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -288,13 +288,13 @@ function loaded() {
|
|||||||
if (statusEl.dataset.spoiler === 'expanded') {
|
if (statusEl.dataset.spoiler === 'expanded') {
|
||||||
statusEl.dataset.spoiler = 'folded';
|
statusEl.dataset.spoiler = 'folded';
|
||||||
this.textContent = new IntlMessageFormat(
|
this.textContent = new IntlMessageFormat(
|
||||||
localeData['status.show_more'] || 'Show more',
|
localeData['status.show_more'] ?? 'Show more',
|
||||||
locale,
|
locale,
|
||||||
).format() as string;
|
).format() as string;
|
||||||
} else {
|
} else {
|
||||||
statusEl.dataset.spoiler = 'expanded';
|
statusEl.dataset.spoiler = 'expanded';
|
||||||
this.textContent = new IntlMessageFormat(
|
this.textContent = new IntlMessageFormat(
|
||||||
localeData['status.show_less'] || 'Show less',
|
localeData['status.show_less'] ?? 'Show less',
|
||||||
locale,
|
locale,
|
||||||
).format() as string;
|
).format() as string;
|
||||||
}
|
}
|
||||||
@ -316,8 +316,8 @@ function loaded() {
|
|||||||
|
|
||||||
const message =
|
const message =
|
||||||
statusEl.dataset.spoiler === 'expanded'
|
statusEl.dataset.spoiler === 'expanded'
|
||||||
? localeData['status.show_less'] || 'Show less'
|
? localeData['status.show_less'] ?? 'Show less'
|
||||||
: localeData['status.show_more'] || 'Show more';
|
: localeData['status.show_more'] ?? 'Show more';
|
||||||
spoilerLink.textContent = new IntlMessageFormat(
|
spoilerLink.textContent = new IntlMessageFormat(
|
||||||
message,
|
message,
|
||||||
locale,
|
locale,
|
||||||
|
@ -67,7 +67,9 @@ const fetchInteractionURLFailure = () => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const isValidDomain = (value: string) => {
|
const isValidDomain = (value: unknown) => {
|
||||||
|
if (typeof value !== 'string') return false;
|
||||||
|
|
||||||
const url = new URL('https:///path');
|
const url = new URL('https:///path');
|
||||||
url.hostname = value;
|
url.hostname = value;
|
||||||
return url.hostname === value;
|
return url.hostname === value;
|
||||||
@ -124,6 +126,11 @@ const fromAcct = (acct: string) => {
|
|||||||
const domain = segments[1];
|
const domain = segments[1];
|
||||||
const fallbackTemplate = `https://${domain}/authorize_interaction?uri={uri}`;
|
const fallbackTemplate = `https://${domain}/authorize_interaction?uri={uri}`;
|
||||||
|
|
||||||
|
if (!domain) {
|
||||||
|
fetchInteractionURLFailure();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
axios
|
axios
|
||||||
.get(`https://${domain}/.well-known/webfinger`, {
|
.get(`https://${domain}/.well-known/webfinger`, {
|
||||||
params: { resource: `acct:${acct}` },
|
params: { resource: `acct:${acct}` },
|
||||||
|
@ -48,8 +48,9 @@ export const AnimatedNumber: React.FC<Props> = ({ value }) => {
|
|||||||
<span
|
<span
|
||||||
key={key}
|
key={key}
|
||||||
style={{
|
style={{
|
||||||
position: direction * style.y > 0 ? 'absolute' : 'static',
|
position:
|
||||||
transform: `translateY(${style.y * 100}%)`,
|
direction * (style.y ?? 0) > 0 ? 'absolute' : 'static',
|
||||||
|
transform: `translateY(${(style.y ?? 0) * 100}%)`,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<ShortNumber value={data as number} />
|
<ShortNumber value={data as number} />
|
||||||
|
@ -52,7 +52,10 @@ function uniqueHashtagsWithCaseHandling(hashtags: string[]) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
return Object.values(groups).map((tags) => {
|
return Object.values(groups).map((tags) => {
|
||||||
if (tags.length === 1) return tags[0];
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- we know that the array has at least one element
|
||||||
|
const firstTag = tags[0]!;
|
||||||
|
|
||||||
|
if (tags.length === 1) return firstTag;
|
||||||
|
|
||||||
// The best match is the one where we have the less difference between upper and lower case letter count
|
// The best match is the one where we have the less difference between upper and lower case letter count
|
||||||
const best = minBy(tags, (tag) => {
|
const best = minBy(tags, (tag) => {
|
||||||
@ -66,7 +69,7 @@ function uniqueHashtagsWithCaseHandling(hashtags: string[]) {
|
|||||||
return Math.abs(lowerCase - upperCase);
|
return Math.abs(lowerCase - upperCase);
|
||||||
});
|
});
|
||||||
|
|
||||||
return best ?? tags[0];
|
return best ?? firstTag;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ const ShortNumberCounter: React.FC<ShortNumberCounterProps> = ({ value }) => {
|
|||||||
|
|
||||||
const count = (
|
const count = (
|
||||||
<FormattedNumber
|
<FormattedNumber
|
||||||
value={rawNumber}
|
value={rawNumber ?? 0}
|
||||||
maximumFractionDigits={maxFractionDigits}
|
maximumFractionDigits={maxFractionDigits}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
@ -29,7 +29,10 @@ const emojis: Emojis = {};
|
|||||||
|
|
||||||
// decompress
|
// decompress
|
||||||
Object.keys(shortCodesToEmojiData).forEach((shortCode) => {
|
Object.keys(shortCodesToEmojiData).forEach((shortCode) => {
|
||||||
const [_filenameData, searchData] = shortCodesToEmojiData[shortCode];
|
const emojiData = shortCodesToEmojiData[shortCode];
|
||||||
|
if (!emojiData) return;
|
||||||
|
|
||||||
|
const [_filenameData, searchData] = emojiData;
|
||||||
const [native, short_names, search, unified] = searchData;
|
const [native, short_names, search, unified] = searchData;
|
||||||
|
|
||||||
emojis[shortCode] = {
|
emojis[shortCode] = {
|
||||||
|
@ -46,7 +46,10 @@ function processEmojiMapData(
|
|||||||
Object.keys(shortCodesToEmojiData).forEach(
|
Object.keys(shortCodesToEmojiData).forEach(
|
||||||
(shortCode: ShortCodesToEmojiDataKey) => {
|
(shortCode: ShortCodesToEmojiDataKey) => {
|
||||||
if (shortCode === undefined) return;
|
if (shortCode === undefined) return;
|
||||||
const [filenameData, _searchData] = shortCodesToEmojiData[shortCode];
|
|
||||||
|
const emojiData = shortCodesToEmojiData[shortCode];
|
||||||
|
if (!emojiData) return;
|
||||||
|
const [filenameData, _searchData] = emojiData;
|
||||||
filenameData.forEach((emojiMapData) => {
|
filenameData.forEach((emojiMapData) => {
|
||||||
processEmojiMapData(emojiMapData, shortCode);
|
processEmojiMapData(emojiMapData, shortCode);
|
||||||
});
|
});
|
||||||
|
@ -74,8 +74,9 @@ export const soundsMiddleware = (): Middleware<
|
|||||||
if (isActionWithMetaSound(action)) {
|
if (isActionWithMetaSound(action)) {
|
||||||
const sound = action.meta.sound;
|
const sound = action.meta.sound;
|
||||||
|
|
||||||
if (sound && Object.hasOwn(soundCache, sound)) {
|
if (sound) {
|
||||||
play(soundCache[sound]);
|
const s = soundCache[sound];
|
||||||
|
if (s) play(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
"allowJs": true,
|
"allowJs": true,
|
||||||
"noEmit": true,
|
"noEmit": true,
|
||||||
"strict": true,
|
"strict": true,
|
||||||
|
"noImplicitReturns": true,
|
||||||
|
"noUncheckedIndexedAccess": true,
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
"baseUrl": "./",
|
"baseUrl": "./",
|
||||||
|
Loading…
Reference in New Issue
Block a user