From c9ef95eba5bf87e941e119eb7ae563091f3127e0 Mon Sep 17 00:00:00 2001 From: Leonabcd123 <156839416+Leonabcd123@users.noreply.github.com> Date: Sat, 28 Feb 2026 20:01:52 +0200 Subject: [PATCH 1/5] Only check short length of new quotes --- frontend/scripts/check-assets.ts | 43 +++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/frontend/scripts/check-assets.ts b/frontend/scripts/check-assets.ts index 87fff613ccfc..c5213017f449 100644 --- a/frontend/scripts/check-assets.ts +++ b/frontend/scripts/check-assets.ts @@ -149,6 +149,25 @@ async function validateLayouts(): Promise { } } +async function fetchQuotes(language: string): Promise { + const url = `https://raw.githubusercontent.com/monkeytypegame/monkeytype/refs/heads/master/frontend/static/quotes/${language}.json`; + + try { + const response = await fetch(url); + if (!response.ok) { + throw new Error(`Response status: ${response.status}`); + } + + const quoteJsonData = (await response.json()) as QuoteData; + return quoteJsonData; + } catch (error) { + console.error( + `Failed to get quotes: ${error instanceof Error ? error.message : String(error)}`, + ); + return null; + } +} + async function validateQuotes(): Promise { const problems = new Problems("Quotes", {}); @@ -197,6 +216,17 @@ async function validateQuotes(): Promise { ); } + // check if pr added quotes in this language + let idOfFirstAddedQuote = 0; + const currentLanguageQuotes = await fetchQuotes(quotefilename); + + if ( + currentLanguageQuotes !== null && + currentLanguageQuotes.quotes.length < quoteData.quotes.length + ) { + idOfFirstAddedQuote = currentLanguageQuotes.quotes.length + 1; + } + //check quote length quoteData.quotes.forEach((quote) => { if (quote.text.length !== quote.length) { @@ -206,12 +236,13 @@ async function validateQuotes(): Promise { ); } - if (quote.text.length < 60) { - // TODO: too many quotes trigger this - // problems.add( - // quotefilename, - // `ID ${quote.id}: length too short (under 60 characters)`, - // ); + if (idOfFirstAddedQuote > 0 && quote.id >= idOfFirstAddedQuote) { + if (quote.text.length < 60) { + problems.add( + quotefilename, + `ID ${quote.id}: length too short (under 60 characters)`, + ); + } } }); From 4e876dfb34db042e5ae6bd279bcf7f10a188a299 Mon Sep 17 00:00:00 2001 From: Leonabcd123 <156839416+Leonabcd123@users.noreply.github.com> Date: Sat, 28 Feb 2026 20:21:57 +0200 Subject: [PATCH 2/5] Hopefully fix id gaps --- frontend/scripts/check-assets.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/frontend/scripts/check-assets.ts b/frontend/scripts/check-assets.ts index c5213017f449..66cab425a6f6 100644 --- a/frontend/scripts/check-assets.ts +++ b/frontend/scripts/check-assets.ts @@ -224,7 +224,9 @@ async function validateQuotes(): Promise { currentLanguageQuotes !== null && currentLanguageQuotes.quotes.length < quoteData.quotes.length ) { - idOfFirstAddedQuote = currentLanguageQuotes.quotes.length + 1; + idOfFirstAddedQuote = + (currentLanguageQuotes.quotes[currentLanguageQuotes.quotes.length - 1] + ?.id ?? -1) + 1; } //check quote length From 2b1e03c6423947a93af7c522e001e468b4df0a8f Mon Sep 17 00:00:00 2001 From: Leonabcd123 <156839416+Leonabcd123@users.noreply.github.com> Date: Sun, 1 Mar 2026 10:17:02 +0200 Subject: [PATCH 3/5] Handle ids not in order --- frontend/scripts/check-assets.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/frontend/scripts/check-assets.ts b/frontend/scripts/check-assets.ts index 66cab425a6f6..5c4014404454 100644 --- a/frontend/scripts/check-assets.ts +++ b/frontend/scripts/check-assets.ts @@ -217,16 +217,14 @@ async function validateQuotes(): Promise { } // check if pr added quotes in this language - let idOfFirstAddedQuote = 0; - const currentLanguageQuotes = await fetchQuotes(quotefilename); + let addedQuotesToThisLanguage = false; + const currentLanguageData = await fetchQuotes(quotefilename); if ( - currentLanguageQuotes !== null && - currentLanguageQuotes.quotes.length < quoteData.quotes.length + currentLanguageData !== null && + currentLanguageData.quotes.length < quoteData.quotes.length ) { - idOfFirstAddedQuote = - (currentLanguageQuotes.quotes[currentLanguageQuotes.quotes.length - 1] - ?.id ?? -1) + 1; + addedQuotesToThisLanguage = true; } //check quote length @@ -238,7 +236,11 @@ async function validateQuotes(): Promise { ); } - if (idOfFirstAddedQuote > 0 && quote.id >= idOfFirstAddedQuote) { + if ( + addedQuotesToThisLanguage && + currentLanguageData !== null && + !currentLanguageData.quotes.includes(quote) + ) { if (quote.text.length < 60) { problems.add( quotefilename, From c14a7ff043c91359cc83640eb09a0431344e989f Mon Sep 17 00:00:00 2001 From: Leonabcd123 <156839416+Leonabcd123@users.noreply.github.com> Date: Mon, 2 Mar 2026 07:36:40 +0200 Subject: [PATCH 4/5] Improve comparison logic --- frontend/scripts/check-assets.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/frontend/scripts/check-assets.ts b/frontend/scripts/check-assets.ts index 5c4014404454..66c37a2783af 100644 --- a/frontend/scripts/check-assets.ts +++ b/frontend/scripts/check-assets.ts @@ -239,7 +239,9 @@ async function validateQuotes(): Promise { if ( addedQuotesToThisLanguage && currentLanguageData !== null && - !currentLanguageData.quotes.includes(quote) + !currentLanguageData.quotes.some( + (langQuote) => langQuote.text === quote.text, + ) ) { if (quote.text.length < 60) { problems.add( From ebe5f24e97b321613fe243317c800d999b7a00aa Mon Sep 17 00:00:00 2001 From: Leonabcd123 <156839416+Leonabcd123@users.noreply.github.com> Date: Mon, 2 Mar 2026 07:47:09 +0200 Subject: [PATCH 5/5] Better handling of quote modification --- frontend/scripts/check-assets.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/frontend/scripts/check-assets.ts b/frontend/scripts/check-assets.ts index 66c37a2783af..efc61b5dc06f 100644 --- a/frontend/scripts/check-assets.ts +++ b/frontend/scripts/check-assets.ts @@ -222,7 +222,9 @@ async function validateQuotes(): Promise { if ( currentLanguageData !== null && - currentLanguageData.quotes.length < quoteData.quotes.length + (currentLanguageData.quotes.length < quoteData.quotes.length || + JSON.stringify(currentLanguageData.quotes) !== + JSON.stringify(quoteData.quotes)) ) { addedQuotesToThisLanguage = true; }