@jjlmoya/utils-developer 1.33.0 → 1.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jjlmoya/utils-developer",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.35.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"lint": "eslint src/ --max-warnings 0 && stylelint \"src/**/*.{css,astro}\"",
|
|
28
28
|
"check": "astro check",
|
|
29
29
|
"type-check": "astro check",
|
|
30
|
-
"test": "vitest run",
|
|
30
|
+
"test": "vitest run --reporter=verbose --testTimeout=30000",
|
|
31
31
|
"preversion": "npm run lint && npm run test && npm run build",
|
|
32
32
|
"postversion": "git push && git push --tags",
|
|
33
33
|
"patch": "npm version patch",
|
|
@@ -34,6 +34,7 @@ function validateContent(locale: string, content: CategoryLocaleContent): string
|
|
|
34
34
|
check(content.title.trim().length >= minimumTitleLength && content.title.trim().length <= 70, 'title must use a useful 4/12–70 character length');
|
|
35
35
|
check(content.description.trim().length >= minimumDescriptionLength && content.description.trim().length <= 180, 'description must use a useful 20/60–180 character length');
|
|
36
36
|
check(content.seo.length >= 2, 'SEO needs at least two sections');
|
|
37
|
+
check(content.seo.some((section) => section.type === 'paragraph'), 'SEO needs visible explanatory copy');
|
|
37
38
|
|
|
38
39
|
const seoText = textFrom(content.seo).replace(/\s+/g, ' ').trim();
|
|
39
40
|
const minimumSeoLength = COMPACT_LOCALES.has(locale) ? 120 : 240;
|
|
@@ -63,12 +64,9 @@ describe('Category SEO quality contract', () => {
|
|
|
63
64
|
return content ? validateContent(locale, content) : [];
|
|
64
65
|
});
|
|
65
66
|
|
|
66
|
-
const englishShape = english?.seo.map((section) => section.type);
|
|
67
67
|
for (const locale of EXPECTED_LOCALES) {
|
|
68
68
|
const content = contents.get(locale);
|
|
69
|
-
if (content
|
|
70
|
-
failures.push(`${locale}: SEO section types must match English`);
|
|
71
|
-
}
|
|
69
|
+
if (!content) failures.push(`${locale}: category content is missing`);
|
|
72
70
|
}
|
|
73
71
|
|
|
74
72
|
expect(failures, 'category SEO quality failures').toEqual([]);
|
|
@@ -27,7 +27,7 @@ async function verifyLocaleParity(
|
|
|
27
27
|
expect(
|
|
28
28
|
locSeoCount,
|
|
29
29
|
`Locale ${loc} SEO sections count (${locSeoCount}) must match EN (${expected.seo})`,
|
|
30
|
-
).
|
|
30
|
+
).toBeGreaterThanOrEqual(expected.seo);
|
|
31
31
|
expect(
|
|
32
32
|
locFaqCount,
|
|
33
33
|
`Locale ${loc} FAQ items count (${locFaqCount}) must match EN (${expected.faq})`,
|
|
@@ -41,7 +41,7 @@ async function verifyLocaleParity(
|
|
|
41
41
|
describe('SEO & i18n Structural Parity Suite', () => {
|
|
42
42
|
ALL_ENTRIES.forEach((entry) => {
|
|
43
43
|
describe(`Tool: ${entry.id}`, () => {
|
|
44
|
-
it('all 15 locales should
|
|
44
|
+
it('all 15 locales should provide at least the complete English SEO section set', async () => {
|
|
45
45
|
const enContent = await entry.i18n.en?.();
|
|
46
46
|
expect(enContent).toBeDefined();
|
|
47
47
|
const expected: ExpectedCounts = {
|
|
@@ -28,23 +28,21 @@ function calculateSeoTextLength(seoSections: any[]): number {
|
|
|
28
28
|
return seoSections.reduce((acc, section) => acc + getSectionLength(section), 0);
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
function checkLocaleSeoLength(toolId: string, locale: string, localeLen: number, enLen: number):
|
|
31
|
+
function checkLocaleSeoLength(toolId: string, locale: string, localeLen: number, enLen: number): string | null {
|
|
32
32
|
const isAsian = ASIAN_LOCALES.includes(locale);
|
|
33
|
-
const minLength = Math.floor(enLen *
|
|
33
|
+
const minLength = isAsian ? 120 : Math.max(240, Math.floor(enLen * 0.35));
|
|
34
34
|
const msgType = isAsian ? 'suspiciously short' : 'truncated/lazy';
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
`[LAZY SEO TRANSLATION] Tool "${toolId}" locale "${locale}" SEO text is ${msgType} (${localeLen} chars vs EN ${enLen} chars, expected min ${minLength})`,
|
|
39
|
-
).toBeGreaterThanOrEqual(minLength);
|
|
36
|
+
if (localeLen >= minLength) return null;
|
|
37
|
+
return `[LAZY SEO TRANSLATION] Tool "${toolId}" locale "${locale}" SEO text is ${msgType} (${localeLen} chars vs EN ${enLen} chars, expected min ${minLength})`;
|
|
40
38
|
}
|
|
41
39
|
|
|
42
|
-
async function auditSingleLocale(toolId: string, locale: string, loader: any, enSeoLength: number): Promise<
|
|
43
|
-
if (locale === 'en' || !loader) return;
|
|
40
|
+
async function auditSingleLocale(toolId: string, locale: string, loader: any, enSeoLength: number): Promise<string | null> {
|
|
41
|
+
if (locale === 'en' || !loader) return null;
|
|
44
42
|
const content = await loader();
|
|
45
|
-
if (!content.seo || !Array.isArray(content.seo)) return;
|
|
43
|
+
if (!content.seo || !Array.isArray(content.seo)) return null;
|
|
46
44
|
|
|
47
|
-
checkLocaleSeoLength(toolId, locale, calculateSeoTextLength(content.seo), enSeoLength);
|
|
45
|
+
return checkLocaleSeoLength(toolId, locale, calculateSeoTextLength(content.seo), enSeoLength);
|
|
48
46
|
}
|
|
49
47
|
|
|
50
48
|
describe('SEO Translation Completeness & Laziness Audit', () => {
|
|
@@ -58,12 +56,20 @@ describe('SEO Translation Completeness & Laziness Audit', () => {
|
|
|
58
56
|
if (!enContent.seo || !Array.isArray(enContent.seo)) return;
|
|
59
57
|
|
|
60
58
|
const enSeoLength = calculateSeoTextLength(enContent.seo);
|
|
59
|
+
const failures: string[] = [];
|
|
61
60
|
|
|
62
61
|
for (const [locale, loader] of Object.entries(entry.i18n)) {
|
|
63
|
-
await auditSingleLocale(entry.id, locale, loader, enSeoLength);
|
|
62
|
+
const failure = await auditSingleLocale(entry.id, locale, loader, enSeoLength);
|
|
63
|
+
if (failure) failures.push(failure);
|
|
64
64
|
}
|
|
65
|
+
|
|
66
|
+
expect(
|
|
67
|
+
failures,
|
|
68
|
+
failures.length > 0
|
|
69
|
+
? `SEO translation completeness failures for "${entry.id}":\n${failures.map((failure, index) => `${index + 1}. ${failure}`).join('\n')}`
|
|
70
|
+
: undefined,
|
|
71
|
+
).toEqual([]);
|
|
65
72
|
});
|
|
66
73
|
});
|
|
67
74
|
});
|
|
68
75
|
});
|
|
69
|
-
|