@iobroker/repochecker 5.16.0 → 5.17.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/README.md CHANGED
@@ -25,9 +25,23 @@ Example:
25
25
  Placeholder for the next version (at the beginning of the line):
26
26
  ### **WORK IN PROGRESS**
27
27
  -->
28
+ ### 5.17.0 (2026-05-30)
29
+
30
+ - (mcm1957) jsonConfig component oauth2 added.
31
+ - (mcm1957) Some translation issue are compacted better.
32
+ - (mcm1957) handle package alias definitiosn from tsconfig.json
33
+ - (@copilot) Improved `[E5004]`/`[W5004]`/`[W5005]` checks: `setInterval()`/`setTimeout()` are now scanned across all source files (not just the main file); bare calls (not prefixed with `this.` or `adapter.`) are flagged with a suggestion to use `this.setInterval()`/`adapter.setInterval()` or `this.setTimeout()`/`adapter.setTimeout()` instead. Messages also note when no matching `clearInterval()`/`clearTimeout()` is detected in the file.
34
+ - (@copilot) Added support for `// @repochecker: optional dependency 'pkg'` comments in source files: missing dependency warnings (`[W5042]`) are suppressed for declared optional packages, and dedicated warning/suggestion messages are emitted for invalid/unused/optional-missing declarations.
35
+ - (@copilot) Adjusted timer checks: bare `setInterval()`/`setTimeout()` calls are now reported once as suggestions (`[S5004]`/`[S5005]`) across all source files, while missing matching `clearInterval()`/`clearTimeout()` calls are reported separately as warnings (`[W5004]`/`[W5005]`).
36
+ - (@copilot) Updated adminUI/file consistency checks: `admin/jsonConfig.json(5)` now consistently warns (`[W5046]`) when `common.adminUI.config !== "json"`, and added the same warning pattern for `admin/jsonTab.json(5)` via `[W5064]` when `common.adminUI.tab !== "json"`.
37
+
38
+ ### 5.16.1 (2026-05-28)
39
+
40
+ - (mcm1957) Processing of require / import filenames has been adapted.
41
+
28
42
  ### 5.16.0 (2026-05-28)
29
43
 
30
- - (mcm1957) Incorrect checking of provenence / trusted publishing has benn fixed.
44
+ - (mcm1957) Incorrect checking of provenence / trusted publishing has been fixed.
31
45
  - (mcm1957) Checking of @tsconfig/nodeNN has been added
32
46
  - (mcm1957) Checing of state roles has been renewed
33
47
  - (mcm1957) Component qrCodeSendTo has been added
@@ -1173,36 +1173,26 @@ async function checkPackageJson(context) {
1173
1173
  );
1174
1174
  } else {
1175
1175
  context.checks.push('engines attribute containing node requirements exist.');
1176
- // 'engines': { 'node': '>= 18' }
1177
- // 'engines': { 'node': '>= 18.1.2' }
1178
- // 'engines': { 'node': '>= 18.1.2 < 19' }
1179
1176
  const nodeVal = context.packageJson.engines.node;
1180
- const match = nodeVal.match(/^(?<cmp>[<>=~]+)?\s*(?<vers>\d+(\.\d+(\.\d+)?)?(-\w+\.\d+)?)/m);
1181
- if (!match) {
1177
+ minimumNodeJsSupported = common.getMinimumNodeJsVersion(nodeVal);
1178
+ if (!minimumNodeJsSupported) {
1182
1179
  context.warnings.push(
1183
1180
  `[W0027] Engines clause at package.json ({'engines' : { 'node' : '${nodeVal}' } }") is not parseable.`,
1184
1181
  );
1185
1182
  } else {
1186
- common.debug(`node check: ${JSON.stringify(match.groups)}`);
1187
- minimumNodeJsSupported = match.groups.vers;
1188
- if (match.groups.cmp !== '>' && match.groups.cmp !== '>=') {
1183
+ common.debug(`minimum node.js version from engines clause: ${minimumNodeJsSupported}`);
1184
+ if (!compareVersions.compare(minimumNodeJsSupported, requiredNodeVersion, '>=')) {
1185
+ context.errors.push(
1186
+ `[E0029] Node.js ${requiredNodeVersion} is required as minimum, node.js ${recommendedNodeVersion} is recommended. The current engines.node clause "${nodeVal}" allows Node.js ${minimumNodeJsSupported} as minimum. Please update it to require at least ">=${requiredNodeVersion}" at package.json.`,
1187
+ );
1188
+ } else if (!compareVersions.compare(minimumNodeJsSupported, recommendedNodeVersion, '>=')) {
1189
1189
  context.warnings.push(
1190
- `[W0028] Minimum node.js version ${recommendedNodeVersion} recommended. Please change "{'engines' : { 'node' >= '${match.groups.vers}' } }" to "{'engines' : { 'node' >= '${recommendedNodeVersion}' } }" at package.json.`,
1190
+ `[W0028] Minimum node.js version ${recommendedNodeVersion} recommended. The current engines.node clause "${nodeVal}" allows Node.js ${minimumNodeJsSupported} as minimum. Please update it to require at least ">=${recommendedNodeVersion}" at package.json.`,
1191
1191
  );
1192
1192
  } else {
1193
- if (!compareVersions.compare(match.groups.vers, requiredNodeVersion, '>=')) {
1194
- context.errors.push(
1195
- `[E0029] Node.js ${requiredNodeVersion} is required as minimum, node.js ${recommendedNodeVersion} is recommended. Please change "{'engines' : { 'node' >= '${match.groups.vers}' } }" to "{'engines' : { 'node' >= '${requiredNodeVersion}' } }" at package.json.`,
1196
- );
1197
- } else if (!compareVersions.compare(match.groups.vers, recommendedNodeVersion, '>=')) {
1198
- context.warnings.push(
1199
- `[W0028] Minimum node.js version ${recommendedNodeVersion} recommended. Please adapt "{'engines' : { 'node' >= '${match.groups.vers}' } }" to "{'engines' : { 'node' >= '${recommendedNodeVersion}' } }" at package.json.`,
1200
- );
1201
- } else {
1202
- context.checks.push(
1203
- `Correct node.js version ${match.groups.vers} requested by "engines" attribute at package.json.`,
1204
- );
1205
- }
1193
+ context.checks.push(
1194
+ `Correct node.js version ${minimumNodeJsSupported} requested by "engines" attribute at package.json.`,
1195
+ );
1206
1196
  }
1207
1197
  }
1208
1198
  }
@@ -349,6 +349,8 @@ function checkNotificationScopes(notifications, adapterName, allowedScopes) {
349
349
  async function checkIOPackageJson(context) {
350
350
  console.log('\n[E1000 - E1999] checking io-package.json');
351
351
 
352
+ let encryptedNativeHasDotIds = false;
353
+
352
354
  if (!context.ioPackageJson.native) {
353
355
  context.errors.push('[E1001] io-package.json must have at least empty "native" attribute');
354
356
  } else {
@@ -456,7 +458,16 @@ async function checkIOPackageJson(context) {
456
458
  if (nativeForChecks[key] === undefined) {
457
459
  // Check if the key contains a dot, indicating an array element path
458
460
  if (key.includes('.')) {
459
- context.warnings.push(`[W1103] Encryption of array elements "${key}" is not yet available`);
461
+ if (
462
+ Array.isArray(context.ioPackageJson.encryptedNative) &&
463
+ context.ioPackageJson.encryptedNative.includes(key)
464
+ ) {
465
+ // encryptedNative dot key: supported since js-controller 7.0.7
466
+ encryptedNativeHasDotIds = true;
467
+ } else {
468
+ // protectedNative-only dot key: not yet supported
469
+ context.warnings.push(`[W1103] Encryption of array elements "${key}" is not yet available`);
470
+ }
460
471
  } else {
461
472
  context.warnings.push(
462
473
  `[W1095] Protected or encrypted element "${key}" should be listed at "native" in io-package.json`,
@@ -1094,11 +1105,10 @@ async function checkIOPackageJson(context) {
1094
1105
  }
1095
1106
  if (
1096
1107
  instanceObject.common.states !== undefined &&
1097
- (typeof instanceObject.common.states !== 'number' &&
1098
- typeof instanceObject.common.states !== 'string')
1108
+ (typeof instanceObject.common.states !== 'object')
1099
1109
  ) {
1100
1110
  context.warnings.push(
1101
- `[W1127] io-package.json: instanceObject "${instanceObject._id || index}" common.states must be number or string`,
1111
+ `[W1127] io-package.json: instanceObject "${instanceObject._id || index}" common.states must be an object`,
1102
1112
  );
1103
1113
  }
1104
1114
 
@@ -1286,6 +1296,12 @@ async function checkIOPackageJson(context) {
1286
1296
  if (context.ioPackageJson && context.ioPackageJson.common && context.ioPackageJson.common.nodeProcessParams) {
1287
1297
  requiredJsControllerVersion = common.maxVersion(requiredJsControllerVersion, '5.0.18');
1288
1298
  }
1299
+ if (encryptedNativeHasDotIds) {
1300
+ requiredJsControllerVersion = common.maxVersion(requiredJsControllerVersion, '7.0.7');
1301
+ }
1302
+
1303
+ // Store the resolved version in context for use by later check modules (e.g. M5000_Code)
1304
+ context.currentJsControllerVersion = currentJsControllerVersion;
1289
1305
 
1290
1306
  if (
1291
1307
  currentJsControllerVersion &&
@@ -1785,7 +1801,8 @@ exports.checkIOPackageJson = checkIOPackageJson;
1785
1801
  // [1100] Empty dependency objects found in "common.dependencies" at io-package.json. Please remove empty objects.
1786
1802
  // [1101] Empty dependency objects found in "common.globalDependencies" at io-package.json. Please remove empty objects.
1787
1803
  // [1102] Consider adding 'vis-2' to "common.restartAdapters" as 'vis' is already listed in io-package.json
1788
- // [1103] Encryption of array elements "${key}" is not yet available
1804
+ // [1103] Encryption of array elements "${key}" is not yet available (protectedNative-only dot keys)
1805
+ // [1103] encryptedNative dot keys are supported since js-controller 7.0.7 and trigger E1057 if the version requirement is not met
1789
1806
  // [1104] allowInit is only used with scheduled adapters and should be removed
1790
1807
  // [1105] Schema validation: ${errorMsg}
1791
1808
  // [1107] Could not download io-package.json schema for validation
@@ -10,6 +10,7 @@
10
10
  const axios = require('axios');
11
11
  const compareVersions = require('compare-versions');
12
12
  const yaml = require('js-yaml');
13
+ const semverMajor = require('semver/functions/major');
13
14
  const common = require('./common.js');
14
15
  const config = require('./config.js');
15
16
 
@@ -723,24 +724,21 @@ async function checkTests(context) {
723
724
  let effectiveRecCheckAndLint = parseInt(testingCfg.recommendedNodeVersionCheckAndLint, 10);
724
725
  let effectiveMinDeploy = parseInt(testingCfg.minimumNodeVersionDeploy, 10);
725
726
  let effectiveRecDeploy = parseInt(testingCfg.recommendedNodeVersionDeploy, 10);
726
- const enginesNode = context.packageJson && context.packageJson.engines && context.packageJson.engines.node;
727
727
  let enginesMajor = 0;
728
- if (enginesNode) {
729
- const enginesMatch = String(enginesNode).match(/(\d+)/);
730
- if (enginesMatch) {
731
- enginesMajor = parseInt(enginesMatch[1], 10);
732
- if (enginesMajor > effectiveMinCheckAndLint) {
733
- effectiveMinCheckAndLint = enginesMajor;
734
- }
735
- if (enginesMajor > effectiveRecCheckAndLint) {
736
- effectiveRecCheckAndLint = enginesMajor;
737
- }
738
- if (enginesMajor > effectiveMinDeploy) {
739
- effectiveMinDeploy = enginesMajor;
740
- }
741
- if (enginesMajor > effectiveRecDeploy) {
742
- effectiveRecDeploy = enginesMajor;
743
- }
728
+ const minimumNodeJsSupported = context.minimumNodeJsSupported;
729
+ if (minimumNodeJsSupported) {
730
+ enginesMajor = semverMajor(minimumNodeJsSupported);
731
+ if (enginesMajor > effectiveMinCheckAndLint) {
732
+ effectiveMinCheckAndLint = enginesMajor;
733
+ }
734
+ if (enginesMajor > effectiveRecCheckAndLint) {
735
+ effectiveRecCheckAndLint = enginesMajor;
736
+ }
737
+ if (enginesMajor > effectiveMinDeploy) {
738
+ effectiveMinDeploy = enginesMajor;
739
+ }
740
+ if (enginesMajor > effectiveRecDeploy) {
741
+ effectiveRecDeploy = enginesMajor;
744
742
  }
745
743
  }
746
744
 
package/lib/M5000_Code.js CHANGED
@@ -20,6 +20,7 @@ const M5600__I18n = require('./M5600__I18n.js');
20
20
 
21
21
  // YAML file extensions for validation
22
22
  const yamlExtensions = ['.yml', '.yaml'];
23
+ const jsonExtensions = ['.json', '.json5'];
23
24
 
24
25
  // Known Node.js built-in modules (can be used with node: prefix)
25
26
  const NODE_BUILT_INS = new Set([
@@ -296,6 +297,47 @@ function collectJsonConfigPasswordFields(node, passwordLocations, options) {
296
297
  }
297
298
  }
298
299
 
300
+ /**
301
+ * Recursively collect table/accordion components that define encryptedAttributes.
302
+ * These components require js-controller >= 7.0.7 for encrypted array element support.
303
+ *
304
+ * @param {*} node - Current JSON node to inspect
305
+ * @param {string[]} locations - Array to collect "filePath:pathInFile" strings
306
+ * @param {{ filePath: string, pathInFile: string }} options - Context for the current node
307
+ */
308
+ function collectJsonConfigEncryptedAttributeComponents(node, locations, options) {
309
+ if (!node || typeof node !== 'object') {
310
+ return;
311
+ }
312
+
313
+ if (Array.isArray(node)) {
314
+ node.forEach((entry, index) =>
315
+ collectJsonConfigEncryptedAttributeComponents(entry, locations, {
316
+ ...options,
317
+ pathInFile: `${options.pathInFile}[${index}]`,
318
+ }),
319
+ );
320
+ return;
321
+ }
322
+
323
+ const nodeType = typeof node.type === 'string' ? node.type : undefined;
324
+
325
+ if (
326
+ (nodeType === 'table' || nodeType === 'accordion') &&
327
+ Array.isArray(node.encryptedAttributes) &&
328
+ node.encryptedAttributes.length > 0
329
+ ) {
330
+ locations.push(`${options.filePath}:${options.pathInFile}`);
331
+ }
332
+
333
+ for (const [key, value] of Object.entries(node)) {
334
+ collectJsonConfigEncryptedAttributeComponents(value, locations, {
335
+ ...options,
336
+ pathInFile: `${options.pathInFile}/${key}`,
337
+ });
338
+ }
339
+ }
340
+
299
341
  /**
300
342
  * Strip single-line and block comments from source code content.
301
343
  * This is a best-effort approach: it handles the common cases but does not
@@ -386,6 +428,102 @@ function extractImports(content) {
386
428
  return [...imports];
387
429
  }
388
430
 
431
+ /**
432
+ * Extract optional dependencies declared via repochecker line comments.
433
+ *
434
+ * Supported syntax (line comment only):
435
+ * // @repochecker: optional dependency 'pkg'
436
+ * // @repochecker: optional dependency "pkg"
437
+ *
438
+ * @param {string} content - File content
439
+ * @returns {string[]} Array of unique optional dependency names
440
+ */
441
+ function extractOptionalDependencies(content) {
442
+ const optionalDependencies = new Set();
443
+ const optionalDependencyPattern = /^\s*\/\/\s*@repochecker:\s*optional dependency\s+(['"])([^'"\r\n]+)\1\s*$/gm;
444
+ let match;
445
+ while ((match = optionalDependencyPattern.exec(content)) !== null) {
446
+ optionalDependencies.add(match[2]);
447
+ }
448
+ return [...optionalDependencies];
449
+ }
450
+
451
+ function analyzeJsonFormatting(content, isJson5File) {
452
+ const issues = [];
453
+ const lines = content.split(/\r?\n/);
454
+ let isInsideJson5BlockComment = false;
455
+
456
+ let hasTabIndent = false;
457
+ let hasSpaceIndent = false;
458
+ let hasMixedIndentLine = false;
459
+ const spaceIndentLengths = [];
460
+ let maxRelevantLineLength = 0;
461
+ let relevantLineCount = 0;
462
+
463
+ for (const line of lines) {
464
+ const trimmedLine = line.trim();
465
+ if (!trimmedLine) {
466
+ continue;
467
+ }
468
+ if (isJson5File) {
469
+ if (isInsideJson5BlockComment) {
470
+ if (trimmedLine.includes('*/')) {
471
+ isInsideJson5BlockComment = false;
472
+ }
473
+ continue;
474
+ }
475
+ if (trimmedLine.startsWith('//')) {
476
+ continue;
477
+ }
478
+ if (trimmedLine.startsWith('/*')) {
479
+ if (!trimmedLine.includes('*/')) {
480
+ isInsideJson5BlockComment = true;
481
+ }
482
+ continue;
483
+ }
484
+ }
485
+
486
+ relevantLineCount++;
487
+ maxRelevantLineLength = Math.max(maxRelevantLineLength, line.length);
488
+
489
+ const indentMatch = line.match(/^([ \t]+)/);
490
+ if (!indentMatch) {
491
+ continue;
492
+ }
493
+ const indent = indentMatch[1];
494
+ const usesTabs = indent.includes('\t');
495
+ const usesSpaces = indent.includes(' ');
496
+ hasTabIndent = hasTabIndent || usesTabs;
497
+ hasSpaceIndent = hasSpaceIndent || usesSpaces;
498
+ hasMixedIndentLine = hasMixedIndentLine || (usesTabs && usesSpaces);
499
+
500
+ if (!usesTabs) {
501
+ spaceIndentLengths.push(indent.length);
502
+ }
503
+ }
504
+
505
+ if (hasMixedIndentLine || (hasTabIndent && hasSpaceIndent)) {
506
+ issues.push('mixed indentation');
507
+ } else if (!hasTabIndent && spaceIndentLengths.length) {
508
+ const uses2SpaceStyle = spaceIndentLengths.every(indent => indent % 2 === 0);
509
+ const uses4SpaceStyle = spaceIndentLengths.every(indent => indent % 4 === 0);
510
+ if (!uses2SpaceStyle && !uses4SpaceStyle) {
511
+ issues.push('inconsistent indentation');
512
+ }
513
+ }
514
+
515
+ const sanitizedContent = stripStringsAndCommentsPreserveLines(content);
516
+ const structuralTokenCount = (sanitizedContent.match(/[{}[\],]/g) || []).length;
517
+ const looksMinified =
518
+ (relevantLineCount <= 1 && structuralTokenCount >= 8) ||
519
+ (relevantLineCount <= 3 && structuralTokenCount >= 20 && maxRelevantLineLength >= 160);
520
+ if (looksMinified) {
521
+ issues.push('too few line breaks');
522
+ }
523
+
524
+ return issues;
525
+ }
526
+
389
527
  async function checkCode(context) {
390
528
  console.log('\n[E5000 - E5999] checkCode');
391
529
 
@@ -415,6 +553,8 @@ async function checkCode(context) {
415
553
  '/src-admin/package.json', // check if react is used
416
554
  '/src-widgets/package.json', // check if react is used
417
555
  '/src/package.json', // check if react is used
556
+
557
+ '/tsconfig.json', // read to extract path aliases (pseudo-organisations)
418
558
  ];
419
559
 
420
560
  context.cfg.allowedLanguages.forEach(lang => readFiles.push(`/admin/i18n/${lang}/translations.json`));
@@ -460,6 +600,24 @@ async function checkCode(context) {
460
600
  }
461
601
  });
462
602
 
603
+ // Add all JSON files (.json, .json5) to readFiles for formatting validation
604
+ const excludeDirsForJson = ['node_modules', '.git', '.vscode', '.dev-server'];
605
+
606
+ tempFilesList.forEach(filePath => {
607
+ const pathParts = filePath.split('/').filter(part => part !== '');
608
+ const isInExcludedDir = pathParts.some(part => excludeDirsForJson.includes(part));
609
+
610
+ if (!isInExcludedDir) {
611
+ const ext = path.extname(filePath);
612
+ if (jsonExtensions.includes(ext)) {
613
+ const normalizedPath = filePath.startsWith('/') ? filePath : `/${filePath}`;
614
+ if (!readFiles.includes(normalizedPath)) {
615
+ readFiles.push(normalizedPath);
616
+ }
617
+ }
618
+ }
619
+ });
620
+
463
621
  // Add all YAML files (.yml, .yaml) to readFiles for validation
464
622
  const excludeDirsForYaml = ['node_modules', '.git', '.vscode', '.dev-server'];
465
623
 
@@ -610,7 +768,6 @@ async function checkCode(context) {
610
768
 
611
769
  // Check for conflicting JSON file extensions in the same directory
612
770
  // E5038: Files with the same base name but different extensions (.json, .json5) in the same directory
613
- const jsonExtensions = ['.json', '.json5'];
614
771
  const jsonFilesByDirectory = new Map();
615
772
 
616
773
  // Group files by directory and base name
@@ -666,6 +823,28 @@ async function checkCode(context) {
666
823
  }
667
824
  }
668
825
 
826
+ // Check selected JSON and JSON5 files for human-readable formatting
827
+ for (const fileName of Object.keys(context)) {
828
+ if (fileName.startsWith('/') && typeof context[fileName] === 'string') {
829
+ const ext = path.extname(fileName);
830
+ const isRelevantJsonFile =
831
+ fileName === '/package.json' ||
832
+ fileName === '/io-package.json' ||
833
+ /^\/admin\/[^/]+\.(json|json5)$/i.test(fileName);
834
+ if (jsonExtensions.includes(ext) && isRelevantJsonFile) {
835
+ const isJson5File = ext === '.json5';
836
+ const issues = analyzeJsonFormatting(context[fileName], isJson5File);
837
+ if (issues.length) {
838
+ context.warnings.push(
839
+ `[W5063] JSON formatting in "${fileName.slice(1)}" is hard to read (${issues.join(
840
+ ', ',
841
+ )}). Please use consistent indentation and proper line breaks.`,
842
+ );
843
+ }
844
+ }
845
+ }
846
+ }
847
+
669
848
  let usesReact = false;
670
849
  if (
671
850
  context.packageJson.devDependencies &&
@@ -901,21 +1080,12 @@ async function checkCode(context) {
901
1080
 
902
1081
  // Check if admin/jsonConfig.json or admin/jsonConfig.json5 exists but common.adminUI.config is not set to "json" (W5046)
903
1082
  if (
904
- (context.filesList.includes('/admin/jsonConfig.json') ||
905
- context.filesList.includes('/admin/jsonConfig.json5')) &&
906
- context.ioPackageJson.common.adminUI &&
907
- context.ioPackageJson.common.adminUI.config === 'materialize'
908
- ) {
909
- context.errors.push(
910
- '[E5046] Using admin/jsonConfig.json(5) requires common.adminUI to be set to "common.adminUI": { "config": "json" }.',
911
- );
912
- } else if (
913
1083
  (context.filesList.includes('/admin/jsonConfig.json') ||
914
1084
  context.filesList.includes('/admin/jsonConfig.json5')) &&
915
1085
  !(context.ioPackageJson.common.adminUI && context.ioPackageJson.common.adminUI.config === 'json')
916
1086
  ) {
917
1087
  context.warnings.push(
918
- '[W5046] Using admin/jsonConfig.json(5) requires common.adminUI to be set to "common.adminUI": { "config": "json" }.',
1088
+ '[W5046] Using admin/jsonConfig.json(5) requires common.adminUI.config to be set to "json".',
919
1089
  );
920
1090
  }
921
1091
 
@@ -952,7 +1122,7 @@ async function checkCode(context) {
952
1122
  }
953
1123
  } else {
954
1124
  context.errors.push(
955
- `[E5012] "/admin/jsonCustom.json${context['/admin/jsonCustom.json'] ? '' : '5'}" not found, but custom support is declared`,
1125
+ `[E5012] Neither "/admin/jsonCustom.json" nor "/admin/jsonCustom.json5" found, but custom support is declared`,
956
1126
  );
957
1127
  }
958
1128
  }
@@ -988,6 +1158,14 @@ async function checkCode(context) {
988
1158
  }
989
1159
  }
990
1160
 
1161
+ // Check if admin/jsonTab.json or admin/jsonTab.json5 exists but common.adminUI.tab is not set to "json" (W5064)
1162
+ if (
1163
+ (context.filesList.includes('/admin/jsonTab.json') || context.filesList.includes('/admin/jsonTab.json5')) &&
1164
+ !(context.ioPackageJson.common.adminUI && context.ioPackageJson.common.adminUI.tab === 'json')
1165
+ ) {
1166
+ context.warnings.push('[W5064] Using admin/jsonTab.json(5) requires common.adminUI.tab to be set to "json".');
1167
+ }
1168
+
991
1169
  // Validate all present jsonConfig files against the jsonConfig schema
992
1170
  const jsonConfigFilesToValidate = [
993
1171
  '/admin/jsonConfig.json',
@@ -1062,6 +1240,46 @@ async function checkCode(context) {
1062
1240
  }
1063
1241
  }
1064
1242
 
1243
+ // Check for table/accordion components with encryptedAttributes requiring js-controller >= 7.0.7
1244
+ if (
1245
+ context.ioPackageJson.common &&
1246
+ context.ioPackageJson.common.adminUI &&
1247
+ context.ioPackageJson.common.adminUI.config === 'json'
1248
+ ) {
1249
+ const encryptedAttrLocations = [];
1250
+
1251
+ for (const adminFile of context.filesList) {
1252
+ if (!/^\/admin\/.+\.json5?$/.test(adminFile) || typeof context[adminFile] !== 'string') {
1253
+ continue;
1254
+ }
1255
+
1256
+ try {
1257
+ const parsed = adminFile.endsWith('.json5')
1258
+ ? JSON5.parse(context[adminFile])
1259
+ : JSON.parse(context[adminFile]);
1260
+ collectJsonConfigEncryptedAttributeComponents(parsed, encryptedAttrLocations, {
1261
+ filePath: adminFile.replace(/^\//, ''),
1262
+ pathInFile: '$',
1263
+ });
1264
+ } catch (e) {
1265
+ common.debug(`Skipping encryptedAttributes scan for ${adminFile}: ${e.message}`);
1266
+ }
1267
+ }
1268
+
1269
+ if (encryptedAttrLocations.length > 0) {
1270
+ const requiredVersion = '7.0.7';
1271
+ const currentVersion = context.currentJsControllerVersion;
1272
+ // Only warn when a js-controller version is declared but is below the required minimum.
1273
+ // When the dependency is missing entirely, E1062 from M1000 already covers that case.
1274
+ if (currentVersion && compareVersions.compare(requiredVersion, currentVersion, '>')) {
1275
+ const locationList = encryptedAttrLocations.join(', ');
1276
+ context.warnings.push(
1277
+ `[W5062] jsonConfig uses "encryptedAttributes" in table/accordion (${locationList}). js-controller >= ${requiredVersion} is required for encrypted object support.`,
1278
+ );
1279
+ }
1280
+ }
1281
+ }
1282
+
1065
1283
  if (context.ioPackageJson.common.blockly && !context['/admin/blockly.js']) {
1066
1284
  context.errors.push('[E5014] "/admin/blockly.js" not found, but blockly support is declared');
1067
1285
  }
@@ -1100,8 +1318,11 @@ async function checkCode(context) {
1100
1318
  );
1101
1319
  }
1102
1320
 
1103
- if (context['/.travis.yml']) {
1321
+ if (context['/.travis.yml'] || context.filesList.includes('/.travis.yml')) {
1104
1322
  context.hasTravis = true;
1323
+ context.warnings.push(
1324
+ '[S5065] ".travis.yml" was found. This file is most likely obsolete and can be removed after verifying that travis is no longer used.',
1325
+ );
1105
1326
  }
1106
1327
 
1107
1328
  if (context['/gulpfile.js']) {
@@ -1151,8 +1372,8 @@ async function checkCode(context) {
1151
1372
  const version = context.packageJson.devDependencies['@alcalzone/release-script'];
1152
1373
  if (compareVersions.compareVersions(version, '3.0.0') >= 0) {
1153
1374
  if (!context['/.releaseconfig.json']) {
1154
- context.errors.push(
1155
- '[E5018] "@alcalzone/release-script" (>=3.0.0) is used, but ".releaseconfig.json" not found. Please create.',
1375
+ context.warnings.push(
1376
+ '[W5018] "@alcalzone/release-script" (>=3.0.0) is used, but ".releaseconfig.json" not found. Please create.',
1156
1377
  );
1157
1378
  } else {
1158
1379
  common.debug(`context[/.releaseconfig.json: ${context['/.releaseconfig.json']}`);
@@ -1242,38 +1463,6 @@ async function checkCode(context) {
1242
1463
  `[E5019] "${context.packageJson.main}" found in package.json, but not found as file. Please commit "build/*" tree to github or set "common.noGit" attribute to true at io-package.json.`,
1243
1464
  );
1244
1465
  }
1245
- } else {
1246
- if (
1247
- context[`/${context.packageJson.main}`].includes('setInterval(') &&
1248
- !context[`/${context.packageJson.main}`].includes('clearInterval(')
1249
- ) {
1250
- if (context.ioPackageJson.common.compact) {
1251
- // if compact mode supported, it is critical
1252
- context.errors.push(
1253
- `[E5004] setInterval found in "${context.packageJson.main}", but no clearInterval detected`,
1254
- );
1255
- } else {
1256
- context.warnings.push(
1257
- `[W5004] setInterval found in "${context.packageJson.main}", but no clearInterval detected`,
1258
- );
1259
- }
1260
- }
1261
- if (
1262
- context[`/${context.packageJson.main}`].includes('setTimeout(') &&
1263
- !context[`/${context.packageJson.main}`].includes('clearTimeout(')
1264
- ) {
1265
- if (context.ioPackageJson.common.compact) {
1266
- // if compact mode supported, it is critical
1267
- // context.errors.push(`[E5005] setTimeout found in "${context.packageJson.main}", but no clearTimeout detected`);
1268
- context.warnings.push(
1269
- `[W5005] setTimeout found in "${context.packageJson.main}", but no clearTimeout detected`,
1270
- );
1271
- } else {
1272
- context.warnings.push(
1273
- `[W5005] setTimeout found in "${context.packageJson.main}", but no clearTimeout detected`,
1274
- );
1275
- }
1276
- }
1277
1466
  }
1278
1467
  }
1279
1468
 
@@ -1561,6 +1750,31 @@ async function checkCode(context) {
1561
1750
  // Packages known to be provided by the js-controller/system and therefore not required as dependencies
1562
1751
  const systemProvidedPackages = new Set(['@iobroker/plugin-sentry']);
1563
1752
 
1753
+ // Extract path alias prefixes from tsconfig.json compilerOptions.paths.
1754
+ // These are local path aliases (pseudo-organisations) that should be treated like local files
1755
+ // and ignored during dependency checks (e.g. "@backend" from "@backend/*": ["src/*"]).
1756
+ const tsConfigPathAliasPrefixes = new Set();
1757
+ const tsConfigContent = context['/tsconfig.json'];
1758
+ if (tsConfigContent) {
1759
+ try {
1760
+ const tsConfig = JSON5.parse(String(tsConfigContent));
1761
+ const tsPaths = tsConfig?.compilerOptions?.paths;
1762
+ if (tsPaths && typeof tsPaths === 'object') {
1763
+ for (const key of Object.keys(tsPaths)) {
1764
+ // Extract the first path segment (before the first '/') as the alias prefix.
1765
+ // Also strip any trailing wildcard '*' to handle both "@backend/*" and "@backend*".
1766
+ // E.g. "@backend/*" → "@backend", "@backend*" → "@backend", "someModule" → "someModule"
1767
+ const firstSegment = key.split('/')[0].replace(/\*$/, '');
1768
+ if (firstSegment) {
1769
+ tsConfigPathAliasPrefixes.add(firstSegment);
1770
+ }
1771
+ }
1772
+ }
1773
+ } catch {
1774
+ // Ignore parse errors - tsconfig.json validity is checked elsewhere
1775
+ }
1776
+ }
1777
+
1564
1778
  // W5042/S5043: Scan source files for require/import statements and check dependencies
1565
1779
  // Exclude files in admin/, build/, doc/, docs/, src-admin/, admin-src/, test/ directories
1566
1780
  // and *.test.* and *.config.* files
@@ -1585,6 +1799,7 @@ async function checkCode(context) {
1585
1799
  '.git',
1586
1800
  '.vscode',
1587
1801
  '.dev-server',
1802
+ 'hass_frontend', // special for ioBroker.hass
1588
1803
  ]);
1589
1804
  // Exact file base names to exclude from scanning
1590
1805
  const excludedSourceFiles = new Set(['tasks.js', 'tasks.ts', 'Gruntfile.js', 'gulpfile.js']);
@@ -1595,7 +1810,10 @@ async function checkCode(context) {
1595
1810
  const packageDependencies = context.packageJson.dependencies || {};
1596
1811
  const packageDevDependencies = context.packageJson.devDependencies || {};
1597
1812
  const usedPackageDependencies = new Set();
1813
+ const usedImportedPackages = new Set();
1598
1814
  const implicitRuntimeDependencies = new Set();
1815
+ const optionalDependencyComments = new Set();
1816
+ const usedOptionalDependencies = new Set();
1599
1817
 
1600
1818
  if (context.ioPackageJson.common.plugins && typeof context.ioPackageJson.common.plugins === 'object') {
1601
1819
  for (const pluginName of Object.keys(context.ioPackageJson.common.plugins)) {
@@ -1617,6 +1835,14 @@ async function checkCode(context) {
1617
1835
  // Track files containing a sleep/wait function implementation for S5051 check
1618
1836
  const sleepFiles = [];
1619
1837
 
1838
+ // Track files with bare setInterval() for S5004 check (not this.setInterval or adapter.setInterval)
1839
+ const setIntervalFiles = [];
1840
+
1841
+ // Track files with bare setTimeout() for S5005 check (not this.setTimeout or adapter.setTimeout)
1842
+ const setTimeoutFiles = [];
1843
+ let hasClearInterval = false;
1844
+ let hasClearTimeout = false;
1845
+
1620
1846
  for (const filePath of Object.keys(context)) {
1621
1847
  if (!filePath.startsWith('/') || typeof context[filePath] !== 'string') {
1622
1848
  continue;
@@ -1651,6 +1877,11 @@ async function checkCode(context) {
1651
1877
 
1652
1878
  common.debug(`Scanning "${filePath.slice(1)}" for dependencies`);
1653
1879
 
1880
+ const optionalDependencies = extractOptionalDependencies(context[filePath]);
1881
+ for (const optionalDependency of optionalDependencies) {
1882
+ optionalDependencyComments.add(optionalDependency);
1883
+ }
1884
+
1654
1885
  // E5049/W5049: Check for process.env usage (after stripping comments to avoid false positives)
1655
1886
  const contentWithoutComments = stripComments(context[filePath]);
1656
1887
  if (/\bprocess\.env\b/.test(contentWithoutComments)) {
@@ -1668,6 +1899,24 @@ async function checkCode(context) {
1668
1899
  sleepFiles.push(filePath.slice(1));
1669
1900
  }
1670
1901
 
1902
+ // S5004/W5004: Check for bare setInterval() — negative lookbehind excludes this.setInterval / adapter.setInterval
1903
+ if (/(?<![.\w])setInterval\s*\(/.test(contentWithoutComments)) {
1904
+ const file = filePath.slice(1);
1905
+ setIntervalFiles.push(file);
1906
+ }
1907
+ if (/clearInterval\s*\(/.test(contentWithoutComments)) {
1908
+ hasClearInterval = true;
1909
+ }
1910
+
1911
+ // S5005/W5005: Check for bare setTimeout() — negative lookbehind excludes this.setTimeout / adapter.setTimeout
1912
+ if (/(?<![.\w])setTimeout\s*\(/.test(contentWithoutComments)) {
1913
+ const file = filePath.slice(1);
1914
+ setTimeoutFiles.push(file);
1915
+ }
1916
+ if (/clearTimeout\s*\(/.test(contentWithoutComments)) {
1917
+ hasClearTimeout = true;
1918
+ }
1919
+
1671
1920
  const imports = extractImports(context[filePath]);
1672
1921
 
1673
1922
  for (const importTarget of imports) {
@@ -1676,7 +1925,8 @@ async function checkCode(context) {
1676
1925
  // Skip relative paths (./xxx, ../xxx) and absolute paths (/xxx)
1677
1926
  // Skip dynamic generated strings (`${xxx}`) and debug vars
1678
1927
  if (
1679
- importTarget.startsWith('.') ||
1928
+ importTarget.startsWith('./') ||
1929
+ importTarget.startsWith('../') ||
1680
1930
  importTarget.startsWith('/') ||
1681
1931
  importTarget.includes('~') || // '~debug~xx'
1682
1932
  importTarget.includes('$') || // `${myvar}/xxx`
@@ -1687,22 +1937,33 @@ async function checkCode(context) {
1687
1937
  }
1688
1938
 
1689
1939
  // Skip obvious filenames
1690
- if (
1691
- importTarget.endsWith('.js') ||
1692
- importTarget.endsWith('.mjs') ||
1693
- importTarget.endsWith('.cjs') ||
1694
- importTarget.endsWith('.ts')
1695
- ) {
1696
- continue;
1697
- }
1940
+ // NOTE: ical.js is a legal package name.
1941
+ // if (
1942
+ // importTarget.endsWith('.js') ||
1943
+ // importTarget.endsWith('.mjs') ||
1944
+ // importTarget.endsWith('.cjs') ||
1945
+ // importTarget.endsWith('.ts')
1946
+ // ) {
1947
+ // continue;
1948
+ // }
1698
1949
 
1699
1950
  // Skip node: prefixed built-ins - check is complete
1700
1951
  if (importTarget.startsWith('node:')) {
1701
1952
  continue;
1702
1953
  }
1703
1954
 
1955
+ // Skip path alias pseudo-organisations defined in tsconfig.json compilerOptions.paths.
1956
+ // These are local aliases (e.g. "@backend/blabla" when "@backend/*" is defined in paths,
1957
+ // or "myAlias" when "myAlias" is defined as an exact alias) and should be treated like
1958
+ // local files.
1959
+ const importFirstSegment = importTarget.split('/')[0];
1960
+ if (tsConfigPathAliasPrefixes.has(importFirstSegment)) {
1961
+ continue;
1962
+ }
1963
+
1704
1964
  // Extract base package name (handles scoped packages and subpath imports)
1705
1965
  const packageName = extractPackageName(importTarget);
1966
+ usedImportedPackages.add(packageName);
1706
1967
 
1707
1968
  // Skip if already reported for this package
1708
1969
  if (reportedDependencyIssues.has(packageName)) {
@@ -1739,6 +2000,9 @@ async function checkCode(context) {
1739
2000
  context.warnings.push(
1740
2001
  `[S5043] Package "${packageName}" is a built-in Node.js module. Please use "node:${packageName}" instead.`,
1741
2002
  );
2003
+ } else if (optionalDependencyComments.has(packageName)) {
2004
+ usedOptionalDependencies.add(packageName);
2005
+ continue;
1742
2006
  } else {
1743
2007
  context.warnings.push(
1744
2008
  `[W5042] Package "${packageName}" is used in source file(s) (${filePath.slice(1)}) but not found in dependencies of package.json. Dependency might be missing.`,
@@ -1789,6 +2053,39 @@ async function checkCode(context) {
1789
2053
  );
1790
2054
  }
1791
2055
 
2056
+ const formatSuggestionFileList = files =>
2057
+ files.length > 2 ? `${files.slice(0, 2).join(', ')}, ...` : files.join(', ');
2058
+
2059
+ // S5004/W5004: Report bare setInterval() usage and missing clearInterval() separately
2060
+ if (setIntervalFiles.length > 0) {
2061
+ const fileList = formatSuggestionFileList(setIntervalFiles);
2062
+ context.warnings.push(
2063
+ `[S5004] Plain setInterval() found in source files (${fileList}). Please use this.setInterval() or adapter.setInterval() instead.`,
2064
+ );
2065
+ }
2066
+
2067
+ if (setIntervalFiles.length > 0 && !hasClearInterval) {
2068
+ const fileList = setIntervalFiles.join(', ');
2069
+ context.warnings.push(
2070
+ `[W5004] setInterval() found in source files (${fileList}) but no clearInterval() detected.`,
2071
+ );
2072
+ }
2073
+
2074
+ // S5005/W5005: Report bare setTimeout() usage and missing clearTimeout() separately
2075
+ if (setTimeoutFiles.length > 0) {
2076
+ const fileList = formatSuggestionFileList(setTimeoutFiles);
2077
+ context.warnings.push(
2078
+ `[S5005] Plain setTimeout() found in source files (${fileList}). Please use this.setTimeout() or adapter.setTimeout() instead.`,
2079
+ );
2080
+ }
2081
+
2082
+ if (setTimeoutFiles.length > 0 && !hasClearTimeout) {
2083
+ const fileList = setTimeoutFiles.join(', ');
2084
+ context.warnings.push(
2085
+ `[W5005] setTimeout() found in source files (${fileList}) but no clearTimeout() detected.`,
2086
+ );
2087
+ }
2088
+
1792
2089
  for (const dependency of Object.keys(packageDependencies)) {
1793
2090
  if (usedPackageDependencies.has(dependency) || implicitRuntimeDependencies.has(dependency)) {
1794
2091
  continue;
@@ -1799,6 +2096,26 @@ async function checkCode(context) {
1799
2096
  );
1800
2097
  }
1801
2098
 
2099
+ for (const optionalDependency of optionalDependencyComments) {
2100
+ if (packageDependencies[optionalDependency]) {
2101
+ context.warnings.push(
2102
+ `[W5064] Optional dependency comment for package "${optionalDependency}" is invalid because the package is already listed in dependencies of package.json.`,
2103
+ );
2104
+ continue;
2105
+ }
2106
+ if (!usedImportedPackages.has(optionalDependency)) {
2107
+ context.warnings.push(
2108
+ `[W5065] Optional dependency comment for package "${optionalDependency}" is ignored because the package is not imported or required by any scanned source file.`,
2109
+ );
2110
+ continue;
2111
+ }
2112
+ if (usedOptionalDependencies.has(optionalDependency)) {
2113
+ context.warnings.push(
2114
+ `[S5066] Package "${optionalDependency}" is declared as an optional dependency via source comment and is used in source files, but is not listed in dependencies of package.json. It might be missing on target systems.`,
2115
+ );
2116
+ }
2117
+ }
2118
+
1802
2119
  // 5500 - xxx reserved for jsonConfig module
1803
2120
 
1804
2121
  // 5600 - 5699: comprehensive i18n checks across the full repository
@@ -1817,11 +2134,10 @@ exports.getFilesList = getFilesList;
1817
2134
  // [5001] Cannot get ${context.branch}.zip on github
1818
2135
  // [5002] "admin/img/info-big.png" not found, but selectID.js used in index_m.html
1819
2136
  // [5003] File "${file}" found in repo! Please remove file.
1820
- // [5004] setInterval found in "${context.packageJson.main}", but no clearInterval detected
1821
- // [5004] setInterval found in "${context.packageJson.main}", but no clearInterval detected
1822
- // [5005] setTimeout found in "${context.packageJson.main}", but no clearTimeout detected
1823
- // [5005] setTimeout found in "${context.packageJson.main}", but no clearTimeout detected
1824
- // [5005] setTimeout found in "${context.packageJson.main}", but no clearTimeout detected
2137
+ // [S5004] Plain setInterval() found in source files (${fileList}). Please use this.setInterval() or adapter.setInterval() instead.
2138
+ // [W5004] setInterval() found in source files (${fileList}) but no clearInterval() detected.
2139
+ // [S5005] Plain setTimeout() found in source files (${fileList}). Please use this.setTimeout() or adapter.setTimeout() instead.
2140
+ // [W5005] setTimeout() found in source files (${fileList}) but no clearTimeout() detected.
1825
2141
  // [5006] More non translated in german or russian words found in admin/words.js. You can use https://translator.iobroker.in/ for translations
1826
2142
  // [5006] Word "${word}" is not translated to german in admin/words.js. You can use https://translator.iobroker.in/ for translations
1827
2143
  // [5006] Word "${word}" is not translated to russian in admin/words.js. You can use https://translator.iobroker.in/ for translations
@@ -1865,7 +2181,7 @@ exports.getFilesList = getFilesList;
1865
2181
  // [S5043] Package "${packageName}" is a built-in Node.js module. Please use "node:${packageName}" prefix instead.
1866
2182
  // [E5044] Cannot parse "/admin/jsonTab.json[5]": ${e}
1867
2183
  // [E5045] "/admin/jsonTab.json[5]" not found, but tab support is declared
1868
- // [W5046] "admin/jsonConfig.json" or "admin/jsonConfig.json5" found but "common.adminUI.config" is not set to "json" in io-package.json. Please add "common.adminUI": { "config": "json" }.
2184
+ // [W5046] Using admin/jsonConfig.json(5) requires common.adminUI.config to be set to "json".
1869
2185
  // [W5047] "${file}" is most likely outdated since jsonConfig is used. Please consider removing it.
1870
2186
  // [W5048] "${file}" is most likely obsolete when using "@iobroker/eslint-config". Please remove it.
1871
2187
  // [E5049] process.env is used in source files (${fileList}). process.env is incompatible with compact mode. Please use adapter configuration instead.
@@ -1883,7 +2199,14 @@ exports.getFilesList = getFilesList;
1883
2199
  // [W5059] Adapter uses class mode ("class ... extends utils.Adapter") in "${context.packageJson.main}" and also uses "utils.adapter(...)" in source file(s): ${fileList}. Please use only one adapter pattern.
1884
2200
  // [W5060] Package "${dependency}" is listed in dependencies of package.json but not imported or required by any scanned source file. Dependency might be unused.
1885
2201
  // [W5061] "utils.commonTools.letsEncrypt" usage detected. Let's Encrypt support was removed in js-controller 6.
2202
+ // [W5062] jsonConfig uses "encryptedAttributes" in table/accordion (${locationList}). js-controller >= 7.0.7 is required for encrypted object support.
2203
+ // [W5064] Optional dependency comment for package "${packageName}" is invalid because the package is already listed in dependencies of package.json.
2204
+ // [W5065] Optional dependency comment for package "${packageName}" is ignored because the package is not imported or required by any scanned source file.
2205
+ // [S5066] Package "${packageName}" is declared as an optional dependency via source comment and is used in source files, but is not listed in dependencies of package.json. It might be missing on target systems.
2206
+ // [W5063] JSON formatting in "${fileName}" is hard to read (${issues}). Please use consistent indentation and proper line breaks.
1886
2207
  // [W5054] method "setObject()" should be avoided. Please use "setObjectNotExists()" or "extendObject()" instead.
1887
2208
  // [W5515] Schema validation skipped for "${configFile}" due to parse error: ${e.message}
2209
+ // [W5064] Using admin/jsonTab.json(5) requires common.adminUI.tab to be set to "json".
2210
+ // [S5065] ".travis.yml" was found. This file is most likely obsolete and can be removed after verifying that travis is no longer used.
1888
2211
 
1889
2212
  // [5500 - ] see M5500_jsonConfig.js
@@ -144,6 +144,7 @@ const validComponents = {
144
144
 
145
145
  number: { function: check_number, minAdmin: DEFAULT_MIN_ADMIN },
146
146
 
147
+ oauth2: { function: check_oauth2, minAdmin: '7.8.9' },
147
148
  objectId: { function: check_objectId, minAdmin: DEFAULT_MIN_ADMIN },
148
149
 
149
150
  password: { function: check_password, minAdmin: DEFAULT_MIN_ADMIN },
@@ -446,6 +447,11 @@ function check_number(context, path, jsonConfig, _inTable) {
446
447
  chk_responsive(context, path, jsonConfig, 'number');
447
448
  }
448
449
 
450
+ function check_oauth2(context, path, jsonConfig, _inTable) {
451
+ common.debug(`check_oauth2 ${path}`);
452
+ chk_responsive(context, path, jsonConfig, 'oauth2');
453
+ }
454
+
449
455
  function check_objectId(context, path, jsonConfig, _inTable) {
450
456
  common.debug(`check_objectId ${path}`);
451
457
  chk_responsive(context, path, jsonConfig, 'objectId');
@@ -470,24 +470,29 @@ function checkJsonConfigTranslations(context, configFile, jsonConfig, i18nDir, w
470
470
  if (noTranslation) {
471
471
  continue;
472
472
  }
473
-
473
+ // console.log('');
474
+ // console.log(`${path} - ${attr}:`);
475
+ // console.log(`type: ${typeof value} - ${JSON.stringify(value)}`);
474
476
  if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
475
477
  if (isSelectOptionLabel || i18nMode === false) {
476
478
  // When i18n=false, or for select-option labels regardless of i18n mode,
477
479
  // all inline i18n objects must be complete.
478
- for (const lang of requiredLanguages) {
479
- if (!Object.prototype.hasOwnProperty.call(value, lang)) {
480
- context.errors.push(
481
- `[E5610] "${path}" attribute "${attr}" is missing required language "${lang}" in i18n object.`,
482
- );
483
- }
480
+ const missingRequiredLanguages = requiredLanguages.filter(
481
+ lang => !Object.prototype.hasOwnProperty.call(value, lang),
482
+ );
483
+ if (missingRequiredLanguages.length > 0) {
484
+ context.errors.push(
485
+ `[E5610] "${path}" attribute "${attr}" is missing required language(s) "${missingRequiredLanguages.join('", "')}" in i18n object.`,
486
+ );
484
487
  }
485
- for (const lang of allowedLanguages) {
486
- if (!requiredLanguages.includes(lang) && !Object.prototype.hasOwnProperty.call(value, lang)) {
487
- context.warnings.push(
488
- `[W5611] "${path}" attribute "${attr}" is missing language "${lang}" in i18n object.`,
489
- );
490
- }
488
+
489
+ const missingOptionalLanguages = allowedLanguages.filter(
490
+ lang => !requiredLanguages.includes(lang) && !Object.prototype.hasOwnProperty.call(value, lang),
491
+ );
492
+ if (missingOptionalLanguages.length > 0) {
493
+ context.warnings.push(
494
+ `[W5611] "${path}" attribute "${attr}" is missing language(s) "${missingOptionalLanguages.join('", "')}" in i18n object.`,
495
+ );
491
496
  }
492
497
  continue;
493
498
  }
@@ -287,6 +287,29 @@ function getMaxYearFromText(text) {
287
287
  return allYears.length > 0 ? Math.max(...allYears) : 0;
288
288
  }
289
289
 
290
+ function findLicenseHeaderMatch(text) {
291
+ return /^##[ \t]+license[ \t]*$/im.exec(text);
292
+ }
293
+
294
+ function findH2Section(text, sectionName) {
295
+ const escapedSectionName = escapeRegExp(sectionName);
296
+ const headerRegex = new RegExp(`^##[ \\t]+${escapedSectionName}[ \\t]*$`, 'im');
297
+ const headerMatch = headerRegex.exec(text);
298
+ if (!headerMatch) {
299
+ return '';
300
+ }
301
+
302
+ const sectionStart = headerMatch.index + headerMatch[0].length;
303
+ const sectionTail = text.slice(sectionStart);
304
+ const nextHeaderMatch = /^##[ \t]+/m.exec(sectionTail);
305
+ const sectionEnd = nextHeaderMatch ? sectionStart + nextHeaderMatch.index : text.length;
306
+ return text.slice(sectionStart, sectionEnd).replace(/^\r?\n/, '');
307
+ }
308
+
309
+ function normalizeVersion(version) {
310
+ return (version || '').trim().replace(/^v/i, '');
311
+ }
312
+
290
313
  // Adapters that are allowed to have a CHANGELOG.md instead of keeping the changelog in README.md
291
314
  const CHANGELOG_MD_ALLOW_LIST = ['js-controller', 'admin'];
292
315
 
@@ -343,33 +366,84 @@ async function checkReadme(context) {
343
366
  }
344
367
  }
345
368
 
346
- if (!data.includes('## Changelog')) {
369
+ const changelogSection = findH2Section(data, 'changelog');
370
+ if (!/^##[ \t]+changelog[ \t]*$/im.test(data)) {
347
371
  context.errors.push('[E6003] NO "## Changelog" found in README.md');
348
372
  } else {
349
373
  context.checks.push('README.md contains Changelog');
374
+ const changelogHeaders = [...changelogSection.matchAll(/^###\s+(.+)$/gm)].map(match => match[1].trim());
375
+ const changelogVersions = [];
350
376
 
351
- if (!data.includes(`### ${context.packageJson.version}`)) {
352
- if (!common.isAlphaVersion(context.packageJson.version)) {
353
- context.errors.push(
354
- `[E6006] Current adapter version ${context.packageJson.version} not found in README.md`,
355
- );
356
- } else {
377
+ if (changelogHeaders.length === 0) {
378
+ context.errors.push(
379
+ '[E6026] Changelog section in README.md contains no "###" entries. The newest changes must be documented in README changelog using the standard format.',
380
+ );
381
+ } else {
382
+ context.checks.push('README.md changelog contains "###" entries');
383
+ const invalidVersionHeaders = [];
384
+ for (const header of changelogHeaders) {
385
+ const match = /^(\d+\.\d+\.\d+)(?:\s+.*)?$/.exec(header);
386
+ if (!match) {
387
+ if (!header.includes('WORK IN PROGRESS')) {
388
+ invalidVersionHeaders.push(header);
389
+ }
390
+ } else {
391
+ changelogVersions.push(normalizeVersion(match[1]));
392
+ }
393
+ }
394
+ if (invalidVersionHeaders.length) {
357
395
  context.warnings.push(
358
- `[S6008] Changelog for version ${context.packageJson.version} should be added to README.md.`,
396
+ `[W6028] Changelog entry header(s) do not match required version format "x.y.z": ${invalidVersionHeaders.join(', ')}`,
359
397
  );
398
+ } else {
399
+ context.checks.push('All changelog "###" headers use valid version format');
360
400
  }
401
+ }
402
+
403
+ //if (!/^\s*[-*]\s+\([^)]+\)\s+.+$/m.test(changelogSection)) {
404
+ if (!/^\s*[-*]\s+.+$/m.test(changelogSection)) {
405
+ context.warnings.push(
406
+ '[W6027] Changelog section in README.md should contain at least one entry in format "- text" or "* text".',
407
+ );
361
408
  } else {
362
- context.checks.push('README.md contains current adapter version');
409
+ context.checks.push('README.md changelog contains at least one standard bullet entry');
410
+ }
411
+
412
+ const latestNpmVersion = normalizeVersion(context.npmLatestVersion);
413
+ if (latestNpmVersion && !changelogVersions.includes(latestNpmVersion)) {
414
+ context.errors.push(
415
+ `[E6029] Changelog section in README.md has no entry for npm latest version ${latestNpmVersion}.`,
416
+ );
417
+ } else if (latestNpmVersion) {
418
+ context.checks.push(`README.md changelog contains npm latest version ${latestNpmVersion}`);
419
+ }
420
+
421
+ const currentIoPackageVersion = normalizeVersion(context.ioPackageJson?.common?.version);
422
+ if (currentIoPackageVersion && !changelogVersions.includes(currentIoPackageVersion)) {
423
+ context.warnings.push(
424
+ `[W6030] Changelog section in README.md should contain an entry for io-package.json version ${currentIoPackageVersion}.`,
425
+ );
426
+ } else if (currentIoPackageVersion) {
427
+ context.checks.push(`README.md changelog contains io-package.json version ${currentIoPackageVersion}`);
363
428
  }
364
429
 
365
- // Count the number of version entries (### headers) in the Changelog section
366
- const changelogStart = data.indexOf('## Changelog');
367
- const afterChangelog = data.substring(changelogStart + '## Changelog'.length);
368
- const nextSectionMatch = afterChangelog.match(/\n## /);
369
- const changelogSection = nextSectionMatch
370
- ? afterChangelog.substring(0, nextSectionMatch.index)
371
- : afterChangelog;
372
- const versionEntryCount = (changelogSection.match(/^###\s+/gm) || []).length;
430
+ const newsVersions = Object.keys(context.ioPackageJson?.common?.news || {}).map(normalizeVersion);
431
+ const missingNewsVersions = newsVersions.filter(version => version && !changelogVersions.includes(version));
432
+ if (missingNewsVersions.length > 0) {
433
+ context.errors.push(
434
+ `[E6031] Changelog section in README.md is missing entry/entries for version(s) from io-package.json news: ${missingNewsVersions.join(', ')}.`,
435
+ );
436
+ } else if (newsVersions.length > 0) {
437
+ context.checks.push('README.md changelog contains all versions from io-package.json news');
438
+ }
439
+
440
+ if (/\[[^\]]*changelog[^\]]*\]\([^)\n]*changelog\.md[^)\n]*\)/i.test(changelogSection)) {
441
+ context.warnings.push(
442
+ '[W6032] Changelog section in README.md appears to use a fixed link to CHANGELOG.md. Keep changelog entries directly in README.md.',
443
+ );
444
+ }
445
+
446
+ const versionEntryCount = changelogHeaders.length;
373
447
 
374
448
  if (!hasChangelogOldMd) {
375
449
  if (versionEntryCount > MAX_README_CHANGELOG_ENTRIES) {
@@ -411,16 +485,25 @@ async function checkReadme(context) {
411
485
  }
412
486
  }
413
487
 
414
- const pos = data.indexOf('## License');
415
- if (pos === -1) {
488
+ const licenseHeaderMatch = findLicenseHeaderMatch(data);
489
+ if (!licenseHeaderMatch) {
416
490
  context.errors.push('[E6004] No "## License" found in README.md');
417
491
  } else {
492
+ const pos = licenseHeaderMatch.index;
418
493
  context.checks.push('## License found in README.md');
419
494
  const text = data.substring(pos);
420
495
  const year = new Date().getFullYear();
421
496
  const commitYear = context.lastCommitYear || 0;
422
497
  const readmeYear = getMaxYearFromText(text);
423
498
 
499
+ if (!/^Copyright\s+\(c\)\s+\d{4}(?:-\d{4})?\s+.+$/im.test(text)) {
500
+ context.errors.push(
501
+ '[E6033] "## License" section in README.md must contain a copyright line like "Copyright (c) 2026 iobroker-community-adapters".',
502
+ );
503
+ } else {
504
+ context.checks.push('README.md license section contains a copyright line');
505
+ }
506
+
424
507
  common.info(
425
508
  `years detected: README ${readmeYear} / Current ${year} / Last commit ${commitYear} / NPM ${npmYear}`,
426
509
  );
@@ -494,7 +577,7 @@ async function checkReadme(context) {
494
577
  }
495
578
 
496
579
  // Check that ## License is the last ## section in README.md
497
- const textAfterLicense = data.substring(pos + '## License'.length);
580
+ const textAfterLicense = data.substring(pos + licenseHeaderMatch[0].length);
498
581
  if (/\n## [^#]/.test(textAfterLicense)) {
499
582
  context.warnings.push(
500
583
  '[W6021] "## License" is not the last section in README.md. The license section should be the last section.',
@@ -621,3 +704,11 @@ exports.checkReadme = checkReadme;
621
704
  // [W6023] Sentry plugin is configured in io-package.json but the required Sentry information was not found in README.md. Please add the standard Sentry notice near the top of README.md.
622
705
  // [W6024] README.md contains the Sentry information, but it is located too far down in the document. Please move it before the third "##" section.
623
706
  // [E6025] README.md must contain exactly one H1 heading, but found N.
707
+ // [E6026] Changelog section in README.md contains no "###" entries. The newest changes must be documented in README changelog using the standard format.
708
+ // [E6027] Changelog section in README.md must contain at least one entry in format "- (xxx) text".
709
+ // [W6028] Changelog entry header(s) do not match required version format "x.y.z": ${invalidVersionHeaders.join(', ')}
710
+ // [E6029] Changelog section in README.md has no entry for npm latest version ${latestNpmVersion}.
711
+ // [W6030] Changelog section in README.md should contain an entry for io-package.json version ${currentIoPackageVersion}.
712
+ // [E6031] Changelog section in README.md is missing entry/entries for version(s) from io-package.json news: ${missingNewsVersions.join(', ')}.
713
+ // [W6032] Changelog section in README.md appears to use a fixed link to CHANGELOG.md. Keep changelog entries directly in README.md.
714
+ // [E6033] "## License" section in README.md must contain a copyright line like "Copyright (c) 2026 iobroker-community-adapters".
package/lib/common.js CHANGED
@@ -6,6 +6,7 @@
6
6
  const axios = require('axios');
7
7
  const fs = require('node:fs/promises');
8
8
  const compareVersions = require('compare-versions');
9
+ const semver = require('semver');
9
10
  const semverValid = require('semver/functions/valid');
10
11
 
11
12
  let gDebug = false;
@@ -291,6 +292,20 @@ function validateSemver(p_semver) {
291
292
  return ret.valid && !ret.uncompressed;
292
293
  }
293
294
 
295
+ function getMinimumNodeJsVersion(versionRange) {
296
+ if (typeof versionRange !== 'string') {
297
+ return null;
298
+ }
299
+
300
+ const trimmedVersionRange = versionRange.trim();
301
+ if (!trimmedVersionRange || !semver.validRange(trimmedVersionRange)) {
302
+ return null;
303
+ }
304
+
305
+ const minimumVersion = semver.minVersion(trimmedVersionRange);
306
+ return minimumVersion ? minimumVersion.version : null;
307
+ }
308
+
294
309
  exports.debug = debug;
295
310
  exports.info = info;
296
311
  exports.error = error;
@@ -316,5 +331,6 @@ exports.getDependencyArray = getDependencyArray;
316
331
  exports.getDependencies = getDependencies;
317
332
  exports.isAlphaVersion = isAlphaVersion;
318
333
  exports.maxVersion = maxVersion;
334
+ exports.getMinimumNodeJsVersion = getMinimumNodeJsVersion;
319
335
  exports.parseSemver = parseSemver;
320
336
  exports.validateSemver = validateSemver;
@@ -36,6 +36,7 @@ const mapSeverity4New = {
36
36
  W3009: 'E', // [W3009] Workflow "test-and-release.yml" is missing recommended concurrency configuration.
37
37
  W3019: 'E', // [W3019] Workflow "test-and-release.yml": job "deploy" step using "ioBroker/testing-action-deploy@v1" has "npm-token" parameter specified. Trusted publishing will not work while "npm-token" is set.
38
38
  W3027: 'E', // [W3027] Workflow "test-and-release.yml": job "adapter-tests" OS matrix is missing: windows-latest, macos-latest. Consider adding tests for all of: ubuntu-latest, windows-latest, macos-latest
39
+ W5018: 'E', // [W5018] "@alcalzone/release-script" (>=3.0.0) is used, but ".releaseconfig.json" not found. Please create.',
39
40
  W5512: 'E', // [W5512] admin/jsonConfig.json schema validation error: ...
40
41
  W6020: 'E', // [W6020] Consider adding a CHANGELOG_OLD.md file to store older changelog entries.
41
42
  W6021: 'E', // [W6021] "## License" is not the last section in README.md.
@@ -46,9 +47,12 @@ const mapSeverity4New = {
46
47
  S2008: 'E', // [S2008] Version 0.5.1 tagged as "latest" at npm is not signed with provenance. Trusted publishing is recommended.
47
48
  S3012: 'E', // [S3012] Workflow "test-and-release.yml": job "deploy" is not defined.
48
49
  S3042: 'W', // [S3042] Workflow "test-and-release.yml": job "check-and-lint" uses "ioBroker/testing-action-check@v2.0.0" with a pinned version. Consider locking only the major version "@v2" instead.
50
+ S5004: 'W', // [S5004] Plain setInterval() found in source files (lib/legacy/states.js, lib/zbDeviceAvailability.js, ...). Please use this.setInterval() or adapter.setInterval() instead.
51
+ S5005: 'W', // [S5005] Plain setTimeout() found in source files (lib/localConfig.js, lib/networkmap.js, ...). Please use this.setTimeout() or adapter.setTimeout() instead.
49
52
  S5022: 'W', // [S5022] Please consider migrating to admin 5 UI (jsonConfig) or react based UI.
50
53
  S5043: 'E', // [S5043] Package "xx" is a built-in Node.js module. Please use "node:fs" instead.
51
54
  S5051: 'W', // [S5051] Custom sleep/wait function(s) found in source files (src/lib/adsb.ts).
55
+ W5606: 'E', // [W5606] i18n "admin/i18n" language "nl" has 169 translation(s) identical to English (i.e. baseConfiguration). This may indicate untranslated content.
52
56
  W5611: 'E', // [W5611] "admin/jsonConfig.json/items/tab_region/items/country/options[0]" attribute "label" is missing language "uk" in i18n object.
53
57
  S6008: 'E', // [S6008] Changelog for version 0.7.0-beta.19 should be added to README.md
54
58
  S6020: 'W', // [S6020] Consider adding a CHANGELOG_OLD.md file to store older changelog entries. This is supported by @alcalzone/releasescript.
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "5.16.0",
2
+ "version": "5.17.0",
3
3
  "name": "@iobroker/repochecker",
4
4
  "dependencies": {
5
5
  "ajv": "^8.20.0",