Skip to content

Commit 9678482

Browse files
refactor: review feedback
1 parent b937395 commit 9678482

2 files changed

Lines changed: 16 additions & 10 deletions

File tree

app/composables/useMarkdown.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,20 +88,20 @@ function parseMarkdown({ text, packageName, plain }: UseMarkdownOptions): string
8888
html = html.replace(/~~(.+?)~~/g, '<del>$1</del>')
8989

9090
// Links: [text](url) - only allow https, mailto
91-
html = html.replace(/\[([^\]]+)\]\(([^)]+)\)/g, (_match, matchedText, url) => {
91+
html = html.replace(/\[([^\]]+)\]\(([^)]+)\)/g, (_match, textGroup, url) => {
9292
// In plain mode, just render the link text without the anchor
9393
if (plain) {
94-
return matchedText
94+
return textGroup
9595
}
9696
const decodedUrl = url.replace(/&amp;/g, '&')
9797
try {
9898
const { protocol, href } = new URL(decodedUrl)
9999
if (['https:', 'mailto:'].includes(protocol)) {
100100
const safeUrl = href.replace(/"/g, '&quot;')
101-
return `<a href="${safeUrl}" rel="nofollow noreferrer noopener" target="_blank">${matchedText}</a>`
101+
return `<a href="${safeUrl}" rel="nofollow noreferrer noopener" target="_blank">${textGroup}</a>`
102102
}
103103
} catch {}
104-
return `${matchedText} (${url})`
104+
return `${textGroup} (${url})`
105105
})
106106

107107
return html

lunaria/components.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export const LocaleDetails = (
115115
file.localizations.find(localization => localization.lang === lang)?.status === 'missing',
116116
)
117117
const outdatedFiles = status.filter(file => {
118-
const localization = file.localizations.find(l => l.lang === lang)
118+
const localization = file.localizations.find(localizationItem => localizationItem.lang === lang)
119119

120120
if (!localization || localization.status === 'missing') return false
121121
if (file.type === 'dictionary')
@@ -149,7 +149,9 @@ export const LocaleDetails = (
149149
? html`<h3 class="capitalize">Missing</h3>
150150
<ul>
151151
${missingFiles.map(file => {
152-
const localization = file.localizations.find(l => l.lang === lang)!
152+
const localization = file.localizations.find(
153+
localizationItem => localizationItem.lang === lang,
154+
)!
153155
return html`
154156
<li>
155157
${Link(links.source(file.source.path), collapsePath(file.source.path))}
@@ -180,7 +182,9 @@ export const OutdatedFiles = (
180182
<h3 class="capitalize">Outdated</h3>
181183
<ul>
182184
${outdatedFiles.map(file => {
183-
const localization = file.localizations.find(l => l.lang === lang)!
185+
const localization = file.localizations.find(
186+
localizationItem => localizationItem.lang === lang,
187+
)!
184188
185189
const isMissingKeys =
186190
localization.status !== 'missing' &&
@@ -263,7 +267,7 @@ export const TableContentStatus = (
263267
lunaria: LunariaInstance,
264268
fileType?: string,
265269
): string => {
266-
const localization = localizations.find(l => l.lang === lang)!
270+
const localization = localizations.find(localizationItem => localizationItem.lang === lang)!
267271
const isMissingKeys = 'missingKeys' in localization && localization.missingKeys.length > 0
268272
// For dictionary files, status is determined solely by key completion:
269273
// if there are missing keys it's "outdated", if all keys are present it's "up-to-date",
@@ -290,7 +294,9 @@ export const ContentDetailsLinks = (
290294
lang: string,
291295
lunaria: LunariaInstance,
292296
): string => {
293-
const localization = fileStatus.localizations.find(l => l.lang === lang)!
297+
const localization = fileStatus.localizations.find(
298+
localizationItem => localizationItem.lang === lang,
299+
)!
294300
const isMissingKeys =
295301
localization.status !== 'missing' &&
296302
'missingKeys' in localization &&
@@ -423,7 +429,7 @@ function SvgLocaleSummary(
423429
file.localizations.find(localization => localization.lang === lang)?.status === 'missing',
424430
)
425431
const outdatedFiles = status.filter(file => {
426-
const localization = file.localizations.find(l => l.lang === lang)
432+
const localization = file.localizations.find(localizationItem => localizationItem.lang === lang)
427433
if (!localization || localization.status === 'missing') {
428434
return false
429435
} else if (file.type === 'dictionary') {

0 commit comments

Comments
 (0)