@iobroker/repochecker 5.5.1 → 5.5.3

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 CHANGED
@@ -25,6 +25,14 @@ Example:
25
25
  Placeholder for the next version (at the beginning of the line):
26
26
  ### **WORK IN PROGRESS**
27
27
  -->
28
+ ### 5.5.3 (2026-03-19)
29
+ - (@copilot) Fixed E3016 false positive: transitive `needs` dependencies are now considered, so `deploy` depending on `adapter-tests` which already depends on `check-and-lint` is correctly accepted. Related to [#756].
30
+ - (@copilot) W5041 warning now includes the list of languages that contain the example keys (e.g. `languages: en, de, ru`).
31
+
32
+ ### 5.5.2 (2026-03-17)
33
+ - (@copilot) E5040 and W5041 messages now include the specific detected key(s) (e.g. `option1`, `option2`, or both) instead of the generic `option1/option2` placeholder. Only one issue is raised even when multiple keys are detected.
34
+ - (@copilot) Fixed E1111/W1111 checks: E1111 and W1111 are now renamed to E5040 and W5041 (correct numbering range for M5000_Code module). Both checks now correctly exempt adapters where `option1`/`option2` keys are genuinely used in `admin/index.html`, `admin/index_m.html`, or as keys in `admin/jsonConfig.json`/`admin/jsonConfig.json5`. Related to [#746].
35
+
28
36
  ### 5.5.1 (2026-03-17)
29
37
  - (@copilot) Added W5039 check: warns when `admin/words.js` exists but is not referenced anywhere in the codebase for adapters using jsonConfig. The file seems to be outdated and should be removed [#745].
30
38
  - (@copilot) Added W3018 and W3019 checks: when deploy job uses `ioBroker/testing-action-deploy@v1`, warns if job-level permissions (`contents: write`, `id-token: write`) are missing (W3018) or if the `npm-token` parameter is specified (W3019), as trusted publishing will not work in either case. Related to [#742].
@@ -309,16 +309,11 @@ async function checkIOPackageJson(context) {
309
309
  } // if (valid)
310
310
 
311
311
  // Check for example/template keys that should be removed
312
+ // Note: actual error E5040 is raised in M5000_Code.js after checking if the keys are used in admin UI files
312
313
  const exampleKeys = ['option1', 'option2'];
313
- const foundExampleKeys = exampleKeys.filter(key =>
314
+ context.nativeExampleKeys = exampleKeys.filter(key =>
314
315
  Object.prototype.hasOwnProperty.call(context.ioPackageJson.native, key),
315
316
  );
316
- if (foundExampleKeys.length && !context.hasExampleConfigWarning) {
317
- context.errors.push(
318
- '[E1111] Example configuration (option1/option2) found in "native" of io-package.json. Please remove example configuration from your code.',
319
- );
320
- context.hasExampleConfigWarning = true;
321
- }
322
317
  }
323
318
 
324
319
  if (!context.ioPackageJson.common) {
@@ -1381,6 +1376,6 @@ exports.checkIOPackageJson = checkIOPackageJson;
1381
1376
  // [1108] Schema validation failed: ${error.message}
1382
1377
  // [1109] "common.jsonConfig" is deprecated and has been replaced by "common.adminUI" at io-package.json. Please remove.
1383
1378
  // [1110] "common.jsonConfig" is deprecated and must be replaced by "common.adminUI" configuration at io-package.json.
1384
- // [1111] Example configuration (option1/option2) found. Please remove example configuration from your code.
1379
+ // [1111] -- moved to M5000_Code.js as [E5040] (check deferred to allow scanning admin UI files)
1385
1380
  // [1112] "notifications" in io-package.json must be translated into all supported languages
1386
1381
  // [1113] "native" config object will not be used when "common.adminUI.config" is set to "none". Please remove native properties from io-package.json.
@@ -64,6 +64,41 @@ function jobNeedsAll(job, requiredJobs) {
64
64
  return requiredJobs.every(req => needsArr.includes(req));
65
65
  }
66
66
 
67
+ /**
68
+ * Returns true if the job identified by `startJobName` depends on `requiredJobName`
69
+ * either directly or transitively through the needs chain.
70
+ *
71
+ * @param {object} jobs - All jobs in the workflow (map of job name -> job object)
72
+ * @param {string} startJobName - The job to start the search from
73
+ * @param {string} requiredJobName - The job name that must be reachable via needs
74
+ * @returns {boolean} true if requiredJobName is a direct or transitive dependency of startJobName
75
+ */
76
+ function jobDependsOn(jobs, startJobName, requiredJobName) {
77
+ const visited = new Set();
78
+ const queue = [startJobName];
79
+ while (queue.length > 0) {
80
+ const current = queue.shift();
81
+ if (visited.has(current)) {
82
+ continue;
83
+ }
84
+ visited.add(current);
85
+ const job = jobs[current];
86
+ if (!job || !job.needs) {
87
+ continue;
88
+ }
89
+ const needsArr = Array.isArray(job.needs) ? job.needs : [job.needs];
90
+ if (needsArr.includes(requiredJobName)) {
91
+ return true;
92
+ }
93
+ for (const dep of needsArr) {
94
+ if (!visited.has(dep)) {
95
+ queue.push(dep);
96
+ }
97
+ }
98
+ }
99
+ return false;
100
+ }
101
+
67
102
  async function checkTests(context) {
68
103
  console.log('\n[E3000 - E3999] checking tests');
69
104
 
@@ -278,9 +313,10 @@ async function checkTests(context) {
278
313
  } else {
279
314
  context.checks.push('Job "deploy" found.');
280
315
 
281
- // E3016: deploy must need check-and-lint and adapter-tests, but only if those jobs exist in the workflow
316
+ // E3016: deploy must depend (directly or transitively) on check-and-lint and adapter-tests,
317
+ // but only if those jobs exist in the workflow
282
318
  const requiredDependencies = ['check-and-lint', 'adapter-tests'].filter(j => jobs[j]);
283
- if (!jobNeedsAll(jobs['deploy'], requiredDependencies)) {
319
+ if (!requiredDependencies.every(req => jobDependsOn(jobs, 'deploy', req))) {
284
320
  context.errors.push(
285
321
  `[E3016] Workflow "${WORKFLOW_FILE}": job "deploy" must declare "needs" for both "check-and-lint" and "adapter-tests".`,
286
322
  );
package/lib/M5000_Code.js CHANGED
@@ -70,6 +70,55 @@ function getAllFiles(context, dirPath, root, filesList) {
70
70
  }
71
71
 
72
72
  // E5xx
73
+ /**
74
+ * Recursively checks if a key exists anywhere in an object structure.
75
+ * Used to check if an example config key (option1/option2) is used in jsonConfig.
76
+ *
77
+ * @param {object} obj - The object to search
78
+ * @param {string} targetKey - The key to search for
79
+ * @returns {boolean} true if the key is found anywhere in the object
80
+ */
81
+ function hasKeyInObject(obj, targetKey) {
82
+ if (typeof obj !== 'object' || obj === null) {
83
+ return false;
84
+ }
85
+ if (Object.prototype.hasOwnProperty.call(obj, targetKey)) {
86
+ return true;
87
+ }
88
+ return Object.values(obj).some(val => hasKeyInObject(val, targetKey));
89
+ }
90
+
91
+ /**
92
+ * Checks if a key is used in admin UI files (index.html, index_m.html, or jsonConfig).
93
+ * Used to suppress false-positive example config warnings when the key is intentionally used.
94
+ *
95
+ * @param {object} context - The context object with file contents
96
+ * @param {string} key - The config key to check (e.g. 'option1')
97
+ * @returns {boolean} true if the key is referenced in any admin UI file
98
+ */
99
+ function isKeyUsedInAdminConfig(context, key) {
100
+ if (context['/admin/index.html'] && context['/admin/index.html'].includes(key)) {
101
+ return true;
102
+ }
103
+ if (context['/admin/index_m.html'] && context['/admin/index_m.html'].includes(key)) {
104
+ return true;
105
+ }
106
+ const jsonConfigRaw = context['/admin/jsonConfig.json'] || context['/admin/jsonConfig.json5'];
107
+ if (jsonConfigRaw) {
108
+ try {
109
+ const parsed = context['/admin/jsonConfig.json']
110
+ ? JSON.parse(context['/admin/jsonConfig.json'])
111
+ : JSON5.parse(context['/admin/jsonConfig.json5']);
112
+ if (hasKeyInObject(parsed, key)) {
113
+ return true;
114
+ }
115
+ } catch {
116
+ // parse errors are reported elsewhere
117
+ }
118
+ }
119
+ return false;
120
+ }
121
+
73
122
  async function checkCode(context) {
74
123
  console.log('\n[E5000 - E5999] checkCode');
75
124
 
@@ -210,31 +259,52 @@ async function checkCode(context) {
210
259
  }
211
260
  }
212
261
 
213
- // Check i18n translation files for example keys (option1/option2)
262
+ // E5040: Check native example keys (option1/option2) found in io-package.json native.
263
+ // Only raise error if the keys are not actually used in admin UI files (index.html, index_m.html, or jsonConfig).
264
+ if (context.nativeExampleKeys && context.nativeExampleKeys.length && !context.hasExampleConfigWarning) {
265
+ const unusedNativeKeys = context.nativeExampleKeys.filter(key => !isKeyUsedInAdminConfig(context, key));
266
+ if (unusedNativeKeys.length) {
267
+ const keyList = unusedNativeKeys.join(', ');
268
+ context.errors.push(
269
+ `[E5040] Example configuration (${keyList}) found in "native" of io-package.json. Please remove example configuration from your code.`,
270
+ );
271
+ context.hasExampleConfigWarning = true;
272
+ }
273
+ }
274
+
275
+ // W5041: Check i18n translation files for example keys (option1/option2).
276
+ // Only raise warning if the keys are not actually used in admin UI files (index.html, index_m.html, or jsonConfig).
214
277
  if (!context.hasExampleConfigWarning) {
215
278
  const exampleKeys = ['option1', 'option2'];
216
- let foundExampleInI18n = false;
279
+ const foundI18nKeys = new Set();
280
+ const foundI18nLangs = new Set();
217
281
  for (const lang of context.cfg.allowedLanguages) {
218
282
  for (const i18nPath of [`/admin/i18n/${lang}/translations.json`, `/admin/i18n/${lang}.json`]) {
219
283
  if (context[i18nPath]) {
220
284
  try {
221
285
  const i18nContent = JSON.parse(context[i18nPath]);
222
- if (exampleKeys.some(key => Object.prototype.hasOwnProperty.call(i18nContent, key))) {
223
- foundExampleInI18n = true;
224
- break;
286
+ const unusedI18nKeys = exampleKeys.filter(
287
+ key =>
288
+ Object.prototype.hasOwnProperty.call(i18nContent, key) &&
289
+ !isKeyUsedInAdminConfig(context, key),
290
+ );
291
+ for (const key of unusedI18nKeys) {
292
+ foundI18nKeys.add(key);
225
293
  }
294
+ if (unusedI18nKeys.length) {
295
+ foundI18nLangs.add(lang);
296
+ }lang
226
297
  } catch {
227
298
  // parse errors are reported elsewhere
228
299
  }
229
300
  }
230
301
  }
231
- if (foundExampleInI18n) {
232
- break;
233
- }
234
302
  }
235
- if (foundExampleInI18n) {
303
+ if (foundI18nKeys.size) {
304
+ const keyList = [...foundI18nKeys].join(', ');
305
+ const langList = [...foundI18nLangs].join(', ');
236
306
  context.warnings.push(
237
- '[W1111] Example configuration (option1/option2) found in i18n translation files. Please remove example configuration from your code.',
307
+ `[W5041] Example configuration (${keyList}) found in i18n translation files (${langList}). Please remove example configuration from your code.`,
238
308
  );
239
309
  context.hasExampleConfigWarning = true;
240
310
  }
@@ -355,7 +425,6 @@ async function checkCode(context) {
355
425
  usesReact = true;
356
426
  }
357
427
  if (context['/src-admin/package.json']) {
358
- //console.log('"src-admin/package.json" exists');
359
428
  const packageJson = JSON.parse(context['/src-admin/package.json']);
360
429
  if (packageJson.devDependencies && packageJson.devDependencies['@iobroker/adapter-react-v5']) {
361
430
  common.info('REACT detected at src-admin/package devDependencies');
@@ -367,7 +436,6 @@ async function checkCode(context) {
367
436
  }
368
437
  }
369
438
  if (context['/src-widgets/package.json']) {
370
- //console.log('"src-widgets/package.json" exists');
371
439
  const packageJson = JSON.parse(context['/src-widgets/package.json']);
372
440
  if (
373
441
  packageJson.devDependencies &&
@@ -964,7 +1032,7 @@ async function checkCode(context) {
964
1032
  }
965
1033
  }
966
1034
 
967
- // first free 5039
1035
+ // first free 5042
968
1036
  // 5500 - xxx reserved for jsonConfig module
969
1037
 
970
1038
  return context;
@@ -1020,5 +1088,8 @@ exports.checkCode = checkCode;
1020
1088
  // [5034] Files with conflicting extensions found in directory "${dir}": ${filePaths} - Only one JavaScript/TypeScript file extension (.ts, .js, .cjs, or .mjs) should be used per file name.
1021
1089
  // [5035] Cannot parse YAML file "${fileName}": ${e.message}
1022
1090
  // [5038] Conflicting JSON files in directory "${dir}": Both ${baseName}.json and ${baseName}.json5 versions of same file exist. Please remove one.
1091
+ // [5039] "admin/words.js" found but not referenced anywhere. File seems to be outdated, please consider removing it.
1092
+ // [E5040] Example configuration (option1/option2) found in "native" of io-package.json. Please remove example configuration from your code. (moved from E1111 in M1000)
1093
+ // [W5041] Example configuration (option1/option2) found in i18n translation files (en, de, ...). Please remove example configuration from your code. (renamed from W1111)
1023
1094
 
1024
1095
  // [5500 - ] see M5500_jsonConfig.js
@@ -13,6 +13,9 @@ const common = require('./common.js');
13
13
 
14
14
  // German language words blacklist - add new words here to extend detection
15
15
  const GERMAN_WORDS = [
16
+ 'der',
17
+ 'die',
18
+ 'das',
16
19
  'Funktion',
17
20
  'Funktionen',
18
21
  'Voraussetzung',
@@ -25,7 +28,17 @@ const GERMAN_WORDS = [
25
28
  'Einstellungen',
26
29
  'Gerät',
27
30
  'Geräte',
31
+ 'Geräte-Konfiguration',
32
+ 'Gerätekonfiguration',
28
33
  'hinzufügen',
34
+ 'nicht',
35
+ 'blockiert',
36
+ 'ist',
37
+ 'von',
38
+ 'bis',
39
+ 'Wertebereich',
40
+ 'vollständig',
41
+ 'Entwickelt mit Unterstützung von',
29
42
  ];
30
43
 
31
44
  // Common English words used to verify if README is written in English
@@ -287,13 +300,13 @@ async function checkReadme(context) {
287
300
  const germanWord = findGermanWord(data);
288
301
  if (germanWord) {
289
302
  context.errors.push(
290
- `[E6015] README.md appears to be written in German (detected word: "${germanWord}"). README.md must be written in English. Please translate.`,
303
+ `[E6015] README.md appears to be written in German (detected word: "${germanWord}"). README.md must be written using English language only. Please translate.`,
291
304
  );
292
305
  } else {
293
306
  context.checks.push('No German language detected in README.md');
294
307
  if (!isEnglishText(data)) {
295
308
  context.warnings.push(
296
- '[W6016] README.md does not appear to be written in English. README.md must be written in English. Please translate.',
309
+ '[W6016] README.md does not appear to be written in English. README.md must be written using English language only. Please translate.',
297
310
  );
298
311
  } else {
299
312
  context.checks.push('README.md appears to be written in English');
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "5.5.1",
2
+ "version": "5.5.3",
3
3
  "name": "@iobroker/repochecker",
4
4
  "dependencies": {
5
5
  "ajv": "^8.18.0",