@iobroker/repochecker 5.5.1 → 5.5.2

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,10 @@ Example:
25
25
  Placeholder for the next version (at the beginning of the line):
26
26
  ### **WORK IN PROGRESS**
27
27
  -->
28
+ ### 5.5.2 (2026-03-17)
29
+ - (@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.
30
+ - (@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].
31
+
28
32
  ### 5.5.1 (2026-03-17)
29
33
  - (@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
34
  - (@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.
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,47 @@ 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();
217
280
  for (const lang of context.cfg.allowedLanguages) {
218
281
  for (const i18nPath of [`/admin/i18n/${lang}/translations.json`, `/admin/i18n/${lang}.json`]) {
219
282
  if (context[i18nPath]) {
220
283
  try {
221
284
  const i18nContent = JSON.parse(context[i18nPath]);
222
- if (exampleKeys.some(key => Object.prototype.hasOwnProperty.call(i18nContent, key))) {
223
- foundExampleInI18n = true;
224
- break;
285
+ const unusedI18nKeys = exampleKeys.filter(
286
+ key =>
287
+ Object.prototype.hasOwnProperty.call(i18nContent, key) &&
288
+ !isKeyUsedInAdminConfig(context, key),
289
+ );
290
+ for (const key of unusedI18nKeys) {
291
+ foundI18nKeys.add(key);
225
292
  }
226
293
  } catch {
227
294
  // parse errors are reported elsewhere
228
295
  }
229
296
  }
230
297
  }
231
- if (foundExampleInI18n) {
232
- break;
233
- }
234
298
  }
235
- if (foundExampleInI18n) {
299
+ if (foundI18nKeys.size) {
300
+ const keyList = [...foundI18nKeys].join(', ');
236
301
  context.warnings.push(
237
- '[W1111] Example configuration (option1/option2) found in i18n translation files. Please remove example configuration from your code.',
302
+ `[W5041] Example configuration (${keyList}) found in i18n translation files. Please remove example configuration from your code.`,
238
303
  );
239
304
  context.hasExampleConfigWarning = true;
240
305
  }
@@ -355,7 +420,6 @@ async function checkCode(context) {
355
420
  usesReact = true;
356
421
  }
357
422
  if (context['/src-admin/package.json']) {
358
- //console.log('"src-admin/package.json" exists');
359
423
  const packageJson = JSON.parse(context['/src-admin/package.json']);
360
424
  if (packageJson.devDependencies && packageJson.devDependencies['@iobroker/adapter-react-v5']) {
361
425
  common.info('REACT detected at src-admin/package devDependencies');
@@ -367,7 +431,6 @@ async function checkCode(context) {
367
431
  }
368
432
  }
369
433
  if (context['/src-widgets/package.json']) {
370
- //console.log('"src-widgets/package.json" exists');
371
434
  const packageJson = JSON.parse(context['/src-widgets/package.json']);
372
435
  if (
373
436
  packageJson.devDependencies &&
@@ -964,7 +1027,7 @@ async function checkCode(context) {
964
1027
  }
965
1028
  }
966
1029
 
967
- // first free 5039
1030
+ // first free 5042
968
1031
  // 5500 - xxx reserved for jsonConfig module
969
1032
 
970
1033
  return context;
@@ -1020,5 +1083,8 @@ exports.checkCode = checkCode;
1020
1083
  // [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
1084
  // [5035] Cannot parse YAML file "${fileName}": ${e.message}
1022
1085
  // [5038] Conflicting JSON files in directory "${dir}": Both ${baseName}.json and ${baseName}.json5 versions of same file exist. Please remove one.
1086
+ // [5039] "admin/words.js" found but not referenced anywhere. File seems to be outdated, please consider removing it.
1087
+ // [E5040] Example configuration (option1/option2) found in "native" of io-package.json. Please remove example configuration from your code. (moved from E1111 in M1000)
1088
+ // [W5041] Example configuration (option1/option2) found in i18n translation files. Please remove example configuration from your code. (renamed from W1111)
1023
1089
 
1024
1090
  // [5500 - ] see M5500_jsonConfig.js
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "5.5.1",
2
+ "version": "5.5.2",
3
3
  "name": "@iobroker/repochecker",
4
4
  "dependencies": {
5
5
  "ajv": "^8.18.0",