fix code quality issues

This commit is contained in:
まっちゃとーにゅ 2024-01-31 06:18:54 +09:00
parent 9ffa56aa1b
commit b6f6c3ea18
No known key found for this signature in database
GPG key ID: 143DE582A97FE052
27 changed files with 63 additions and 64 deletions

View file

@ -62,12 +62,12 @@ export default function (props: MfmProps, { emit }: { emit: SetupContext<MfmEven
const validTime = (t: string | boolean | null | undefined) => {
if (t == null) return null;
if (typeof t === 'boolean') return null;
return t.match(/^[0-9.]+s$/) ? t : null;
return RegExp(/^[0-9.]+s$/).exec(t) ? t : null;
};
const validColor = (c: unknown): string | null => {
if (typeof c !== 'string') return null;
return c.match(/^[0-9a-f]{3,6}$/i) ? c : null;
return RegExp(/^[0-9a-f]{3,6}$/i).exec(c) ? c : null;
};
const useAnim = defaultStore.state.advancedMfm && defaultStore.state.animatedMfm;
@ -356,7 +356,7 @@ export default function (props: MfmProps, { emit }: { emit: SetupContext<MfmEven
case 'mention': {
return [h(MkMention, {
key: Math.random(),
host: (token.props.host == null && props.author && props.author.host != null ? props.author.host : token.props.host) ?? host,
host: (token.props.host == null && props.author?.host ? props.author.host : token.props.host) ?? host,
username: token.props.username,
})];
}

View file

@ -97,7 +97,7 @@ function onTabClick(t: Tab, ev: MouseEvent): void {
function renderTab() {
const tabEl = props.tab ? tabRefs[props.tab] : undefined;
if (tabEl && tabHighlightEl.value && tabHighlightEl.value.parentElement) {
if (tabEl && tabHighlightEl.value?.parentElement) {
// offsetWidth offsetLeft getBoundingClientRect 使
// https://developer.mozilla.org/ja/docs/Web/API/HTMLElement/offsetWidth#%E5%80%A4
const parentRect = tabHighlightEl.value.parentElement.getBoundingClientRect();