@iobroker/repochecker 5.15.0 → 5.15.1
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/README.md +4 -0
- package/lib/M5600__I18n.js +110 -20
- package/lib/postprocessing.js +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -25,6 +25,10 @@ Example:
|
|
|
25
25
|
Placeholder for the next version (at the beginning of the line):
|
|
26
26
|
### **WORK IN PROGRESS**
|
|
27
27
|
-->
|
|
28
|
+
### 5.15.1 (2026-05-27)
|
|
29
|
+
|
|
30
|
+
- (mcm1957) X56xx issues have been count-limited
|
|
31
|
+
|
|
28
32
|
### 5.15.0 (2026-05-27)
|
|
29
33
|
|
|
30
34
|
- (mcm1957) I18n checks have been extended
|
package/lib/M5600__I18n.js
CHANGED
|
@@ -25,6 +25,60 @@ const TRANSLATABLE_ATTRS = [
|
|
|
25
25
|
'placeholder',
|
|
26
26
|
'validatorErrorText',
|
|
27
27
|
];
|
|
28
|
+
const MAX_W5612_WARNINGS = 10;
|
|
29
|
+
const MAX_56XX_ISSUES_PER_CODE = 10;
|
|
30
|
+
const ISSUE_CODE_56XX_REGEX = /^\[((?:E|W|S)56\d{2})\]/;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Limit every E/W/S56xx issue code in the list to MAX_56XX_ISSUES_PER_CODE messages
|
|
34
|
+
* plus one additional "maximum reached" message.
|
|
35
|
+
*
|
|
36
|
+
* @param {string[]} issues - Issue list (errors, warnings, or suggestions).
|
|
37
|
+
* @returns {string[]} - Limited issue list.
|
|
38
|
+
*/
|
|
39
|
+
function limit56xxIssues(issues) {
|
|
40
|
+
const limited = [];
|
|
41
|
+
const perCodeCount = new Map();
|
|
42
|
+
|
|
43
|
+
for (const issue of issues) {
|
|
44
|
+
const match = issue.match(ISSUE_CODE_56XX_REGEX);
|
|
45
|
+
if (!match) {
|
|
46
|
+
limited.push(issue);
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const code = match[1];
|
|
51
|
+
const count = perCodeCount.get(code) ?? 0;
|
|
52
|
+
|
|
53
|
+
if (count < MAX_56XX_ISSUES_PER_CODE) {
|
|
54
|
+
limited.push(issue);
|
|
55
|
+
perCodeCount.set(code, count + 1);
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (count === MAX_56XX_ISSUES_PER_CODE) {
|
|
60
|
+
limited.push(
|
|
61
|
+
`[${code}] Maximum number of ${code} issues (${MAX_56XX_ISSUES_PER_CODE}) has been reached. Additional ${code} issues exist.`,
|
|
62
|
+
);
|
|
63
|
+
perCodeCount.set(code, count + 1);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return limited;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Apply issue limits for all E/W/S56xx codes.
|
|
72
|
+
*
|
|
73
|
+
* @param {object} context - The repochecker context object.
|
|
74
|
+
*/
|
|
75
|
+
function apply56xxIssueLimits(context) {
|
|
76
|
+
context.errors = limit56xxIssues(context.errors);
|
|
77
|
+
context.warnings = limit56xxIssues(context.warnings);
|
|
78
|
+
if (Array.isArray(context.suggestions)) {
|
|
79
|
+
context.suggestions = limit56xxIssues(context.suggestions);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
28
82
|
|
|
29
83
|
/**
|
|
30
84
|
* Escape a string for use as a literal in a regular expression.
|
|
@@ -267,9 +321,16 @@ function checkI18nDirectory(context, i18nDir) {
|
|
|
267
321
|
*
|
|
268
322
|
* @param {any} node - jsonConfig node to scan
|
|
269
323
|
* @param {string} currentPath - path in the jsonConfig for error reporting
|
|
270
|
-
* @
|
|
324
|
+
* @param {{insideSelectOptions: boolean}} [state] - recursion state tracking if traversal is currently inside options of a select* component.
|
|
325
|
+
* @returns {Array<{
|
|
326
|
+
* attr: string,
|
|
327
|
+
* value: any,
|
|
328
|
+
* path: string,
|
|
329
|
+
* noTranslation: boolean,
|
|
330
|
+
* isSelectOptionLabel: boolean
|
|
331
|
+
* }>} - Collected attribute entries. isSelectOptionLabel is true for label attributes found inside select* options.
|
|
271
332
|
*/
|
|
272
|
-
function collectTranslatableValues(node, currentPath) {
|
|
333
|
+
function collectTranslatableValues(node, currentPath, state = { insideSelectOptions: false }) {
|
|
273
334
|
if (!node || typeof node !== 'object') {
|
|
274
335
|
return [];
|
|
275
336
|
}
|
|
@@ -278,7 +339,7 @@ function collectTranslatableValues(node, currentPath) {
|
|
|
278
339
|
|
|
279
340
|
if (Array.isArray(node)) {
|
|
280
341
|
node.forEach((item, i) => {
|
|
281
|
-
results.push(...collectTranslatableValues(item, `${currentPath}[${i}]
|
|
342
|
+
results.push(...collectTranslatableValues(item, `${currentPath}[${i}]`, state));
|
|
282
343
|
});
|
|
283
344
|
return results;
|
|
284
345
|
}
|
|
@@ -286,18 +347,28 @@ function collectTranslatableValues(node, currentPath) {
|
|
|
286
347
|
// If this node has noTranslation set, its string values should not be checked
|
|
287
348
|
const noTranslation = node.noTranslation === true;
|
|
288
349
|
|
|
350
|
+
const nodeType = typeof node.type === 'string' ? node.type : '';
|
|
351
|
+
const isSelectComponent = nodeType.startsWith('select');
|
|
352
|
+
|
|
289
353
|
for (const [key, value] of Object.entries(node)) {
|
|
290
354
|
if (TRANSLATABLE_ATTRS.includes(key) && value !== undefined && value !== null) {
|
|
291
|
-
results.push({
|
|
355
|
+
results.push({
|
|
356
|
+
attr: key,
|
|
357
|
+
value,
|
|
358
|
+
path: currentPath,
|
|
359
|
+
noTranslation,
|
|
360
|
+
isSelectOptionLabel: key === 'label' && state.insideSelectOptions,
|
|
361
|
+
});
|
|
292
362
|
}
|
|
293
363
|
|
|
294
364
|
// Recurse into child objects and arrays
|
|
365
|
+
const childState = key === 'options' && isSelectComponent ? { insideSelectOptions: true } : state;
|
|
295
366
|
if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
|
|
296
|
-
results.push(...collectTranslatableValues(value, `${currentPath}/${key}
|
|
367
|
+
results.push(...collectTranslatableValues(value, `${currentPath}/${key}`, childState));
|
|
297
368
|
} else if (Array.isArray(value)) {
|
|
298
369
|
value.forEach((item, i) => {
|
|
299
370
|
if (typeof item === 'object' && item !== null) {
|
|
300
|
-
results.push(...collectTranslatableValues(item, `${currentPath}/${key}[${i}]
|
|
371
|
+
results.push(...collectTranslatableValues(item, `${currentPath}/${key}[${i}]`, childState));
|
|
301
372
|
}
|
|
302
373
|
});
|
|
303
374
|
}
|
|
@@ -341,7 +412,7 @@ function getI18nDirForJsonConfig(context, configFile, jsonConfig) {
|
|
|
341
412
|
* @param {object} jsonConfig - parsed jsonConfig object
|
|
342
413
|
* @param {string} i18nDir - associated i18n directory path like '/admin/i18n'
|
|
343
414
|
*/
|
|
344
|
-
function checkJsonConfigTranslations(context, configFile, jsonConfig, i18nDir) {
|
|
415
|
+
function checkJsonConfigTranslations(context, configFile, jsonConfig, i18nDir, w5612State) {
|
|
345
416
|
const displayConfig = configFile.replace(/^\//, '');
|
|
346
417
|
const { allowedLanguages, requiredLanguages } = context.cfg;
|
|
347
418
|
const i18nMode = jsonConfig.i18n;
|
|
@@ -394,21 +465,16 @@ function checkJsonConfigTranslations(context, configFile, jsonConfig, i18nDir) {
|
|
|
394
465
|
|
|
395
466
|
const translatables = collectTranslatableValues(jsonConfig, displayConfig);
|
|
396
467
|
|
|
397
|
-
for (const { attr, value, path, noTranslation } of translatables) {
|
|
468
|
+
for (const { attr, value, path, noTranslation, isSelectOptionLabel } of translatables) {
|
|
398
469
|
// Skip attributes where the component declares noTranslation: true
|
|
399
470
|
if (noTranslation) {
|
|
400
471
|
continue;
|
|
401
472
|
}
|
|
402
473
|
|
|
403
474
|
if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
//
|
|
407
|
-
// context.warnings.push(
|
|
408
|
-
// `[W5616] "${path}" attribute "${attr}" defines inline i18n object while i18n is enabled. Consider using a translation key string instead.`,
|
|
409
|
-
// );
|
|
410
|
-
} else {
|
|
411
|
-
// i18n=false: check that required languages are present in the object
|
|
475
|
+
if (isSelectOptionLabel || i18nMode === false) {
|
|
476
|
+
// When i18n=false, or for select-option labels regardless of i18n mode,
|
|
477
|
+
// all inline i18n objects must be complete.
|
|
412
478
|
for (const lang of requiredLanguages) {
|
|
413
479
|
if (!Object.prototype.hasOwnProperty.call(value, lang)) {
|
|
414
480
|
context.errors.push(
|
|
@@ -423,6 +489,15 @@ function checkJsonConfigTranslations(context, configFile, jsonConfig, i18nDir) {
|
|
|
423
489
|
);
|
|
424
490
|
}
|
|
425
491
|
}
|
|
492
|
+
continue;
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
// Value is an inline i18n object (e.g. { en: "Name", de: "Name" })
|
|
496
|
+
if (i18nMode === true || typeof i18nMode === 'string') {
|
|
497
|
+
// When i18n files are used, translatable attributes should be string keys
|
|
498
|
+
// context.warnings.push(
|
|
499
|
+
// `[W5616] "${path}" attribute "${attr}" defines inline i18n object while i18n is enabled. Consider using a translation key string instead.`,
|
|
500
|
+
// );
|
|
426
501
|
}
|
|
427
502
|
} else if (typeof value === 'string') {
|
|
428
503
|
if (i18nMode === false) {
|
|
@@ -431,13 +506,24 @@ function checkJsonConfigTranslations(context, configFile, jsonConfig, i18nDir) {
|
|
|
431
506
|
`[W5617] "${path}" attribute "${attr}" uses a plain string while jsonConfig has i18n=false. Consider using an inline i18n object instead.`,
|
|
432
507
|
);
|
|
433
508
|
} else if (enTranslations !== null) {
|
|
509
|
+
if (isSelectOptionLabel) {
|
|
510
|
+
continue;
|
|
511
|
+
}
|
|
434
512
|
// i18n enabled: check that the string is a valid key in the English translations
|
|
435
513
|
if (!Object.prototype.hasOwnProperty.call(enTranslations, value)) {
|
|
436
514
|
if (value.match(/[a-zA-Z]/) && value.length >= 3) {
|
|
437
515
|
// do not force translations of labels containing no characters
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
516
|
+
if (w5612State.count < MAX_W5612_WARNINGS) {
|
|
517
|
+
context.warnings.push(
|
|
518
|
+
`[W5612] "${path}" attribute "${attr}" uses key "${value}" which is not found in the English translation file at "${i18nDir.replace(/^\//, '')}/en".`,
|
|
519
|
+
);
|
|
520
|
+
w5612State.count++;
|
|
521
|
+
} else if (!w5612State.limitWarningAdded) {
|
|
522
|
+
context.warnings.push(
|
|
523
|
+
`[W5612] Maximum number of W5612 warnings (${MAX_W5612_WARNINGS}) has been reached. Additional W5612 warnings exist.`,
|
|
524
|
+
);
|
|
525
|
+
w5612State.limitWarningAdded = true;
|
|
526
|
+
}
|
|
441
527
|
}
|
|
442
528
|
}
|
|
443
529
|
}
|
|
@@ -464,6 +550,8 @@ function checkAllI18n(context) {
|
|
|
464
550
|
|
|
465
551
|
// 2. Check jsonConfig files for correct i18n attribute usage and translatable attribute consistency
|
|
466
552
|
const jsonConfigFiles = ['/admin/jsonConfig.json', '/admin/jsonConfig.json5'];
|
|
553
|
+
// Limit W5612 globally across all jsonConfig files processed in one run.
|
|
554
|
+
const w5612State = { count: 0, limitWarningAdded: false };
|
|
467
555
|
|
|
468
556
|
for (const configFile of jsonConfigFiles) {
|
|
469
557
|
if (!context[configFile]) {
|
|
@@ -481,8 +569,10 @@ function checkAllI18n(context) {
|
|
|
481
569
|
}
|
|
482
570
|
|
|
483
571
|
const i18nDir = getI18nDirForJsonConfig(context, configFile, jsonConfig);
|
|
484
|
-
checkJsonConfigTranslations(context, configFile, jsonConfig, i18nDir);
|
|
572
|
+
checkJsonConfigTranslations(context, configFile, jsonConfig, i18nDir, w5612State);
|
|
485
573
|
}
|
|
574
|
+
|
|
575
|
+
apply56xxIssueLimits(context);
|
|
486
576
|
}
|
|
487
577
|
|
|
488
578
|
exports.checkAllI18n = checkAllI18n;
|
package/lib/postprocessing.js
CHANGED
|
@@ -43,10 +43,12 @@ const mapSeverity4New = {
|
|
|
43
43
|
W8916: 'E', // [W8916] Dependabot configuration "/.github/dependabot.yml" has no entry with "package-ecosystem: github-actions".
|
|
44
44
|
W8917: 'E', // [W8917] At least major versions of @types/node should not be updated by dependabot.
|
|
45
45
|
S0062: 'W', // [S0062] Consider adding and using package "@alcalzone/release-script".
|
|
46
|
+
S2008: 'E', // [S2008] Version 0.5.1 tagged as "latest" at npm is not signed with provenance. Trusted publishing is recommended.
|
|
46
47
|
S3012: 'E', // [S3012] Workflow "test-and-release.yml": job "deploy" is not defined.
|
|
47
48
|
S5022: 'W', // [S5022] Please consider migrating to admin 5 UI (jsonConfig) or react based UI.
|
|
48
49
|
S5043: 'E', // [S5043] Package "xx" is a built-in Node.js module. Please use "node:fs" instead.
|
|
49
50
|
S5051: 'W', // [S5051] Custom sleep/wait function(s) found in source files (src/lib/adsb.ts).
|
|
51
|
+
W5611: 'E', // [W5611] "admin/jsonConfig.json/items/tab_region/items/country/options[0]" attribute "label" is missing language "uk" in i18n object.
|
|
50
52
|
S6008: 'E', // [S6008] Changelog for version 0.7.0-beta.19 should be added to README.md
|
|
51
53
|
S6020: 'W', // [S6020] Consider adding a CHANGELOG_OLD.md file to store older changelog entries. This is supported by @alcalzone/releasescript.
|
|
52
54
|
S8901: 'W', // [S8901] Dependabot configuration file ".github/dependabot.yml" not found. Consider adding dependabot to keep dependencies up to date.
|
package/package.json
CHANGED