@jjlmoya/utils-games-development 1.66.0 → 1.68.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 +67 -67
- package/scripts/postinstall.mjs +27 -27
- package/src/category/GamesCategorySEO.astro +19 -19
- package/src/category/i18n/de.ts +15 -15
- package/src/category/i18n/en.ts +15 -15
- package/src/category/i18n/es.ts +15 -15
- package/src/category/i18n/fr.ts +15 -15
- package/src/category/i18n/id.ts +10 -10
- package/src/category/i18n/it.ts +10 -10
- package/src/category/i18n/ja.ts +10 -10
- package/src/category/i18n/ko.ts +10 -10
- package/src/category/i18n/nl.ts +10 -10
- package/src/category/i18n/pl.ts +10 -10
- package/src/category/i18n/pt.ts +10 -10
- package/src/category/i18n/ru.ts +10 -10
- package/src/category/i18n/sv.ts +10 -10
- package/src/category/i18n/tr.ts +10 -10
- package/src/category/i18n/zh.ts +10 -10
- package/src/category/seo.astro +15 -15
- package/src/components/PreviewNavSidebar.astro +116 -116
- package/src/components/PreviewToolbar.astro +143 -143
- package/src/data.ts +11 -11
- package/src/env.d.ts +5 -5
- package/src/index.ts +20 -20
- package/src/layouts/PreviewLayout.astro +122 -122
- package/src/pages/[locale]/[slug].astro +165 -165
- package/src/pages/[locale].astro +250 -250
- package/src/pages/index.astro +4 -4
- package/src/tests/category_seo_quality.test.ts +74 -0
- package/src/tests/diacritics_density.test.ts +118 -118
- package/src/tests/faq_count.test.ts +19 -19
- package/src/tests/i18n_coverage.test.ts +36 -36
- package/src/tests/inverted_punctuation.test.ts +84 -84
- package/src/tests/mocks/astro_mock.js +2 -2
- package/src/tests/no_en_dash.test.ts +70 -70
- package/src/tests/no_h1_in_components.test.ts +48 -48
- package/src/tests/pagespeed_best_practices.test.ts +198 -198
- package/src/tests/qa-test-helpers.ts +32 -32
- package/src/tests/qa_bibliography_links.test.ts +41 -41
- package/src/tests/qa_claim_evidence.test.ts +69 -69
- package/src/tests/qa_logic_reference_coverage.test.ts +46 -46
- package/src/tests/qa_runtime_i18n.test.ts +100 -100
- package/src/tests/schemas_fulfillment.test.ts +23 -23
- package/src/tests/script_density.test.ts +94 -94
- package/src/tests/seo_length.test.ts +23 -23
- package/src/tests/seo_translation_completeness.test.ts +18 -12
- package/src/tests/slug_language_code_format.test.ts +23 -23
- package/src/tests/slug_uniqueness.test.ts +80 -80
- package/src/tests/title_quality.test.ts +56 -56
- package/src/tool/audioLoopPointFinder/audio-loop-point-finder.css +322 -322
- package/src/tool/audioLoopPointFinder/client.ts +262 -262
- package/src/tool/hitboxHurtboxAnimator/hitbox-hurtbox-animator.css +614 -614
- package/src/tool/saveFileEditor/component.astro +351 -351
- package/src/tool/saveFileEditor/game-save-file-editor.css +250 -250
- package/src/tool/spriteSheetPacker/app-client.ts +248 -248
- package/src/tool/spriteSheetPacker/bibliography.ts +12 -12
- package/src/tool/spriteSheetPacker/component.astro +229 -229
- package/src/tool/spriteSheetPacker/dropzone-client.ts +55 -55
- package/src/tool/spriteSheetPacker/entry.ts +28 -28
- package/src/tool/spriteSheetPacker/exporter.ts +116 -116
- package/src/tool/spriteSheetPacker/extractor-client.ts +127 -127
- package/src/tool/spriteSheetPacker/flipbook-client.ts +60 -60
- package/src/tool/spriteSheetPacker/logic.test.ts +155 -155
- package/src/tool/spriteSheetPacker/logic.ts +32 -32
- package/src/tool/spriteSheetPacker/packer-core.ts +121 -121
- package/src/tool/spriteSheetPacker/packer-ui.ts +86 -86
- package/src/tool/spriteSheetPacker/sprite-sheet-packer.css +578 -578
- package/src/tool/spriteSheetPacker/types.ts +89 -89
- package/src/tool/spriteSheetPacker/ui.ts +42 -42
- package/src/tool/steamCapsuleGenerator/index.ts +9 -9
- package/src/tool/steamCapsuleGenerator/validation.ts +14 -14
- package/src/types.ts +72 -72
|
@@ -1,118 +1,118 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { ALL_TOOLS } from '../tools';
|
|
3
|
-
|
|
4
|
-
type LocaleWithDiacritics = keyof typeof DIACRITIC_RULES;
|
|
5
|
-
|
|
6
|
-
const DIACRITIC_RULES = {
|
|
7
|
-
de: {
|
|
8
|
-
language: 'German',
|
|
9
|
-
expectedCharacters: 'ä ö ü ß',
|
|
10
|
-
characters: /[äöüÄÖÜß]/g,
|
|
11
|
-
minPerThousandLetters: 0.1,
|
|
12
|
-
},
|
|
13
|
-
es: {
|
|
14
|
-
language: 'Spanish',
|
|
15
|
-
expectedCharacters: 'á é í ó ú ü ñ',
|
|
16
|
-
characters: /[áéíóúüñÁÉÍÓÚÜÑ]/g,
|
|
17
|
-
minPerThousandLetters: 0.1,
|
|
18
|
-
},
|
|
19
|
-
fr: {
|
|
20
|
-
language: 'French',
|
|
21
|
-
expectedCharacters: 'à â æ ç é è ê ë î ï ô œ ù û ü ÿ',
|
|
22
|
-
characters: /[àâæçéèêëîïôœùûüÿÀÂÆÇÉÈÊËÎÏÔŒÙÛÜŸ]/g,
|
|
23
|
-
minPerThousandLetters: 0.1,
|
|
24
|
-
},
|
|
25
|
-
it: {
|
|
26
|
-
language: 'Italian',
|
|
27
|
-
expectedCharacters: 'à è é ì í î ò ó ù ú',
|
|
28
|
-
characters: /[àèéìíîòóùúÀÈÉÌÍÎÒÓÙÚ]/g,
|
|
29
|
-
minPerThousandLetters: 0.1,
|
|
30
|
-
},
|
|
31
|
-
pl: {
|
|
32
|
-
language: 'Polish',
|
|
33
|
-
expectedCharacters: 'ą ć ę ł ń ó ś ź ż',
|
|
34
|
-
characters: /[ąćęłńóśźżĄĆĘŁŃÓŚŹŻ]/g,
|
|
35
|
-
minPerThousandLetters: 0.1,
|
|
36
|
-
},
|
|
37
|
-
pt: {
|
|
38
|
-
language: 'Portuguese',
|
|
39
|
-
expectedCharacters: 'á â ã à ç é ê í ó ô õ ú ü',
|
|
40
|
-
characters: /[áâãàçéêíóôõúüÁÂÃÀÇÉÊÍÓÔÕÚÜ]/g,
|
|
41
|
-
minPerThousandLetters: 0.1,
|
|
42
|
-
},
|
|
43
|
-
sv: {
|
|
44
|
-
language: 'Swedish',
|
|
45
|
-
expectedCharacters: 'å ä ö',
|
|
46
|
-
characters: /[åäöÅÄÖ]/g,
|
|
47
|
-
minPerThousandLetters: 0.1,
|
|
48
|
-
},
|
|
49
|
-
tr: {
|
|
50
|
-
language: 'Turkish',
|
|
51
|
-
expectedCharacters: 'ç ğ ı İ ö ş ü',
|
|
52
|
-
characters: /[çğıöşüÇĞİÖŞÜ]/g,
|
|
53
|
-
minPerThousandLetters: 0.1,
|
|
54
|
-
},
|
|
55
|
-
} as const;
|
|
56
|
-
|
|
57
|
-
const LETTERS = /\p{L}/gu;
|
|
58
|
-
const TRANSLATABLE_KEYS = ['title', 'description', 'ui', 'seo', 'faq', 'howTo'] as const;
|
|
59
|
-
|
|
60
|
-
function collectStrings(value: unknown): string[] {
|
|
61
|
-
if (typeof value === 'string') return [value];
|
|
62
|
-
if (!value || typeof value !== 'object') return [];
|
|
63
|
-
if (Array.isArray(value)) return value.flatMap(collectStrings);
|
|
64
|
-
return Object.values(value).flatMap(collectStrings);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function normalizeText(value: unknown): string {
|
|
68
|
-
return collectStrings(value).join(' ').normalize('NFC');
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function translatableContent(content: Record<string, unknown>) {
|
|
72
|
-
return TRANSLATABLE_KEYS.map((key) => content[key]);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
function letterCount(text: string): number {
|
|
76
|
-
return text.match(LETTERS)?.length ?? 0;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
function diacriticCount(text: string, locale: LocaleWithDiacritics): number {
|
|
80
|
-
return text.match(DIACRITIC_RULES[locale].characters)?.length ?? 0;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function diacriticsPerThousandLetters(text: string, locale: LocaleWithDiacritics): number {
|
|
84
|
-
const letters = letterCount(text);
|
|
85
|
-
if (letters === 0) return 0;
|
|
86
|
-
return diacriticCount(text, locale) / letters * 1000;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
describe('Diacritics density validation', () => {
|
|
90
|
-
ALL_TOOLS.forEach((tool) => {
|
|
91
|
-
describe(`Tool: ${tool.entry.id}`, () => {
|
|
92
|
-
Object.keys(DIACRITIC_RULES).forEach((locale) => {
|
|
93
|
-
it(`${locale} keeps the expected accent and special-letter set`, async () => {
|
|
94
|
-
const typedLocale = locale as LocaleWithDiacritics;
|
|
95
|
-
const loader = tool.entry.i18n[typedLocale];
|
|
96
|
-
if (!loader) return;
|
|
97
|
-
|
|
98
|
-
const content = await loader();
|
|
99
|
-
const text = normalizeText(translatableContent(content as unknown as Record<string, unknown>));
|
|
100
|
-
const rule = DIACRITIC_RULES[typedLocale];
|
|
101
|
-
const letters = letterCount(text);
|
|
102
|
-
const matches = diacriticCount(text, typedLocale);
|
|
103
|
-
const density = diacriticsPerThousandLetters(text, typedLocale);
|
|
104
|
-
|
|
105
|
-
expect(
|
|
106
|
-
density,
|
|
107
|
-
[
|
|
108
|
-
`Possible spelling or encoding issue detected in ${tool.entry.id}/${typedLocale} (${rule.language}).`,
|
|
109
|
-
`The text has ${matches} special characters (${density.toFixed(2)} per 1000 letters, ${letters} letters analyzed).`,
|
|
110
|
-
`This locale should include some of these characters: ${rule.expectedCharacters}.`,
|
|
111
|
-
'If the count is 0 or near 0, accents, tildes, or special letters were probably stripped by encoding or normalization.',
|
|
112
|
-
].join(' '),
|
|
113
|
-
).toBeGreaterThanOrEqual(rule.minPerThousandLetters);
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
|
-
});
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { ALL_TOOLS } from '../tools';
|
|
3
|
+
|
|
4
|
+
type LocaleWithDiacritics = keyof typeof DIACRITIC_RULES;
|
|
5
|
+
|
|
6
|
+
const DIACRITIC_RULES = {
|
|
7
|
+
de: {
|
|
8
|
+
language: 'German',
|
|
9
|
+
expectedCharacters: 'ä ö ü ß',
|
|
10
|
+
characters: /[äöüÄÖÜß]/g,
|
|
11
|
+
minPerThousandLetters: 0.1,
|
|
12
|
+
},
|
|
13
|
+
es: {
|
|
14
|
+
language: 'Spanish',
|
|
15
|
+
expectedCharacters: 'á é í ó ú ü ñ',
|
|
16
|
+
characters: /[áéíóúüñÁÉÍÓÚÜÑ]/g,
|
|
17
|
+
minPerThousandLetters: 0.1,
|
|
18
|
+
},
|
|
19
|
+
fr: {
|
|
20
|
+
language: 'French',
|
|
21
|
+
expectedCharacters: 'à â æ ç é è ê ë î ï ô œ ù û ü ÿ',
|
|
22
|
+
characters: /[àâæçéèêëîïôœùûüÿÀÂÆÇÉÈÊËÎÏÔŒÙÛÜŸ]/g,
|
|
23
|
+
minPerThousandLetters: 0.1,
|
|
24
|
+
},
|
|
25
|
+
it: {
|
|
26
|
+
language: 'Italian',
|
|
27
|
+
expectedCharacters: 'à è é ì í î ò ó ù ú',
|
|
28
|
+
characters: /[àèéìíîòóùúÀÈÉÌÍÎÒÓÙÚ]/g,
|
|
29
|
+
minPerThousandLetters: 0.1,
|
|
30
|
+
},
|
|
31
|
+
pl: {
|
|
32
|
+
language: 'Polish',
|
|
33
|
+
expectedCharacters: 'ą ć ę ł ń ó ś ź ż',
|
|
34
|
+
characters: /[ąćęłńóśźżĄĆĘŁŃÓŚŹŻ]/g,
|
|
35
|
+
minPerThousandLetters: 0.1,
|
|
36
|
+
},
|
|
37
|
+
pt: {
|
|
38
|
+
language: 'Portuguese',
|
|
39
|
+
expectedCharacters: 'á â ã à ç é ê í ó ô õ ú ü',
|
|
40
|
+
characters: /[áâãàçéêíóôõúüÁÂÃÀÇÉÊÍÓÔÕÚÜ]/g,
|
|
41
|
+
minPerThousandLetters: 0.1,
|
|
42
|
+
},
|
|
43
|
+
sv: {
|
|
44
|
+
language: 'Swedish',
|
|
45
|
+
expectedCharacters: 'å ä ö',
|
|
46
|
+
characters: /[åäöÅÄÖ]/g,
|
|
47
|
+
minPerThousandLetters: 0.1,
|
|
48
|
+
},
|
|
49
|
+
tr: {
|
|
50
|
+
language: 'Turkish',
|
|
51
|
+
expectedCharacters: 'ç ğ ı İ ö ş ü',
|
|
52
|
+
characters: /[çğıöşüÇĞİÖŞÜ]/g,
|
|
53
|
+
minPerThousandLetters: 0.1,
|
|
54
|
+
},
|
|
55
|
+
} as const;
|
|
56
|
+
|
|
57
|
+
const LETTERS = /\p{L}/gu;
|
|
58
|
+
const TRANSLATABLE_KEYS = ['title', 'description', 'ui', 'seo', 'faq', 'howTo'] as const;
|
|
59
|
+
|
|
60
|
+
function collectStrings(value: unknown): string[] {
|
|
61
|
+
if (typeof value === 'string') return [value];
|
|
62
|
+
if (!value || typeof value !== 'object') return [];
|
|
63
|
+
if (Array.isArray(value)) return value.flatMap(collectStrings);
|
|
64
|
+
return Object.values(value).flatMap(collectStrings);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function normalizeText(value: unknown): string {
|
|
68
|
+
return collectStrings(value).join(' ').normalize('NFC');
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function translatableContent(content: Record<string, unknown>) {
|
|
72
|
+
return TRANSLATABLE_KEYS.map((key) => content[key]);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function letterCount(text: string): number {
|
|
76
|
+
return text.match(LETTERS)?.length ?? 0;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function diacriticCount(text: string, locale: LocaleWithDiacritics): number {
|
|
80
|
+
return text.match(DIACRITIC_RULES[locale].characters)?.length ?? 0;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function diacriticsPerThousandLetters(text: string, locale: LocaleWithDiacritics): number {
|
|
84
|
+
const letters = letterCount(text);
|
|
85
|
+
if (letters === 0) return 0;
|
|
86
|
+
return diacriticCount(text, locale) / letters * 1000;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
describe('Diacritics density validation', () => {
|
|
90
|
+
ALL_TOOLS.forEach((tool) => {
|
|
91
|
+
describe(`Tool: ${tool.entry.id}`, () => {
|
|
92
|
+
Object.keys(DIACRITIC_RULES).forEach((locale) => {
|
|
93
|
+
it(`${locale} keeps the expected accent and special-letter set`, async () => {
|
|
94
|
+
const typedLocale = locale as LocaleWithDiacritics;
|
|
95
|
+
const loader = tool.entry.i18n[typedLocale];
|
|
96
|
+
if (!loader) return;
|
|
97
|
+
|
|
98
|
+
const content = await loader();
|
|
99
|
+
const text = normalizeText(translatableContent(content as unknown as Record<string, unknown>));
|
|
100
|
+
const rule = DIACRITIC_RULES[typedLocale];
|
|
101
|
+
const letters = letterCount(text);
|
|
102
|
+
const matches = diacriticCount(text, typedLocale);
|
|
103
|
+
const density = diacriticsPerThousandLetters(text, typedLocale);
|
|
104
|
+
|
|
105
|
+
expect(
|
|
106
|
+
density,
|
|
107
|
+
[
|
|
108
|
+
`Possible spelling or encoding issue detected in ${tool.entry.id}/${typedLocale} (${rule.language}).`,
|
|
109
|
+
`The text has ${matches} special characters (${density.toFixed(2)} per 1000 letters, ${letters} letters analyzed).`,
|
|
110
|
+
`This locale should include some of these characters: ${rule.expectedCharacters}.`,
|
|
111
|
+
'If the count is 0 or near 0, accents, tildes, or special letters were probably stripped by encoding or normalization.',
|
|
112
|
+
].join(' '),
|
|
113
|
+
).toBeGreaterThanOrEqual(rule.minPerThousandLetters);
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
});
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import type * as DATA from '../data';
|
|
3
|
-
|
|
4
|
-
const TOOLS: typeof DATA.gamesCategory[] = [];
|
|
5
|
-
|
|
6
|
-
describe('FAQ Content Validation', () => {
|
|
7
|
-
TOOLS.forEach((entry) => {
|
|
8
|
-
describe(`Tool: ${entry.icon}`, () => {
|
|
9
|
-
it('placeholder', () => {
|
|
10
|
-
expect(true).toBe(true);
|
|
11
|
-
});
|
|
12
|
-
});
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it('no tools registered yet', () => {
|
|
16
|
-
expect(TOOLS.length).toBe(0);
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import type * as DATA from '../data';
|
|
3
|
+
|
|
4
|
+
const TOOLS: typeof DATA.gamesCategory[] = [];
|
|
5
|
+
|
|
6
|
+
describe('FAQ Content Validation', () => {
|
|
7
|
+
TOOLS.forEach((entry) => {
|
|
8
|
+
describe(`Tool: ${entry.icon}`, () => {
|
|
9
|
+
it('placeholder', () => {
|
|
10
|
+
expect(true).toBe(true);
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it('no tools registered yet', () => {
|
|
16
|
+
expect(TOOLS.length).toBe(0);
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { ALL_TOOLS } from '../tools';
|
|
3
|
-
|
|
4
|
-
const EXPECTED_LOCALES = [
|
|
5
|
-
'de', 'en', 'es', 'fr', 'id', 'it', 'ja', 'ko', 'nl', 'pl', 'pt', 'ru', 'sv', 'tr', 'zh'
|
|
6
|
-
];
|
|
7
|
-
|
|
8
|
-
describe('I18n Coverage Validation', () => {
|
|
9
|
-
it('all tools should be registered', () => {
|
|
10
|
-
expect(ALL_TOOLS.length).toBeGreaterThan(0);
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
ALL_TOOLS.forEach(({ entry }: { entry: any }) => {
|
|
14
|
-
describe(`Tool: ${entry.id}`, () => {
|
|
15
|
-
it('should have all 15 required locales', () => {
|
|
16
|
-
const registeredLocales = Object.keys(entry.i18n);
|
|
17
|
-
EXPECTED_LOCALES.forEach((locale) => {
|
|
18
|
-
expect(
|
|
19
|
-
registeredLocales,
|
|
20
|
-
`Tool "${entry.id}" is missing locale "${locale}"`,
|
|
21
|
-
).toContain(locale);
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it('all locale loaders should be functions', () => {
|
|
26
|
-
EXPECTED_LOCALES.forEach((locale) => {
|
|
27
|
-
const loader = entry.i18n[locale as keyof typeof entry.i18n];
|
|
28
|
-
expect(
|
|
29
|
-
typeof loader,
|
|
30
|
-
`Tool "${entry.id}" locale "${locale}" loader is not a function`,
|
|
31
|
-
).toBe('function');
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
});
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { ALL_TOOLS } from '../tools';
|
|
3
|
+
|
|
4
|
+
const EXPECTED_LOCALES = [
|
|
5
|
+
'de', 'en', 'es', 'fr', 'id', 'it', 'ja', 'ko', 'nl', 'pl', 'pt', 'ru', 'sv', 'tr', 'zh'
|
|
6
|
+
];
|
|
7
|
+
|
|
8
|
+
describe('I18n Coverage Validation', () => {
|
|
9
|
+
it('all tools should be registered', () => {
|
|
10
|
+
expect(ALL_TOOLS.length).toBeGreaterThan(0);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
ALL_TOOLS.forEach(({ entry }: { entry: any }) => {
|
|
14
|
+
describe(`Tool: ${entry.id}`, () => {
|
|
15
|
+
it('should have all 15 required locales', () => {
|
|
16
|
+
const registeredLocales = Object.keys(entry.i18n);
|
|
17
|
+
EXPECTED_LOCALES.forEach((locale) => {
|
|
18
|
+
expect(
|
|
19
|
+
registeredLocales,
|
|
20
|
+
`Tool "${entry.id}" is missing locale "${locale}"`,
|
|
21
|
+
).toContain(locale);
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('all locale loaders should be functions', () => {
|
|
26
|
+
EXPECTED_LOCALES.forEach((locale) => {
|
|
27
|
+
const loader = entry.i18n[locale as keyof typeof entry.i18n];
|
|
28
|
+
expect(
|
|
29
|
+
typeof loader,
|
|
30
|
+
`Tool "${entry.id}" locale "${locale}" loader is not a function`,
|
|
31
|
+
).toBe('function');
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
});
|
|
@@ -1,84 +1,84 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { ALL_TOOLS } from '../tools';
|
|
3
|
-
|
|
4
|
-
const INVERTED_PUNCTUATION_LOCALES = {
|
|
5
|
-
es: {
|
|
6
|
-
language: 'Spanish',
|
|
7
|
-
questionStart: '¿',
|
|
8
|
-
questionEnd: '?',
|
|
9
|
-
exclamationStart: '¡',
|
|
10
|
-
exclamationEnd: '!',
|
|
11
|
-
},
|
|
12
|
-
} as const;
|
|
13
|
-
|
|
14
|
-
type InvertedPunctuationLocale = keyof typeof INVERTED_PUNCTUATION_LOCALES;
|
|
15
|
-
|
|
16
|
-
const TRANSLATABLE_KEYS = ['title', 'description', 'ui', 'seo', 'faq', 'howTo'] as const;
|
|
17
|
-
|
|
18
|
-
function collectStrings(value: unknown): string[] {
|
|
19
|
-
if (typeof value === 'string') return [value];
|
|
20
|
-
if (!value || typeof value !== 'object') return [];
|
|
21
|
-
if (Array.isArray(value)) return value.flatMap(collectStrings);
|
|
22
|
-
return Object.values(value).flatMap(collectStrings);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function translatableStrings(content: Record<string, unknown>): string[] {
|
|
26
|
-
return TRANSLATABLE_KEYS.flatMap((key) => collectStrings(content[key]));
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function sentenceStart(text: string, endIndex: number): string {
|
|
30
|
-
const beforeMark = text.slice(0, endIndex).trimEnd();
|
|
31
|
-
const boundary = Math.max(
|
|
32
|
-
beforeMark.lastIndexOf('.'),
|
|
33
|
-
beforeMark.lastIndexOf(':'),
|
|
34
|
-
beforeMark.lastIndexOf(';'),
|
|
35
|
-
beforeMark.lastIndexOf('\n'),
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
return beforeMark.slice(boundary + 1).trimStart();
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function findMissingInvertedMarks(
|
|
42
|
-
text: string,
|
|
43
|
-
startMark: string,
|
|
44
|
-
endMark: string,
|
|
45
|
-
): string[] {
|
|
46
|
-
return [...text.matchAll(new RegExp(`\\${endMark}`, 'g'))]
|
|
47
|
-
.map((match) => sentenceStart(text, match.index ?? 0))
|
|
48
|
-
.filter((segment) => segment.length > 0 && !segment.includes(startMark))
|
|
49
|
-
.map((segment) => `${segment}${endMark}`);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
describe('Inverted punctuation validation', () => {
|
|
53
|
-
ALL_TOOLS.forEach((tool) => {
|
|
54
|
-
describe(`Tool: ${tool.entry.id}`, () => {
|
|
55
|
-
Object.keys(INVERTED_PUNCTUATION_LOCALES).forEach((locale) => {
|
|
56
|
-
it(`${locale} uses opening punctuation marks for questions and exclamations`, async () => {
|
|
57
|
-
const typedLocale = locale as InvertedPunctuationLocale;
|
|
58
|
-
const loader = tool.entry.i18n[typedLocale];
|
|
59
|
-
if (!loader) return;
|
|
60
|
-
|
|
61
|
-
const rule = INVERTED_PUNCTUATION_LOCALES[typedLocale];
|
|
62
|
-
const content = await loader();
|
|
63
|
-
const strings = translatableStrings(content as unknown as Record<string, unknown>);
|
|
64
|
-
const missingQuestions = strings.flatMap((text) =>
|
|
65
|
-
findMissingInvertedMarks(text, rule.questionStart, rule.questionEnd)
|
|
66
|
-
);
|
|
67
|
-
const missingExclamations = strings.flatMap((text) =>
|
|
68
|
-
findMissingInvertedMarks(text, rule.exclamationStart, rule.exclamationEnd)
|
|
69
|
-
);
|
|
70
|
-
const failures = [...missingQuestions, ...missingExclamations];
|
|
71
|
-
|
|
72
|
-
expect(
|
|
73
|
-
failures,
|
|
74
|
-
[
|
|
75
|
-
`Missing opening punctuation marks in ${tool.entry.id}/${typedLocale} (${rule.language}).`,
|
|
76
|
-
`Questions must use ${rule.questionStart}...${rule.questionEnd} and exclamations must use ${rule.exclamationStart}...${rule.exclamationEnd}.`,
|
|
77
|
-
`Examples: ${failures.slice(0, 5).join(' | ')}`,
|
|
78
|
-
].join(' '),
|
|
79
|
-
).toHaveLength(0);
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
});
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { ALL_TOOLS } from '../tools';
|
|
3
|
+
|
|
4
|
+
const INVERTED_PUNCTUATION_LOCALES = {
|
|
5
|
+
es: {
|
|
6
|
+
language: 'Spanish',
|
|
7
|
+
questionStart: '¿',
|
|
8
|
+
questionEnd: '?',
|
|
9
|
+
exclamationStart: '¡',
|
|
10
|
+
exclamationEnd: '!',
|
|
11
|
+
},
|
|
12
|
+
} as const;
|
|
13
|
+
|
|
14
|
+
type InvertedPunctuationLocale = keyof typeof INVERTED_PUNCTUATION_LOCALES;
|
|
15
|
+
|
|
16
|
+
const TRANSLATABLE_KEYS = ['title', 'description', 'ui', 'seo', 'faq', 'howTo'] as const;
|
|
17
|
+
|
|
18
|
+
function collectStrings(value: unknown): string[] {
|
|
19
|
+
if (typeof value === 'string') return [value];
|
|
20
|
+
if (!value || typeof value !== 'object') return [];
|
|
21
|
+
if (Array.isArray(value)) return value.flatMap(collectStrings);
|
|
22
|
+
return Object.values(value).flatMap(collectStrings);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function translatableStrings(content: Record<string, unknown>): string[] {
|
|
26
|
+
return TRANSLATABLE_KEYS.flatMap((key) => collectStrings(content[key]));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function sentenceStart(text: string, endIndex: number): string {
|
|
30
|
+
const beforeMark = text.slice(0, endIndex).trimEnd();
|
|
31
|
+
const boundary = Math.max(
|
|
32
|
+
beforeMark.lastIndexOf('.'),
|
|
33
|
+
beforeMark.lastIndexOf(':'),
|
|
34
|
+
beforeMark.lastIndexOf(';'),
|
|
35
|
+
beforeMark.lastIndexOf('\n'),
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
return beforeMark.slice(boundary + 1).trimStart();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function findMissingInvertedMarks(
|
|
42
|
+
text: string,
|
|
43
|
+
startMark: string,
|
|
44
|
+
endMark: string,
|
|
45
|
+
): string[] {
|
|
46
|
+
return [...text.matchAll(new RegExp(`\\${endMark}`, 'g'))]
|
|
47
|
+
.map((match) => sentenceStart(text, match.index ?? 0))
|
|
48
|
+
.filter((segment) => segment.length > 0 && !segment.includes(startMark))
|
|
49
|
+
.map((segment) => `${segment}${endMark}`);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
describe('Inverted punctuation validation', () => {
|
|
53
|
+
ALL_TOOLS.forEach((tool) => {
|
|
54
|
+
describe(`Tool: ${tool.entry.id}`, () => {
|
|
55
|
+
Object.keys(INVERTED_PUNCTUATION_LOCALES).forEach((locale) => {
|
|
56
|
+
it(`${locale} uses opening punctuation marks for questions and exclamations`, async () => {
|
|
57
|
+
const typedLocale = locale as InvertedPunctuationLocale;
|
|
58
|
+
const loader = tool.entry.i18n[typedLocale];
|
|
59
|
+
if (!loader) return;
|
|
60
|
+
|
|
61
|
+
const rule = INVERTED_PUNCTUATION_LOCALES[typedLocale];
|
|
62
|
+
const content = await loader();
|
|
63
|
+
const strings = translatableStrings(content as unknown as Record<string, unknown>);
|
|
64
|
+
const missingQuestions = strings.flatMap((text) =>
|
|
65
|
+
findMissingInvertedMarks(text, rule.questionStart, rule.questionEnd)
|
|
66
|
+
);
|
|
67
|
+
const missingExclamations = strings.flatMap((text) =>
|
|
68
|
+
findMissingInvertedMarks(text, rule.exclamationStart, rule.exclamationEnd)
|
|
69
|
+
);
|
|
70
|
+
const failures = [...missingQuestions, ...missingExclamations];
|
|
71
|
+
|
|
72
|
+
expect(
|
|
73
|
+
failures,
|
|
74
|
+
[
|
|
75
|
+
`Missing opening punctuation marks in ${tool.entry.id}/${typedLocale} (${rule.language}).`,
|
|
76
|
+
`Questions must use ${rule.questionStart}...${rule.questionEnd} and exclamations must use ${rule.exclamationStart}...${rule.exclamationEnd}.`,
|
|
77
|
+
`Examples: ${failures.slice(0, 5).join(' | ')}`,
|
|
78
|
+
].join(' '),
|
|
79
|
+
).toHaveLength(0);
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export default function () { return null; }
|
|
2
|
-
|
|
1
|
+
export default function () { return null; }
|
|
2
|
+
|
|
@@ -1,70 +1,70 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import fs from 'node:fs';
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
|
|
5
|
-
function getFiles(dir: string): string[] {
|
|
6
|
-
const results: string[] = [];
|
|
7
|
-
if (!fs.existsSync(dir)) {
|
|
8
|
-
return results;
|
|
9
|
-
}
|
|
10
|
-
const list = fs.readdirSync(dir);
|
|
11
|
-
for (const file of list) {
|
|
12
|
-
const fullPath = path.join(dir, file);
|
|
13
|
-
const stat = fs.statSync(fullPath);
|
|
14
|
-
if (stat && stat.isDirectory()) {
|
|
15
|
-
if (file !== 'tests' && file !== 'node_modules' && file !== '.astro') {
|
|
16
|
-
results.push(...getFiles(fullPath));
|
|
17
|
-
}
|
|
18
|
-
} else {
|
|
19
|
-
results.push(fullPath);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
return results;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function isContentFile(filePath: string): boolean {
|
|
26
|
-
return /\\i18n\\/.test(filePath) || filePath.endsWith('bibliography.ts');
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const srcDir = path.join(process.cwd(), 'src');
|
|
30
|
-
const scriptsDir = path.join(process.cwd(), 'scripts');
|
|
31
|
-
const filesToTest = [
|
|
32
|
-
...getFiles(srcDir).filter(isContentFile),
|
|
33
|
-
...getFiles(scriptsDir).filter(isContentFile),
|
|
34
|
-
];
|
|
35
|
-
|
|
36
|
-
const aiTypographyGarbage = [
|
|
37
|
-
'\u2013',
|
|
38
|
-
'\u2014',
|
|
39
|
-
'\u2026',
|
|
40
|
-
'\u201C',
|
|
41
|
-
'\u201D',
|
|
42
|
-
'\u2018',
|
|
43
|
-
'\u2019',
|
|
44
|
-
'\u00AB',
|
|
45
|
-
'\u00BB',
|
|
46
|
-
'\u200B',
|
|
47
|
-
'\u201E',
|
|
48
|
-
];
|
|
49
|
-
|
|
50
|
-
describe('Typography Garbage Character Validation', () => {
|
|
51
|
-
filesToTest.forEach((filePath) => {
|
|
52
|
-
const relativePath = path.relative(process.cwd(), filePath);
|
|
53
|
-
it(`should not contain typography garbage characters in ${relativePath}`, () => {
|
|
54
|
-
const content = fs.readFileSync(filePath, 'utf-8');
|
|
55
|
-
const hasAiPatterns = aiTypographyGarbage.some(char => content.includes(char));
|
|
56
|
-
expect(hasAiPatterns).toBe(false);
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it(`should not contain space before colon in ${relativePath}`, () => {
|
|
60
|
-
const content = fs.readFileSync(filePath, 'utf-8');
|
|
61
|
-
const spaceBeforeColon = / : /.test(content);
|
|
62
|
-
expect(spaceBeforeColon).toBe(false);
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it(`should not contain double hyphen in ${relativePath}`, () => {
|
|
66
|
-
const content = fs.readFileSync(filePath, 'utf-8');
|
|
67
|
-
expect(content).not.toContain('--');
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
});
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
|
|
5
|
+
function getFiles(dir: string): string[] {
|
|
6
|
+
const results: string[] = [];
|
|
7
|
+
if (!fs.existsSync(dir)) {
|
|
8
|
+
return results;
|
|
9
|
+
}
|
|
10
|
+
const list = fs.readdirSync(dir);
|
|
11
|
+
for (const file of list) {
|
|
12
|
+
const fullPath = path.join(dir, file);
|
|
13
|
+
const stat = fs.statSync(fullPath);
|
|
14
|
+
if (stat && stat.isDirectory()) {
|
|
15
|
+
if (file !== 'tests' && file !== 'node_modules' && file !== '.astro') {
|
|
16
|
+
results.push(...getFiles(fullPath));
|
|
17
|
+
}
|
|
18
|
+
} else {
|
|
19
|
+
results.push(fullPath);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return results;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function isContentFile(filePath: string): boolean {
|
|
26
|
+
return /\\i18n\\/.test(filePath) || filePath.endsWith('bibliography.ts');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const srcDir = path.join(process.cwd(), 'src');
|
|
30
|
+
const scriptsDir = path.join(process.cwd(), 'scripts');
|
|
31
|
+
const filesToTest = [
|
|
32
|
+
...getFiles(srcDir).filter(isContentFile),
|
|
33
|
+
...getFiles(scriptsDir).filter(isContentFile),
|
|
34
|
+
];
|
|
35
|
+
|
|
36
|
+
const aiTypographyGarbage = [
|
|
37
|
+
'\u2013',
|
|
38
|
+
'\u2014',
|
|
39
|
+
'\u2026',
|
|
40
|
+
'\u201C',
|
|
41
|
+
'\u201D',
|
|
42
|
+
'\u2018',
|
|
43
|
+
'\u2019',
|
|
44
|
+
'\u00AB',
|
|
45
|
+
'\u00BB',
|
|
46
|
+
'\u200B',
|
|
47
|
+
'\u201E',
|
|
48
|
+
];
|
|
49
|
+
|
|
50
|
+
describe('Typography Garbage Character Validation', () => {
|
|
51
|
+
filesToTest.forEach((filePath) => {
|
|
52
|
+
const relativePath = path.relative(process.cwd(), filePath);
|
|
53
|
+
it(`should not contain typography garbage characters in ${relativePath}`, () => {
|
|
54
|
+
const content = fs.readFileSync(filePath, 'utf-8');
|
|
55
|
+
const hasAiPatterns = aiTypographyGarbage.some(char => content.includes(char));
|
|
56
|
+
expect(hasAiPatterns).toBe(false);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it(`should not contain space before colon in ${relativePath}`, () => {
|
|
60
|
+
const content = fs.readFileSync(filePath, 'utf-8');
|
|
61
|
+
const spaceBeforeColon = / : /.test(content);
|
|
62
|
+
expect(spaceBeforeColon).toBe(false);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it(`should not contain double hyphen in ${relativePath}`, () => {
|
|
66
|
+
const content = fs.readFileSync(filePath, 'utf-8');
|
|
67
|
+
expect(content).not.toContain('--');
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
});
|