@iobroker/repochecker 5.13.1 → 5.14.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,6 +25,22 @@ Example:
25
25
  Placeholder for the next version (at the beginning of the line):
26
26
  ### **WORK IN PROGRESS**
27
27
  -->
28
+ ### 5.14.0 (2026-05-26)
29
+
30
+ - (@copilot) Added `[E1143]`: when `package.json` `main` points to a `.ts` file, `io-package.json` must set `common.compact` to `false`. In this case `[S1039]` is no longer emitted.
31
+ - (@copilot) Added `[W5060]`: warns when a package is listed in `dependencies` of `package.json` but is not imported or required by any scanned source file. Plugin packages implied by `io-package.json common.plugins` are ignored to avoid false positives.
32
+ - (@copilot) Added `[S3042]`/`[S3043]`/`[S3044]`: suggest using only the major version tag (e.g. `@v2`) when `test-and-release.yml` pins a specific minor/patch version (e.g. `@v2.0.0`) for `ioBroker/testing-action-check`, `ioBroker/testing-action-adapter`, or `ioBroker/testing-action-deploy`.
33
+ - (@copilot) Added notification scope checks in `io-package.json`: errors when `notifications[].scope` is missing and warns when the scope is neither the adapter name nor in a general allowlist (currently empty).
34
+ - (@copilot) Moved file-list-based eslint config file checks to run after code file discovery and now abort on missing internal `context.filesList`.
35
+ - (@copilot) Added eslint migration/config checks for package/workflow validation, including `lint: true` verification in `test-and-release.yml`.
36
+ - (@copilot) Improved `test-and-release.yml` OS checks to evaluate matrix or action-step OS coverage against `package.json` `os` restrictions, including alias mapping (`linux`/`win32`/`darwin`).
37
+ - (@copilot) Added `[W5059]`: warns when adapters using class mode (`class ... extends utils.Adapter`) still call `utils.adapter(...)` in source files.
38
+
39
+ ### 5.13.2 (2026-05-26)
40
+
41
+ - (mcm1957) Adapter some severities for new adapters.
42
+ - (mcm1957) Missing state common attributes added.
43
+
28
44
  ### 5.13.1 (2026-05-24)
29
45
 
30
46
  - (mcm1957) Some flase positives have been fixed.
package/index.js CHANGED
@@ -157,6 +157,7 @@ function check(request, ctx, callback) {
157
157
  .then(context => M2000_Npm.checkNpm(context))
158
158
  .then(context => M4000_Repository.checkRepository(context))
159
159
  .then(context => M5000_Code.checkCode(context))
160
+ .then(context => M0000_PackageJson.checkEslintFileChecks(context))
160
161
  .then(context => M0000_PackageJson.checkDependencyNodeRequirements(context))
161
162
  .then(context => M3000_Testing.checkTests(context))
162
163
  .then(context => M8000_Github.checkGithubRepo(context))
@@ -10,6 +10,7 @@
10
10
 
11
11
  const compareVersions = require('compare-versions');
12
12
  const semver = require('semver');
13
+ const axios = require('axios');
13
14
 
14
15
  const common = require('./common.js');
15
16
 
@@ -368,6 +369,12 @@ function applyConditionalRequirements(dependencyTable, packageJsonDeps) {
368
369
  }
369
370
  }
370
371
  }
372
+ function fileExistsInList(context, filePath) {
373
+ if (!context.filesList) {
374
+ throw new Error('FATAL: context.filesList is undefined');
375
+ }
376
+ return context.filesList.includes(filePath) || context.filesList.includes(filePath.replace(/^\//, ''));
377
+ }
371
378
 
372
379
  /**
373
380
  * Expands npm alias dependencies into separate entries for both the alias name and the real package name.
@@ -402,6 +409,147 @@ function expandNpmAliases(dependencies) {
402
409
  return expanded;
403
410
  }
404
411
 
412
+ /**
413
+ * Parses a dependency declaration and resolves npm aliases.
414
+ *
415
+ * @param {string} packageName - Declared package name in package.json
416
+ * @param {string} packageVersion - Declared package version/range in package.json
417
+ * @returns {{ packageName: string; packageVersion: string }} Parsed package name and version
418
+ */
419
+ function parseDependencyDeclaration(packageName, packageVersion) {
420
+ if (typeof packageVersion !== 'string' || !packageVersion.startsWith('npm:')) {
421
+ return { packageName, packageVersion };
422
+ }
423
+
424
+ const withoutPrefix = packageVersion.slice(4);
425
+ const lastAt = withoutPrefix.lastIndexOf('@');
426
+ if (lastAt <= 0) {
427
+ return { packageName, packageVersion };
428
+ }
429
+
430
+ return {
431
+ packageName: withoutPrefix.slice(0, lastAt),
432
+ packageVersion: withoutPrefix.slice(lastAt + 1),
433
+ };
434
+ }
435
+
436
+ /**
437
+ * Returns the update-check rule for the provided package.
438
+ *
439
+ * @param {object} context - The checker context
440
+ * @param {string} packageName - npm package name
441
+ * @returns {{ minimumAgeDays: number; level: 'S' | 'W' }} Threshold and severity for update suggestions
442
+ */
443
+ function getNpmUpdateRule(context, packageName) {
444
+ const rules = context.cfg?.npmUpdateSuggestions || {};
445
+ const defaultMinimumAgeDays = Number.isFinite(rules.defaultMinimumAgeDays) ? rules.defaultMinimumAgeDays : 60;
446
+ const newAdapterMinimumAgeDays = Number.isFinite(rules.newAdapterMinimumAgeDays)
447
+ ? rules.newAdapterMinimumAgeDays
448
+ : 7;
449
+
450
+ const defaultLevel = context.cfg?.isNewAdapter ? 'W' : 'S';
451
+ let minimumAgeDays = context.cfg?.isNewAdapter ? newAdapterMinimumAgeDays : defaultMinimumAgeDays;
452
+ let level = defaultLevel;
453
+
454
+ for (const entry of rules.standardPackages || []) {
455
+ if (!entry || entry.name !== packageName) {
456
+ continue;
457
+ }
458
+ if (Number.isFinite(entry.minimumAgeDays)) {
459
+ minimumAgeDays = entry.minimumAgeDays;
460
+ }
461
+ if (entry.level === 'S' || entry.level === 'W') {
462
+ level = entry.level;
463
+ }
464
+ break;
465
+ }
466
+
467
+ return { minimumAgeDays, level };
468
+ }
469
+
470
+ /**
471
+ * Checks if dependencies/devDependencies should receive update suggestions based on npm publish age.
472
+ *
473
+ * @param {object} context - The checker context
474
+ * @returns {Promise<object>} Updated context with dependency update suggestions
475
+ */
476
+ async function checkNpmDependencyUpdateSuggestions(context) {
477
+ const dependencySources = [
478
+ ['dependencies', context.packageJson.dependencies || {}],
479
+ ['devDependencies', context.packageJson.devDependencies || {}],
480
+ ];
481
+ const deduplicatedChecks = new Map();
482
+
483
+ for (const [sourceType, sourceDeps] of dependencySources) {
484
+ for (const [declaredName, declaredVersion] of Object.entries(sourceDeps)) {
485
+ const parsed = parseDependencyDeclaration(declaredName, declaredVersion);
486
+ const minVersion = semver.minVersion(parsed.packageVersion);
487
+ if (!minVersion) {
488
+ continue;
489
+ }
490
+
491
+ const key = `${parsed.packageName}:${minVersion.version}`;
492
+ if (!deduplicatedChecks.has(key)) {
493
+ deduplicatedChecks.set(key, {
494
+ packageName: parsed.packageName,
495
+ packageVersion: minVersion.version,
496
+ sourceType,
497
+ });
498
+ }
499
+ }
500
+ }
501
+
502
+ const now = Date.now();
503
+ const millisecondsPerDay = 24 * 60 * 60 * 1000;
504
+
505
+ const checks = Array.from(deduplicatedChecks.values());
506
+ const batchSize = 5;
507
+ for (let i = 0; i < checks.length; i += batchSize) {
508
+ const batch = checks.slice(i, i + batchSize);
509
+ await Promise.all(
510
+ batch.map(async checkItem => {
511
+ const { packageName, packageVersion, sourceType } = checkItem;
512
+ try {
513
+ const response = await axios(`https://registry.npmjs.org/${encodeURIComponent(packageName)}`);
514
+ const npmData = response.data;
515
+ const latestVersion = npmData?.['dist-tags']?.latest;
516
+ const latestPublishedAt = npmData?.time?.[latestVersion];
517
+
518
+ if (!latestVersion || compareVersions.compare(latestVersion, packageVersion, '<=')) {
519
+ return;
520
+ }
521
+ if (!latestPublishedAt) {
522
+ return;
523
+ }
524
+
525
+ const publishedAtDate = new Date(latestPublishedAt);
526
+ if (Number.isNaN(publishedAtDate.getTime())) {
527
+ return;
528
+ }
529
+
530
+ const packageAgeDays = Math.floor((now - publishedAtDate.getTime()) / millisecondsPerDay);
531
+ const updateRule = getNpmUpdateRule(context, packageName);
532
+ if (packageAgeDays < updateRule.minimumAgeDays) {
533
+ return;
534
+ }
535
+
536
+ const dayLabel = packageAgeDays === 1 ? 'day' : 'days';
537
+ const issueCode = updateRule.level === 'W' ? 'W0083' : 'S0082';
538
+ context.warnings.push(
539
+ `[${issueCode}] Package "${packageName}" (${sourceType}) can be updated from ${packageVersion} to ${latestVersion}. The newer version has been published for ${packageAgeDays} ${dayLabel}. Please evaluate updating package.json.`,
540
+ );
541
+ } catch (e) {
542
+ common.debug(
543
+ `Could not fetch npm registry data for "${packageName}" while checking dependency update suggestions: ${e.message || e}`,
544
+ );
545
+ }
546
+ }),
547
+ );
548
+ }
549
+
550
+ return context;
551
+ }
552
+
405
553
  /**
406
554
  * Validates release format according to ioBroker semver subset requirements
407
555
  *
@@ -715,6 +863,11 @@ async function checkPackageJson(context) {
715
863
  } else {
716
864
  context.checks.push('Scripts found in package.json');
717
865
  }
866
+ if (!context.packageJson.scripts || !context.packageJson.scripts.lint) {
867
+ context.warnings.push('[W0074] No "lint" script found in package.json. Please add one.');
868
+ } else {
869
+ context.checks.push('"lint" script found in package.json');
870
+ }
718
871
 
719
872
  if (context.packageJson.maintainers) {
720
873
  context.warnings.push(
@@ -1160,6 +1313,57 @@ async function checkPackageJson(context) {
1160
1313
  }
1161
1314
  context.checks.push('required devDependencies have been checked.');
1162
1315
 
1316
+ await checkNpmDependencyUpdateSuggestions(context);
1317
+
1318
+ // Check eslint migration and config requirements
1319
+ const devDeps = context.packageJson.devDependencies || {};
1320
+ const hasEslintConfig = Object.prototype.hasOwnProperty.call(devDeps, '@iobroker/eslint-config');
1321
+ if (!hasEslintConfig) {
1322
+ context.warnings.push(
1323
+ '[S0071] No devDependency for "@iobroker/eslint-config" found. Consider migrating to the shared ESLint config.',
1324
+ );
1325
+ }
1326
+
1327
+ const eslintVersionRaw = devDeps.eslint;
1328
+ const eslintVersion = eslintVersionRaw ? semver.coerce(eslintVersionRaw) : null;
1329
+ const hasEslintV9OrHigher = !!(eslintVersion && semver.gte(eslintVersion, '9.0.0'));
1330
+ if (eslintVersion && semver.lt(eslintVersion, '9.0.0')) {
1331
+ context.warnings.push(
1332
+ `[W0072] "eslint":"${eslintVersionRaw}" is below 9.0.0. Please migrate to "@iobroker/eslint-config".`,
1333
+ );
1334
+ } else if (hasEslintV9OrHigher && !hasEslintConfig) {
1335
+ context.warnings.push(
1336
+ `[S0073] "eslint":"${eslintVersionRaw}" is >= 9.0.0 but "@iobroker/eslint-config" is not used. Consider migrating to "@iobroker/eslint-config".`,
1337
+ );
1338
+ }
1339
+
1340
+ if (hasEslintConfig) {
1341
+ const obsoleteEslintDevDeps = [
1342
+ '@eslint/eslintrc',
1343
+ '@eslint/js',
1344
+ '@typescript-eslint/eslint-plugin',
1345
+ '@typescript-eslint/parser',
1346
+ 'eslint',
1347
+ 'eslint-config-prettier',
1348
+ 'eslint-plugin-import',
1349
+ 'eslint-plugin-jsdoc',
1350
+ 'eslint-plugin-prettier',
1351
+ 'eslint-plugin-react',
1352
+ 'eslint-plugin-react-hooks',
1353
+ 'eslint-plugin-unicorn',
1354
+ 'prettier',
1355
+ 'typescript-eslint',
1356
+ ];
1357
+ const foundObsoleteDeps = obsoleteEslintDevDeps.filter(dep =>
1358
+ Object.prototype.hasOwnProperty.call(devDeps, dep),
1359
+ );
1360
+ if (foundObsoleteDeps.length > 0) {
1361
+ context.warnings.push(
1362
+ `[W0078] Remove obsolete eslint/prettier devDependencies when using "@iobroker/eslint-config": ${foundObsoleteDeps.join(', ')}.`,
1363
+ );
1364
+ }
1365
+ }
1366
+
1163
1367
  // check @types/node version vs engines.node minimum version
1164
1368
  if (minimumNodeJsSupported !== null) {
1165
1369
  const minMajor = parseInt(minimumNodeJsSupported.split('.')[0], 10);
@@ -1194,11 +1398,11 @@ async function checkPackageJson(context) {
1194
1398
  context.warnings.push(
1195
1399
  `[W0066] "@types/node":"${typesNodeVersion}" at package.json allows major version greater than ${minMajor}. Downgrade to node.js ${minMajor}.x.x to avoid wrong typing is recommended.`,
1196
1400
  );
1197
- // } else if (!semver.satisfies(`${minMajor}.0.0`, typesNodeVersion)) {
1198
- // // Check if @types/node does not cover the minimum node version
1199
- // context.warnings.push(
1200
- // `[S0067] "@types/node":"${typesNodeVersion}" at package.json does not cover minimum node.js version ${minimumNodeJsSupported}. Consider updating to "@types/node":"^${minMajor}" to match the engines clause.`,
1201
- // );
1401
+ // } else if (!semver.satisfies(`${minMajor}.0.0`, typesNodeVersion)) {
1402
+ // // Check if @types/node does not cover the minimum node version
1403
+ // context.warnings.push(
1404
+ // `[S0067] "@types/node":"${typesNodeVersion}" at package.json does not cover minimum node.js version ${minimumNodeJsSupported}. Consider updating to "@types/node":"^${minMajor}" to match the engines clause.`,
1405
+ // );
1202
1406
  } else {
1203
1407
  context.checks.push(
1204
1408
  `@types/node "${typesNodeVersion}" matches minimum node.js version ${minimumNodeJsSupported}.`,
@@ -1398,6 +1602,63 @@ async function checkPackageJson(context) {
1398
1602
  return context;
1399
1603
  }
1400
1604
 
1605
+ async function checkEslintFileChecks(context) {
1606
+ const devDeps = context.packageJson.devDependencies || {};
1607
+ const hasEslintConfig = Object.prototype.hasOwnProperty.call(devDeps, '@iobroker/eslint-config');
1608
+ const eslintVersionRaw = devDeps.eslint;
1609
+ const eslintVersion = eslintVersionRaw ? semver.coerce(eslintVersionRaw) : null;
1610
+ const hasEslintV9OrHigher = !!(eslintVersion && semver.gte(eslintVersion, '9.0.0'));
1611
+ const obsoleteEslintFiles = ['/.eslintignore', '/.eslintrc.json', '/.prettierignore', '/.prettierrc.js'];
1612
+
1613
+ if (hasEslintConfig) {
1614
+ if (!fileExistsInList(context, '/eslint.config.mjs')) {
1615
+ context.errors.push(
1616
+ '[E0075] "eslint.config.mjs" is missing although "@iobroker/eslint-config" is configured.',
1617
+ );
1618
+ } else {
1619
+ try {
1620
+ const eslintConfigContent = await common.getFile(context, '/eslint.config.mjs');
1621
+ const hasImport = /import\s+config\s+from\s+['"]@iobroker\/eslint-config['"]\s*;?/.test(
1622
+ String(eslintConfigContent || ''),
1623
+ );
1624
+ if (!hasImport) {
1625
+ context.errors.push(
1626
+ '[E0077] "eslint.config.mjs" should use installed "@iobroker/eslint-config" via `import config from \'@iobroker/eslint-config\';`.',
1627
+ );
1628
+ } else {
1629
+ context.checks.push('"eslint.config.mjs" imports "@iobroker/eslint-config".');
1630
+ }
1631
+ } catch (e) {
1632
+ context.errors.push(`[E0081] Could not read "eslint.config.mjs": ${e.message || e}`);
1633
+ }
1634
+ }
1635
+
1636
+ if (!fileExistsInList(context, '/prettier.config.mjs')) {
1637
+ context.warnings.push(
1638
+ '[W0076] "prettier.config.mjs" is missing although "@iobroker/eslint-config" is configured.',
1639
+ );
1640
+ } else {
1641
+ context.checks.push('"prettier.config.mjs" found.');
1642
+ }
1643
+
1644
+ const foundObsoleteFiles = obsoleteEslintFiles.filter(file => fileExistsInList(context, file));
1645
+ if (foundObsoleteFiles.length > 0) {
1646
+ context.warnings.push(
1647
+ `[W0079] Remove obsolete eslint/prettier config files when using "@iobroker/eslint-config": ${foundObsoleteFiles.map(file => file.slice(1)).join(', ')}.`,
1648
+ );
1649
+ }
1650
+ } else if (hasEslintV9OrHigher) {
1651
+ const foundObsoleteFiles = obsoleteEslintFiles.filter(file => fileExistsInList(context, file));
1652
+ if (foundObsoleteFiles.length > 0) {
1653
+ context.warnings.push(
1654
+ `[S0080] Remove obsolete eslint/prettier config files: ${foundObsoleteFiles.map(file => file.slice(1)).join(', ')}.`,
1655
+ );
1656
+ }
1657
+ }
1658
+
1659
+ return context;
1660
+ }
1661
+
1401
1662
  /**
1402
1663
  * Creates a package-lock.json in a temp directory by running npm install --package-lock-only.
1403
1664
  * Returns the content of the generated package-lock.json, or throws if creation fails.
@@ -1454,7 +1715,7 @@ async function checkDependencyNodeRequirements(context) {
1454
1715
  }
1455
1716
 
1456
1717
  let packageLockContent = null;
1457
- const hasPackageLock = context.filesList && context.filesList.includes('/package-lock.json');
1718
+ const hasPackageLock = fileExistsInList(context, '/package-lock.json');
1458
1719
 
1459
1720
  if (hasPackageLock) {
1460
1721
  // Load package-lock.json from the repository
@@ -1625,6 +1886,7 @@ async function checkDependencyNodeRequirements(context) {
1625
1886
 
1626
1887
  exports.getPackageJson = getPackageJson;
1627
1888
  exports.checkPackageJson = checkPackageJson;
1889
+ exports.checkEslintFileChecks = checkEslintFileChecks;
1628
1890
  exports.checkDependencyNodeRequirements = checkDependencyNodeRequirements;
1629
1891
  exports.validateReleaseFormat = validateReleaseFormat;
1630
1892
 
@@ -1705,3 +1967,17 @@ exports.validateReleaseFormat = validateReleaseFormat;
1705
1967
  // [0068] Invalid semver format ${typesNodeVersion} for devDependency "@types/node" at package.json.
1706
1968
  // [W0069] The following dependencies require a node.js version incompatible with the adapter's minimum (node ${minimumNodeJsSupported}): ...
1707
1969
  // [S0070] Dependency node requirement check could not be performed: ...
1970
+ // [S0071] No devDependency for "@iobroker/eslint-config" found.
1971
+ // [W0072] "eslint" below 9.0.0 detected. Please migrate to "@iobroker/eslint-config".
1972
+ // [S0073] "eslint" >= 9.0.0 detected without "@iobroker/eslint-config". Consider migrating.
1973
+ // [W0074] No "lint" script found in package.json.
1974
+ // [E0075] "eslint.config.mjs" is missing although "@iobroker/eslint-config" is configured.
1975
+ // [W0076] "prettier.config.mjs" is missing although "@iobroker/eslint-config" is configured.
1976
+ // [E0077] "eslint.config.mjs" should use installed "@iobroker/eslint-config".
1977
+ // [W0078] Obsolete eslint/prettier devDependencies found while "@iobroker/eslint-config" is used.
1978
+ // [W0079] Obsolete eslint/prettier config files found while "@iobroker/eslint-config" is used.
1979
+ // [S0080] Obsolete eslint/prettier config files found for adapters using eslint >= 9.0.0 without "@iobroker/eslint-config".
1980
+
1981
+ // [E0081] Could not read "eslint.config.mjs": ${e.message || e}
1982
+ // [S0082] Package "${packageName}" (${sourceType}) can be updated from ${packageVersion} to ${latestVersion}. ...
1983
+ // [W0083] Package "${packageName}" (${sourceType}) can be updated from ${packageVersion} to ${latestVersion}. ...
@@ -35,6 +35,7 @@ let requiredJsControllerVersion = '6.0.11';
35
35
  const recommendedAdminVersion = '7.6.20';
36
36
  let requiredAdminVersion = '7.6.17'; // set to 6.17.14 if jsonConfig is used
37
37
  const adaptersAllowedToUseNondeletable = [];
38
+ const generallyAllowedNotificationScopes = [];
38
39
 
39
40
  const blacklistIOPackageJson = {
40
41
  $schema: {
@@ -279,6 +280,55 @@ function doesValueMatchStateType(value, stateType) {
279
280
  return true;
280
281
  }
281
282
 
283
+ function isReadmeOrLicenseFile(path) {
284
+ if (!path || typeof path !== 'string') {
285
+ return false;
286
+ }
287
+ const normalized = path.replace(/^\/+/, '').toLowerCase();
288
+ return normalized === 'readme.md' || normalized === 'license' || normalized === 'license.md';
289
+ }
290
+
291
+ function isCurrentRepositoryReadmeOrLicenseLink(context, link) {
292
+ if (!link || typeof link !== 'string' || !context?.repository) {
293
+ return false;
294
+ }
295
+ try {
296
+ const parsedUrl = new URL(link);
297
+ const host = parsedUrl.hostname.toLowerCase();
298
+ const pathParts = parsedUrl.pathname
299
+ .split('/')
300
+ .map(part => decodeURIComponent(part))
301
+ .filter(Boolean);
302
+ const [owner, repo] = context.repository.toLowerCase().split('/');
303
+
304
+ if (host === 'github.com') {
305
+ if (pathParts.length < 5) {
306
+ return false;
307
+ }
308
+ const [urlOwner, urlRepo, segment] = pathParts;
309
+ if (urlOwner.toLowerCase() !== owner || urlRepo.toLowerCase() !== repo || segment !== 'blob') {
310
+ return false;
311
+ }
312
+ return isReadmeOrLicenseFile(pathParts.slice(4).join('/'));
313
+ }
314
+
315
+ if (host === 'raw.githubusercontent.com') {
316
+ if (pathParts.length < 4) {
317
+ return false;
318
+ }
319
+ const [urlOwner, urlRepo] = pathParts;
320
+ if (urlOwner.toLowerCase() !== owner || urlRepo.toLowerCase() !== repo) {
321
+ return false;
322
+ }
323
+ return isReadmeOrLicenseFile(pathParts.slice(3).join('/'));
324
+ }
325
+ } catch {
326
+ return false;
327
+ }
328
+
329
+ return false;
330
+ }
331
+
282
332
  async function validateIOPackageSchema(context) {
283
333
  common.debug('[schema] validating io-package.json against schema');
284
334
 
@@ -371,6 +421,34 @@ function checkNotificationsTranslations(obj, allowedLanguages) {
371
421
  return false;
372
422
  }
373
423
 
424
+ function checkNotificationScopes(notifications, adapterName, allowedScopes) {
425
+ const normalizedAdapterName = adapterName.toLowerCase();
426
+ const normalizedAllowedScopes = new Set(allowedScopes.map(scope => scope.toLowerCase()));
427
+
428
+ const missingScopeNotifications = [];
429
+ const unsupportedScopeNotifications = [];
430
+
431
+ for (let i = 0; i < notifications.length; i++) {
432
+ const notification = notifications[i];
433
+ if (!notification || typeof notification !== 'object' || Array.isArray(notification)) {
434
+ continue;
435
+ }
436
+
437
+ if (!Object.prototype.hasOwnProperty.call(notification, 'scope')) {
438
+ missingScopeNotifications.push(i);
439
+ continue;
440
+ }
441
+
442
+ const normalizedScope =
443
+ typeof notification.scope === 'string' ? notification.scope.toLowerCase() : String(notification.scope);
444
+ if (normalizedScope !== normalizedAdapterName && !normalizedAllowedScopes.has(normalizedScope)) {
445
+ unsupportedScopeNotifications.push({ index: i, scope: notification.scope });
446
+ }
447
+ }
448
+
449
+ return { missingScopeNotifications, unsupportedScopeNotifications };
450
+ }
451
+
374
452
  async function checkIOPackageJson(context) {
375
453
  console.log('\n[E1000 - E1999] checking io-package.json');
376
454
 
@@ -707,7 +785,16 @@ async function checkIOPackageJson(context) {
707
785
  }
708
786
  }
709
787
 
710
- if (!context.ioPackageJson.common.compact && !context.ioPackageJson.common.onlyWWW) {
788
+ const hasTypeScriptMainEntry = context.packageJson?.main?.endsWith('.ts');
789
+ if (!context.ioPackageJson.common.onlyWWW && hasTypeScriptMainEntry) {
790
+ if (context.ioPackageJson.common.compact === undefined || context.ioPackageJson.common.compact === true) {
791
+ context.errors.push(
792
+ '[E1143] package.json "main" points to a TypeScript file. Please set "common.compact": false in io-package.json.',
793
+ );
794
+ } else {
795
+ context.checks.push('"common.compact" found in io-package.json');
796
+ }
797
+ } else if (!context.ioPackageJson.common.compact && !context.ioPackageJson.common.onlyWWW) {
711
798
  if (context.ioPackageJson.common.compact === undefined) {
712
799
  context.warnings.push(
713
800
  '[W1013] Please test whether adapter can support compact mode, if not set "common.compact:false" at io-package.json.',
@@ -790,11 +877,25 @@ async function checkIOPackageJson(context) {
790
877
  } else {
791
878
  context.checks.push('"common.licenseInformation.type" is valid in io-package.json');
792
879
 
793
- if (['paid', 'commercial', 'limited'].includes(context.ioPackageJson.common?.licenseInformation?.type)) {
794
- if (!context.ioPackageJson.common?.licenseInformation?.link) {
795
- context.errors.push('[E1071] "common.licenseInformation.link" is required for non-free adapters');
880
+ const licenseInformationLink = context.ioPackageJson.common?.licenseInformation?.link;
881
+ if (
882
+ ['paid', 'commercial', 'limited'].includes(context.ioPackageJson.common?.licenseInformation?.type) &&
883
+ !licenseInformationLink
884
+ ) {
885
+ context.warnings.push('[W1071] "common.licenseInformation.link" is required for non-free adapters');
886
+ } else if (licenseInformationLink) {
887
+ context.checks.push('"common.licenseInformation.link" is valid in io-package.json');
888
+
889
+ if (isCurrentRepositoryReadmeOrLicenseLink(context, licenseInformationLink)) {
890
+ context.warnings.push(
891
+ '[W1137] "common.licenseInformation.link" should not point to this repository\'s README.md or LICENSE file',
892
+ );
893
+ }
894
+
895
+ if (!((await common.downloadURL(licenseInformationLink, false)) || '').trim()) {
896
+ context.warnings.push('[W1138] "common.licenseInformation.link" should point to a readable URL');
796
897
  } else {
797
- context.checks.push('"common.licenseInformation.link" is valid in io-package.json');
898
+ context.checks.push('"common.licenseInformation.link" points to a readable URL');
798
899
  }
799
900
  }
800
901
  }
@@ -999,13 +1100,16 @@ async function checkIOPackageJson(context) {
999
1100
  'desc',
1000
1101
  'read',
1001
1102
  'write',
1002
- 'role',
1103
+ 'role', // string
1003
1104
  'states',
1004
1105
  'workingID',
1005
1106
  'custom',
1006
1107
  'type',
1007
- 'name',
1008
- 'expert',
1108
+ 'name', // StringOrTranslated
1109
+ 'expert', // boolean
1110
+ 'dontDelete', // boolean
1111
+ 'color', // string
1112
+ 'icon', // string
1009
1113
  ]);
1010
1114
 
1011
1115
  instanceObjects.forEach((instanceObject, index) => {
@@ -1177,6 +1281,19 @@ async function checkIOPackageJson(context) {
1177
1281
  );
1178
1282
  }
1179
1283
  }
1284
+
1285
+ if (instanceObject.common.color !== undefined && typeof instanceObject.common.color !== 'string') {
1286
+ context.warnings.push(
1287
+ `[W1140] io-package.json: instanceObject "${instanceObject._id || index}" common.color must be a string`,
1288
+ );
1289
+ }
1290
+
1291
+ if (instanceObject.common.icon !== undefined && typeof instanceObject.common.icon !== 'string') {
1292
+ context.warnings.push(
1293
+ `[W1141] io-package.json: instanceObject "${instanceObject._id || index}" common.icon must be a string`,
1294
+ );
1295
+ }
1296
+
1180
1297
  });
1181
1298
  }
1182
1299
  }
@@ -1633,12 +1750,32 @@ async function checkIOPackageJson(context) {
1633
1750
  if (context.ioPackageJson.notifications) {
1634
1751
  if (!Array.isArray(context.ioPackageJson.notifications)) {
1635
1752
  context.errors.push('[E1112] "notifications" in io-package.json must be an array');
1636
- } else if (checkNotificationsTranslations(context.ioPackageJson.notifications, context.cfg.allowedLanguages)) {
1637
- context.errors.push(
1638
- `[E1112] "notifications" in io-package.json must be translated into all supported languages (${context.cfg.allowedLanguages.join(', ')})`,
1639
- );
1640
1753
  } else {
1641
- context.checks.push('"notifications" in io-package.json are translated into all supported languages');
1754
+ if (checkNotificationsTranslations(context.ioPackageJson.notifications, context.cfg.allowedLanguages)) {
1755
+ context.errors.push(
1756
+ `[E1139] "notifications" in io-package.json must be translated into all supported languages (${context.cfg.allowedLanguages.join(', ')})`,
1757
+ );
1758
+ } else {
1759
+ context.checks.push('"notifications" in io-package.json are translated into all supported languages');
1760
+ }
1761
+
1762
+ const { missingScopeNotifications, unsupportedScopeNotifications } = checkNotificationScopes(
1763
+ context.ioPackageJson.notifications,
1764
+ context.adapterName,
1765
+ generallyAllowedNotificationScopes,
1766
+ );
1767
+
1768
+ for (const notificationIndex of missingScopeNotifications) {
1769
+ context.errors.push(
1770
+ `[E1137] "notifications[${notificationIndex}].scope" is missing in io-package.json`,
1771
+ );
1772
+ }
1773
+
1774
+ for (const notification of unsupportedScopeNotifications) {
1775
+ context.warnings.push(
1776
+ `[W1142] "notifications[${notification.index}].scope" has unsupported value "${notification.scope}" in io-package.json. Use "${context.adapterName.toLowerCase()}" or a generally allowed scope.`,
1777
+ );
1778
+ }
1642
1779
  }
1643
1780
  } else {
1644
1781
  context.checks.push('"notifications" not found in io-package.json, skipping check');
@@ -1726,8 +1863,6 @@ exports.checkIOPackageJson = checkIOPackageJson;
1726
1863
  // [1067] scheduled adapters must have "common.schedule" property in io-package.json
1727
1864
  // [1068] "common.keywords" should not contain "${forbiddenKeywords.join(', ')}" io-package.json0
1728
1865
  // [1069] "common.keywords" must be an array within io-package.json and contain some useful keywords
1729
- // [1069] "common.keywords" must be an array within io-package.json and contain some useful keywords
1730
- // [1069] "common.keywords" must be an array within io-package.json and contain some useful keywords
1731
1866
  // [1070] "common.licenseInformation.type" is invalid. Select valid type (e.g. free)
1732
1867
  // [1071] "common.licenseInformation.link" is required for non-free adapters
1733
1868
  // [1072] "common.localLink" in io-package.json is deprecated. Please define object "common.localLinks": { "_default": "..." }
@@ -1772,8 +1907,36 @@ exports.checkIOPackageJson = checkIOPackageJson;
1772
1907
  // [1109] "common.jsonConfig" is deprecated and has been replaced by "common.adminUI" at io-package.json. Please remove.
1773
1908
  // [1110] "common.jsonConfig" is deprecated and must be replaced by "common.adminUI" configuration at io-package.json.
1774
1909
  // [1111] -- moved to M5000_Code.js as [E5040] (check deferred to allow scanning admin UI files)
1775
- // [1112] "notifications" in io-package.json must be translated into all supported languages
1910
+ // [1112] "notifications" in io-package.json must be an array
1776
1911
  // [1113] "native" config object will not be used when "common.adminUI.config" is set to "none". Please remove native properties from io-package.json.
1777
1912
  // [1114] "common.schedule" is not supported / unused for daemon adapters and should be removed from io-package.json.
1778
1913
  // [1115] Plugin "${pluginName}" is listed in "common.plugins" of io-package.json but "@iobroker/plugin-${pluginName}" is not listed as a dependency in package.json. Please add it.
1779
1914
  // [1116] Sentry plugin is configured in io-package.json but "@sentry/*" packages (${sentryDeps.join(', ')}) are listed as dependencies in package.json. When using the sentry plugin, explicit @sentry/* dependencies should not be added.
1915
+ // [W1117] Could not download stateRoles URL for validation of instanceObjects common.role
1916
+ // [W1118] io-package.json: instanceObject[${index}] must be an object
1917
+ // [W1119] io-package.json: instanceObject[${index}] must define non-empty string "_id"
1918
+ // [W1120] io-package.json: instanceObject "${instanceObject._id || index}" with type "state" must have "common" object
1919
+ // [W1121] io-package.json: instanceObject "${instanceObject._id || index}" common.${key} must be a number
1920
+ // [W1122] io-package.json: instanceObject "${instanceObject._id || index}" common.unit must be a string
1921
+ // [W1123] io-package.json: instanceObject "${instanceObject._id || index}" common.desc must be a string or object
1922
+ // [W1124] io-package.json: instanceObject "${instanceObject._id || index}" common.read is mandatory and must be boolean
1923
+ // [W1125] io-package.json: instanceObject "${instanceObject._id || index}" common.write is mandatory and must be boolean
1924
+ // [W1126] io-package.json: instanceObject "${instanceObject._id || index}" common.role is mandatory and must be a non-empty string
1925
+ // [W1127] io-package.json: instanceObject "${instanceObject._id || index}" common.states must be number or string
1926
+ // [W1128] io-package.json: instanceObject "${instanceObject._id || index}" common.defAck must be boolean
1927
+ // [W1129] io-package.json: instanceObject "${instanceObject._id || index}" common.workingID must be string
1928
+ // [W1130] io-package.json: instanceObject "${instanceObject._id || index}" common.def must match common.type "${instanceObject.common.type}"
1929
+ // [W1131] io-package.json: instanceObject "${instanceObject._id || index}" has unsupported common.${commonKey} attribute
1930
+ // [W1132] io-package.json: instanceObject "${instanceObject._id || index}" common.role "${instanceObject.common.role}" is not a known ioBroker state role
1931
+ // [W1133] io-package.json: instanceObject "${instanceObject._id || index}" role "${instanceObject.common.role}" expects common.type to be one of [${roleDefinition.types.join(', ')}], but found "${instanceObject.common.type}"
1932
+ // [W1134] io-package.json: instanceObject "${instanceObject._id || index}" role "${instanceObject.common.role}" expects common.read=${roleDefinition.read}
1933
+ // [W1135] io-package.json: instanceObject "${instanceObject._id || index}" role "${instanceObject.common.role}" expects common.write=${roleDefinition.write}
1934
+ // [W1136] io-package.json: instanceObject "${instanceObject._id || index}" common.expert must be boolean
1935
+ // [W1137] "common.licenseInformation.link" should not point to this repository's README.md or LICENSE file
1936
+ // [W1138] "common.licenseInformation.link" should point to a readable URL
1937
+ // [E1137] "notifications[${notificationIndex}].scope" is missing in io-package.json
1938
+ // [E1139] "notifications" in io-package.json must be translated into all supported languages
1939
+ // [W1140] io-package.json: instanceObject common.color must be a string
1940
+ // [W1141] io-package.json: instanceObject common.icon must be a string
1941
+ // [W1142] "notifications[${notification.index}].scope" has unsupported value "${notification.scope}" in io-package.json.
1942
+ // [E1143] package.json "main" points to a TypeScript file. Please set "common.compact": false in io-package.json.