@iobroker/repochecker 4.2.0-alpha.0 → 4.2.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -5
- package/lib/M100_IOPackageJson.js +17 -0
- package/lib/M400_Repository.js +135 -1
- package/lib/M500_Code.js +136 -4
- package/lib/M500__JsonConfig.js +30 -30
- package/lib/M800_Github.js +4 -1
- package/lib/M900_GitNpmIgnore.js +25 -0
- package/lib/common.js +31 -0
- package/lib/config.js +13 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -33,11 +33,20 @@ npx @iobroker/repochecker https://github.com/ioBroker/ioBroker.javascript --loca
|
|
|
33
33
|
-->
|
|
34
34
|
|
|
35
35
|
## Changelog
|
|
36
|
-
### 4.2.0-alpha.
|
|
37
|
-
- (copilot)
|
|
38
|
-
- (copilot)
|
|
39
|
-
|
|
40
|
-
- (
|
|
36
|
+
### 4.2.0-alpha.2 (2025-09-15)
|
|
37
|
+
- (copilot) Added check for deprecated adapter methods (createState/createChannel/createDevice/deleteState/deleteChannel/deleteDevice) (W533) [#182].
|
|
38
|
+
- (copilot) Added check for outdated lib/tools.js file usage (W532) [#432].
|
|
39
|
+
|
|
40
|
+
### 4.2.0-alpha.1 (2025-09-14)
|
|
41
|
+
- (copilot) Added VS Code schema definitions checker for .vscode/settings.json - validates json.schemas for io-package.json and jsonConfig files [#336].
|
|
42
|
+
- (copilot) Change W510 to E510: Convert missing admin i18n files from warning to error [#400].
|
|
43
|
+
- (copilot) Renumbered all issues in M500__JsonConfig.js from 500-511 range to 550-561 range [#481].
|
|
44
|
+
- (copilot) Added check for .commitinfo file - error if present (E905), warning if not in .gitignore (W906) [#467].
|
|
45
|
+
- (copilot) Added check for allowInit attribute [#181].
|
|
46
|
+
- (copilot) Added detection for empty dependency objects in io-package.json (E200, E201) [#422].
|
|
47
|
+
- (copilot) Added suggestion to restart 'vis-2' when 'vis' is in restartAdapters (S202) [#412].
|
|
48
|
+
- (copilot) Modified W513 gulpfile.js warning to check for @iobroker/adapter-dev dependency and add S531 suggestion [#469].
|
|
49
|
+
- (copilot) Fixed W195 warning for array elements - add W203 warning for unsupported array encryption [#399].
|
|
41
50
|
|
|
42
51
|
### 4.1.0 (2025-09-11)
|
|
43
52
|
- (mcm1957) eslint-config and testing suggestions have been updated.
|
|
@@ -372,4 +381,6 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
372
381
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
373
382
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
374
383
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
384
|
+
|
|
385
|
+
|
|
375
386
|
THE SOFTWARE.
|
|
@@ -527,6 +527,22 @@ async function checkIOPackageJson(context) {
|
|
|
527
527
|
) {
|
|
528
528
|
context.errors.push('[E192] extension adapters must list web adapter as dependency in io-package.json');
|
|
529
529
|
}
|
|
530
|
+
|
|
531
|
+
// Check allowInit attribute - only useful for scheduled adapters
|
|
532
|
+
if (
|
|
533
|
+
context.ioPackageJson.common.mode !== 'schedule' &&
|
|
534
|
+
context.ioPackageJson.common.allowInit !== undefined
|
|
535
|
+
) {
|
|
536
|
+
if (context.ioPackageJson.common.allowInit === true) {
|
|
537
|
+
context.warnings.push(
|
|
538
|
+
'[W204] allowInit is only used with scheduled adapters and should be removed',
|
|
539
|
+
);
|
|
540
|
+
} else if (context.ioPackageJson.common.allowInit === false) {
|
|
541
|
+
context.warnings.push(
|
|
542
|
+
'[S204] allowInit is only used with scheduled adapters and should be removed',
|
|
543
|
+
);
|
|
544
|
+
}
|
|
545
|
+
}
|
|
530
546
|
}
|
|
531
547
|
}
|
|
532
548
|
|
|
@@ -1202,3 +1218,4 @@ exports.checkIOPackageJson = checkIOPackageJson;
|
|
|
1202
1218
|
// [201] Empty dependency objects found in "common.globalDependencies" at io-package.json. Please remove empty objects.
|
|
1203
1219
|
// [202] Consider adding 'vis-2' to "common.restartAdapters" as 'vis' is already listed in io-package.json
|
|
1204
1220
|
// [203] Encryption of array elements "${key}" is not yet available
|
|
1221
|
+
// [204] allowInit is only used with scheduled adapters and should be removed
|
package/lib/M400_Repository.js
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
const axios = require('axios');
|
|
11
11
|
const compareVersions = require('compare-versions');
|
|
12
|
+
const JSON5 = require('json5');
|
|
12
13
|
|
|
13
14
|
// disable axios caching
|
|
14
15
|
// axios.defaults.headers = {
|
|
@@ -18,6 +19,7 @@ const compareVersions = require('compare-versions');
|
|
|
18
19
|
// };
|
|
19
20
|
|
|
20
21
|
const common = require('./common.js');
|
|
22
|
+
const config = require('./config.js');
|
|
21
23
|
|
|
22
24
|
async function checkRepository(context) {
|
|
23
25
|
console.log('\n[E400 - E499] checkRepository');
|
|
@@ -344,8 +346,129 @@ async function checkRepository(context) {
|
|
|
344
346
|
context.checks.push(`Dependency checks skipped due to repository access errors`);
|
|
345
347
|
}
|
|
346
348
|
}
|
|
349
|
+
|
|
350
|
+
// Check VS Code schema definitions
|
|
351
|
+
await checkVSCodeSchemas(context);
|
|
352
|
+
|
|
347
353
|
return context;
|
|
348
|
-
// max number is
|
|
354
|
+
// max number is E449
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
async function checkVSCodeSchemas(context) {
|
|
358
|
+
try {
|
|
359
|
+
// Try to get .vscode/settings.json file
|
|
360
|
+
const vscodeSettings = await common.getFile(context, '/.vscode/settings.json');
|
|
361
|
+
|
|
362
|
+
if (!vscodeSettings) {
|
|
363
|
+
// File doesn't exist, suggest adding it
|
|
364
|
+
context.warnings.push(
|
|
365
|
+
'[S436] Consider adding .vscode/settings.json file with JSON schema definitions for better development experience with Visual Studio Code.',
|
|
366
|
+
);
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
context.checks.push('Found .vscode/settings.json file');
|
|
371
|
+
|
|
372
|
+
// Parse the JSON
|
|
373
|
+
let settingsJson;
|
|
374
|
+
try {
|
|
375
|
+
settingsJson = JSON5.parse(vscodeSettings);
|
|
376
|
+
} catch {
|
|
377
|
+
context.errors.push('[E437] .vscode/settings.json file contains invalid JSON.');
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
// Check if json.schemas exists
|
|
382
|
+
if (!settingsJson['json.schemas']) {
|
|
383
|
+
context.warnings.push(
|
|
384
|
+
'[W438] .vscode/settings.json file missing "json.schemas" property. Add schema definitions for better IntelliSense support.',
|
|
385
|
+
);
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
const schemas = settingsJson['json.schemas'];
|
|
390
|
+
if (!Array.isArray(schemas)) {
|
|
391
|
+
context.errors.push('[E439] "json.schemas" property in .vscode/settings.json must be an array.');
|
|
392
|
+
return;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
// Check for io-package.json schema
|
|
396
|
+
const ioPackageSchema = schemas.find(
|
|
397
|
+
schema => schema.fileMatch && schema.fileMatch.includes('io-package.json'),
|
|
398
|
+
);
|
|
399
|
+
|
|
400
|
+
if (!ioPackageSchema) {
|
|
401
|
+
context.warnings.push(
|
|
402
|
+
`[W440] Missing schema definition for "io-package.json" in .vscode/settings.json. Add: {"fileMatch": ["io-package.json"], "url": "${config.schemaUrls['io-package']}"}`,
|
|
403
|
+
);
|
|
404
|
+
} else {
|
|
405
|
+
// Check if URL is correct
|
|
406
|
+
if (ioPackageSchema.url !== config.schemaUrls['io-package']) {
|
|
407
|
+
context.errors.push(
|
|
408
|
+
`[E441] Incorrect schema URL for "io-package.json" in .vscode/settings.json. Expected: "${config.schemaUrls['io-package']}", found: "${ioPackageSchema.url}"`,
|
|
409
|
+
);
|
|
410
|
+
} else {
|
|
411
|
+
context.checks.push('Correct io-package.json schema definition found in .vscode/settings.json');
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
// Check for jsonConfig schemas
|
|
416
|
+
const jsonConfigFiles = ['admin/jsonConfig.json', 'admin/jsonCustom.json', 'admin/jsonTab.json'];
|
|
417
|
+
const json5ConfigFiles = ['admin/jsonConfig.json5', 'admin/jsonCustom.json5', 'admin/jsonTab.json5'];
|
|
418
|
+
|
|
419
|
+
// Check if adapter has any json5 files in admin directory
|
|
420
|
+
|
|
421
|
+
// Find schema that matches jsonConfig files
|
|
422
|
+
const jsonConfigSchema = schemas.find(
|
|
423
|
+
schema => schema.fileMatch && jsonConfigFiles.every(file => schema.fileMatch.includes(file)),
|
|
424
|
+
);
|
|
425
|
+
|
|
426
|
+
if (!jsonConfigSchema) {
|
|
427
|
+
context.warnings.push(
|
|
428
|
+
`[W442] Missing schema definition for jsonConfig files in .vscode/settings.json. Add: {"fileMatch": ${JSON.stringify(jsonConfigFiles)}, "url": "${config.schemaUrls.jsonConfig}"}`,
|
|
429
|
+
);
|
|
430
|
+
} else {
|
|
431
|
+
// Check if URL is correct
|
|
432
|
+
if (jsonConfigSchema.url !== config.schemaUrls.jsonConfig) {
|
|
433
|
+
context.errors.push(
|
|
434
|
+
`[E443] Incorrect schema URL for jsonConfig files in .vscode/settings.json. Expected: "${config.schemaUrls.jsonConfig}", found: "${jsonConfigSchema.url}"`,
|
|
435
|
+
);
|
|
436
|
+
} else {
|
|
437
|
+
context.checks.push('Correct jsonConfig schema definition found in .vscode/settings.json');
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
// Check for json5 schema
|
|
442
|
+
const json5ConfigSchema = schemas.find(
|
|
443
|
+
schema => schema.fileMatch && json5ConfigFiles.every(file => schema.fileMatch.includes(file)),
|
|
444
|
+
);
|
|
445
|
+
|
|
446
|
+
if (!json5ConfigSchema) {
|
|
447
|
+
if (context.cfg.usesJson5) {
|
|
448
|
+
context.warnings.push(
|
|
449
|
+
`[W444] Missing schema definition for JSON5 config files in .vscode/settings.json. Adapt: {"fileMatch": ${JSON.stringify(jsonConfigFiles.concat(json5ConfigFiles))}, "url": "${config.schemaUrls.jsonConfig}"}`,
|
|
450
|
+
);
|
|
451
|
+
}
|
|
452
|
+
} else {
|
|
453
|
+
// Check if URL is correct
|
|
454
|
+
if (json5ConfigSchema.url !== config.schemaUrls.jsonConfig) {
|
|
455
|
+
context.errors.push(
|
|
456
|
+
`[E445] Incorrect schema URL for JSON5 config files in .vscode/settings.json. Expected: "${config.schemaUrls.jsonConfig}", found: "${json5ConfigSchema.url}"`,
|
|
457
|
+
);
|
|
458
|
+
} else {
|
|
459
|
+
context.checks.push('Correct JSON5 config schema definition found in .vscode/settings.json');
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
} catch (error) {
|
|
463
|
+
// File doesn't exist or cannot be read
|
|
464
|
+
if (error.code === 'ENOENT' || error.message.includes('404')) {
|
|
465
|
+
context.warnings.push(
|
|
466
|
+
'[S436] Consider adding .vscode/settings.json file with JSON schema definitions for better development experience with Visual Studio Code.',
|
|
467
|
+
);
|
|
468
|
+
} else {
|
|
469
|
+
context.warnings.push(`[W446] Could not read .vscode/settings.json file: ${error.message}`);
|
|
470
|
+
}
|
|
471
|
+
}
|
|
349
472
|
}
|
|
350
473
|
|
|
351
474
|
exports.checkRepository = checkRepository;
|
|
@@ -397,3 +520,14 @@ exports.checkRepository = checkRepository;
|
|
|
397
520
|
// [434] Dependency '${dependency}':'${dependencies[dependency]}' should specify '>='
|
|
398
521
|
// [434] Dependency '${dependency}':'${dependencies[dependency]}' should specify '>='
|
|
399
522
|
// [435] Dependency '${dependency}':'${dependencies[dependency]}' cannot be parsed - ${e}
|
|
523
|
+
// [436] Consider adding .vscode/settings.json file with JSON schema definitions for better development experience with Visual Studio Code.
|
|
524
|
+
// [437] .vscode/settings.json file contains invalid JSON.
|
|
525
|
+
// [438] .vscode/settings.json file missing "json.schemas" property. Add schema definitions for better IntelliSense support.
|
|
526
|
+
// [439] "json.schemas" property in .vscode/settings.json must be an array.
|
|
527
|
+
// [440] Missing schema definition for "io-package.json" in .vscode/settings.json. Add: {"fileMatch": ["io-package.json"], "url": "${config.schemaUrls['io-package']}"}
|
|
528
|
+
// [441] Incorrect schema URL for "io-package.json" in .vscode/settings.json. Expected: "${config.schemaUrls['io-package']}", found: "${ioPackageSchema.url}"
|
|
529
|
+
// [442] Missing schema definition for jsonConfig files in .vscode/settings.json. Add: {"fileMatch": ${JSON.stringify(jsonConfigFiles)}, "url": "${config.schemaUrls.jsonConfig}"}
|
|
530
|
+
// [443] Incorrect schema URL for jsonConfig files in .vscode/settings.json. Expected: "${config.schemaUrls.jsonConfig}", found: "${jsonConfigSchema.url}"
|
|
531
|
+
// [444] Missing schema definition for JSON5 config files in .vscode/settings.json. Add: {"fileMatch": ${JSON.stringify(json5ConfigFiles)}, "url": "${config.schemaUrls.jsonConfig}"}
|
|
532
|
+
// [445] Incorrect schema URL for JSON5 config files in .vscode/settings.json. Expected: "${config.schemaUrls.jsonConfig}", found: "${json5ConfigSchema.url}"
|
|
533
|
+
// [446] Could not read .vscode/settings.json file: ${error.message}
|
package/lib/M500_Code.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
This module is a support module for iobroker.repochecker
|
|
4
4
|
|
|
5
5
|
Area checked: Adapter Code
|
|
6
|
-
Numbering : 500 -
|
|
6
|
+
Numbering : 500 - 549
|
|
7
7
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
@@ -100,6 +100,38 @@ async function checkCode(context) {
|
|
|
100
100
|
readFiles.push(`/${context.packageJson.main}`);
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
+
// Add all executable files to readFiles for proper lib/tools.js usage scanning
|
|
104
|
+
// We need to discover files first to know which ones to read
|
|
105
|
+
let tempFilesList = [];
|
|
106
|
+
if (common.isLocal()) {
|
|
107
|
+
// For local mode, scan the directory to find all files first
|
|
108
|
+
tempFilesList = getAllFiles(process.cwd(), '', []);
|
|
109
|
+
} else {
|
|
110
|
+
// For remote mode, we'll need to get the files list first
|
|
111
|
+
tempFilesList = await common.getFilesList(context);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// Add all executable files (.js, .mjs, .cjs, .ts) to readFiles, excluding certain directories
|
|
115
|
+
const executableExtensions = ['.js', '.mjs', '.cjs', '.ts'];
|
|
116
|
+
const excludeDirsForExecutables = ['node_modules', 'admin', 'admin-src', '.git', '.vscode', '.dev-server'];
|
|
117
|
+
|
|
118
|
+
tempFilesList.forEach(filePath => {
|
|
119
|
+
// Skip files in excluded directories
|
|
120
|
+
const pathParts = filePath.split('/').filter(part => part !== '');
|
|
121
|
+
const isInExcludedDir = pathParts.some(part => excludeDirsForExecutables.includes(part));
|
|
122
|
+
|
|
123
|
+
if (!isInExcludedDir) {
|
|
124
|
+
const ext = path.extname(filePath);
|
|
125
|
+
if (executableExtensions.includes(ext)) {
|
|
126
|
+
// Ensure the file path starts with /
|
|
127
|
+
const normalizedPath = filePath.startsWith('/') ? filePath : `/${filePath}`;
|
|
128
|
+
if (!readFiles.includes(normalizedPath)) {
|
|
129
|
+
readFiles.push(normalizedPath);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
|
|
103
135
|
// if (!context.ioPackageJson.common.noConfig) {
|
|
104
136
|
// if (context.ioPackageJson.common.materialize || (context.ioPackageJson.common.adminUI && context.ioPackageJson.common.adminUI.config === 'materialize')) {
|
|
105
137
|
// readFiles.push('admin/index_m.html');
|
|
@@ -297,8 +329,8 @@ async function checkCode(context) {
|
|
|
297
329
|
context.errors.push(`[E509] Cannot parse "admin/i18n/${lang}.json": ${e}`);
|
|
298
330
|
}
|
|
299
331
|
} else {
|
|
300
|
-
context.
|
|
301
|
-
`[
|
|
332
|
+
context.errors.push(
|
|
333
|
+
`[E510] "/admin/i18n/${lang}/translations.json" or "admin/i18n/${lang}.json" not found, but admin support is declared. Please add.`,
|
|
302
334
|
);
|
|
303
335
|
}
|
|
304
336
|
});
|
|
@@ -491,7 +523,105 @@ async function checkCode(context) {
|
|
|
491
523
|
}
|
|
492
524
|
}
|
|
493
525
|
|
|
494
|
-
//
|
|
526
|
+
// Check for outdated lib/tools.js
|
|
527
|
+
if (context.filesList.includes('/lib/tools.js')) {
|
|
528
|
+
// Check if lib/tools.js is used anywhere in the repository
|
|
529
|
+
let isUsed = false;
|
|
530
|
+
|
|
531
|
+
// Search through all loaded files for references to tools.js
|
|
532
|
+
for (const fileName of Object.keys(context)) {
|
|
533
|
+
if (fileName.startsWith('/') && typeof context[fileName] === 'string') {
|
|
534
|
+
const content = context[fileName];
|
|
535
|
+
// Look for various patterns that might reference lib/tools.js
|
|
536
|
+
if (
|
|
537
|
+
content.includes('lib/tools') ||
|
|
538
|
+
content.includes('./lib/tools') ||
|
|
539
|
+
content.includes('../lib/tools')
|
|
540
|
+
) {
|
|
541
|
+
isUsed = true;
|
|
542
|
+
break;
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
if (!isUsed) {
|
|
548
|
+
context.warnings.push(
|
|
549
|
+
'[S532] "lib/tools.js" found in repo but not used anywhere. Consider removing this outdated file.',
|
|
550
|
+
);
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
// Check for deprecated adapter methods (createState, createChannel, createDevice, deleteState, deleteChannel, deleteDevice)
|
|
555
|
+
const deprecatedMethods = [
|
|
556
|
+
'createState',
|
|
557
|
+
'createChannel',
|
|
558
|
+
'createDevice',
|
|
559
|
+
'deleteState',
|
|
560
|
+
'deleteChannel',
|
|
561
|
+
'deleteDevice',
|
|
562
|
+
];
|
|
563
|
+
|
|
564
|
+
// Track which deprecated methods have already been reported
|
|
565
|
+
const reportedMethods = new Set();
|
|
566
|
+
|
|
567
|
+
// Search through all loaded executable files for deprecated method usage
|
|
568
|
+
for (const fileName of Object.keys(context)) {
|
|
569
|
+
if (fileName.startsWith('/') && typeof context[fileName] === 'string') {
|
|
570
|
+
// Skip files in excluded directories (admin, tests, etc.)
|
|
571
|
+
const pathParts = fileName.split('/').filter(part => part !== '');
|
|
572
|
+
const isInExcludedDir = pathParts.some(part => excludeDirsForExecutables.includes(part));
|
|
573
|
+
|
|
574
|
+
if (isInExcludedDir) {
|
|
575
|
+
continue;
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
// Only check executable files
|
|
579
|
+
const ext = path.extname(fileName);
|
|
580
|
+
const executableExtensions = ['.js', '.mjs', '.cjs', '.ts'];
|
|
581
|
+
if (!executableExtensions.includes(ext)) {
|
|
582
|
+
continue;
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
const content = context[fileName];
|
|
586
|
+
const lines = content.split(/\r\n|\r|\n/g);
|
|
587
|
+
|
|
588
|
+
for (let i = 0; i < lines.length; i++) {
|
|
589
|
+
const line = lines[i];
|
|
590
|
+
|
|
591
|
+
for (const method of deprecatedMethods) {
|
|
592
|
+
// Skip if this method has already been reported
|
|
593
|
+
if (reportedMethods.has(method)) {
|
|
594
|
+
continue;
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
// Check for this.methodName or adapter.methodName patterns
|
|
598
|
+
const patterns = [
|
|
599
|
+
new RegExp(`\\bthis\\.${method}\\s*\\(`, 'g'),
|
|
600
|
+
new RegExp(`\\badapter\\.${method}\\s*\\(`, 'g'),
|
|
601
|
+
];
|
|
602
|
+
|
|
603
|
+
for (const pattern of patterns) {
|
|
604
|
+
if (pattern.test(line)) {
|
|
605
|
+
// Make sure this is not a private function definition
|
|
606
|
+
const functionDefPattern = new RegExp(
|
|
607
|
+
`(function\\s+${method}|${method}\\s*[=:]\\s*function|${method}\\s*\\([^)]*\\)\\s*{)`,
|
|
608
|
+
'i',
|
|
609
|
+
);
|
|
610
|
+
if (!functionDefPattern.test(line)) {
|
|
611
|
+
context.warnings.push(
|
|
612
|
+
`[W533] method "${method}()" is deprecated and will be removed with future js-controller version. Please use "set/deleteObject()" instead.`,
|
|
613
|
+
);
|
|
614
|
+
reportedMethods.add(method);
|
|
615
|
+
}
|
|
616
|
+
break; // Only warn once per line
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
// first free 0534
|
|
495
625
|
// 550 - xxx reserved for jsonConfig module
|
|
496
626
|
|
|
497
627
|
return context;
|
|
@@ -540,5 +670,7 @@ exports.checkCode = checkCode;
|
|
|
540
670
|
// [529] Plugin "manual-review" missing at .releaseconfig.json. Please add.
|
|
541
671
|
// [530] .releaseconfig.json is no valid json file - ${e}.
|
|
542
672
|
// [531] "gulpfile.js" found in repo with @iobroker/adapter-dev. Check if gulp is still needed.
|
|
673
|
+
// [532] "lib/tools.js" found in repo but not used anywhere. Consider removing this outdated file.
|
|
674
|
+
// [533] method "${method}()" is deprecated and will be removed with future js-controller version. Please use "set/deleteObject()" instead.
|
|
543
675
|
|
|
544
676
|
// [550 - ] see M500_jsonConfig.js
|
package/lib/M500__JsonConfig.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
This module is a support module for iobroker.repochecker
|
|
4
4
|
|
|
5
5
|
Area checked: Adapter Code
|
|
6
|
-
Numbering :
|
|
6
|
+
Numbering : 550 - 599
|
|
7
7
|
|
|
8
8
|
Extension to check jsonConfig
|
|
9
9
|
|
|
@@ -127,7 +127,7 @@ function handleResponsiveError(context, msg) {
|
|
|
127
127
|
responsiveErrorLimit--;
|
|
128
128
|
if (responsiveErrorLimit === 0) {
|
|
129
129
|
context.errors.push(
|
|
130
|
-
`[
|
|
130
|
+
`[E560] responsive check: maximum issues reached, please fix reported ones and recheck`,
|
|
131
131
|
);
|
|
132
132
|
}
|
|
133
133
|
}
|
|
@@ -139,7 +139,7 @@ function handleResponsiveWarning(context, msg) {
|
|
|
139
139
|
responsiveWarningLimit--;
|
|
140
140
|
if (responsiveWarningLimit === 0) {
|
|
141
141
|
context.warnings.push(
|
|
142
|
-
`[
|
|
142
|
+
`[W560] responsive check: maximum issues reached, please fix reported ones and recheck`,
|
|
143
143
|
);
|
|
144
144
|
}
|
|
145
145
|
}
|
|
@@ -164,7 +164,7 @@ function chk_responsive(context, path, jsonConfig, component, opts) {
|
|
|
164
164
|
if (missing.length) {
|
|
165
165
|
handleResponsiveError(
|
|
166
166
|
context,
|
|
167
|
-
`[
|
|
167
|
+
`[E557] missing size attributes [${missing.join(',')}] for ${component} at ${path}`,
|
|
168
168
|
);
|
|
169
169
|
}
|
|
170
170
|
}
|
|
@@ -173,7 +173,7 @@ function chk_responsive(context, path, jsonConfig, component, opts) {
|
|
|
173
173
|
if (jsonConfig[size] !== undefined && (jsonConfig[size] > 12 || jsonConfig[size] <= 0)) {
|
|
174
174
|
handleResponsiveError(
|
|
175
175
|
context,
|
|
176
|
-
`[
|
|
176
|
+
`[E561] invalid size attributes "${size}":"${jsonConfig[size]}" for ${component} at ${path}. Value must be 1 to 12.`,
|
|
177
177
|
);
|
|
178
178
|
}
|
|
179
179
|
}
|
|
@@ -181,7 +181,7 @@ function chk_responsive(context, path, jsonConfig, component, opts) {
|
|
|
181
181
|
if (!opts.sizesOptional && jsonConfig.xs && jsonConfig.xs != 12) {
|
|
182
182
|
handleResponsiveWarning(
|
|
183
183
|
context,
|
|
184
|
-
`[
|
|
184
|
+
`[W558] attribute "xs" for ${component} should specify a value of "12" at ${path}`,
|
|
185
185
|
);
|
|
186
186
|
}
|
|
187
187
|
|
|
@@ -192,7 +192,7 @@ function chk_responsive(context, path, jsonConfig, component, opts) {
|
|
|
192
192
|
if (jsonConfig.sm && jsonConfig.sm > ii) {
|
|
193
193
|
handleResponsiveError(
|
|
194
194
|
context,
|
|
195
|
-
`[
|
|
195
|
+
`[E559] "sm" value (${jsonConfig.sm}) for ${component} greater then value for smaller displays`,
|
|
196
196
|
);
|
|
197
197
|
} else {
|
|
198
198
|
ii = jsonConfig.sm;
|
|
@@ -200,7 +200,7 @@ function chk_responsive(context, path, jsonConfig, component, opts) {
|
|
|
200
200
|
if (jsonConfig.md && jsonConfig.md > ii) {
|
|
201
201
|
handleResponsiveError(
|
|
202
202
|
context,
|
|
203
|
-
`[
|
|
203
|
+
`[E559] "md" value (${jsonConfig.md}) for ${component} greater then value for smaller displays`,
|
|
204
204
|
);
|
|
205
205
|
} else {
|
|
206
206
|
ii = jsonConfig.md;
|
|
@@ -208,7 +208,7 @@ function chk_responsive(context, path, jsonConfig, component, opts) {
|
|
|
208
208
|
if (jsonConfig.lg && jsonConfig.lg > ii) {
|
|
209
209
|
handleResponsiveError(
|
|
210
210
|
context,
|
|
211
|
-
`[
|
|
211
|
+
`[E559] "lg" value (${jsonConfig.lg}) for ${component} greater then value for smaller displays`,
|
|
212
212
|
);
|
|
213
213
|
} else {
|
|
214
214
|
ii = jsonConfig.lg;
|
|
@@ -216,7 +216,7 @@ function chk_responsive(context, path, jsonConfig, component, opts) {
|
|
|
216
216
|
if (jsonConfig.xl && jsonConfig.xl > ii) {
|
|
217
217
|
handleResponsiveError(
|
|
218
218
|
context,
|
|
219
|
-
`[
|
|
219
|
+
`[E559] "xl" value (${jsonConfig.xl}) for ${component} greater then value for smaller displays`,
|
|
220
220
|
);
|
|
221
221
|
}
|
|
222
222
|
}
|
|
@@ -481,12 +481,12 @@ function checkComponent(context, path, jsonConfig) {
|
|
|
481
481
|
|
|
482
482
|
const type = jsonConfig.type;
|
|
483
483
|
if (!type) {
|
|
484
|
-
context.errors.push(`[
|
|
484
|
+
context.errors.push(`[E552] no type specified at ${path}`);
|
|
485
485
|
}
|
|
486
486
|
common.debug(` type ${type}`);
|
|
487
487
|
|
|
488
488
|
if (validComponents[type] === undefined) {
|
|
489
|
-
context.errors.push(`[
|
|
489
|
+
context.errors.push(`[E554] unexpected component "${type}" detected at ${path}`);
|
|
490
490
|
} else if (typeof validComponents[type] === 'function') {
|
|
491
491
|
validComponents[type](context, path, jsonConfig, false);
|
|
492
492
|
} else {
|
|
@@ -510,7 +510,7 @@ function checkPanel(context, path, jsonConfig, isRoot) {
|
|
|
510
510
|
common.debug(` scanning ${key}`);
|
|
511
511
|
|
|
512
512
|
if (!validAttributes.includes(key)) {
|
|
513
|
-
context.errors.push(`[
|
|
513
|
+
context.errors.push(`[E553] unexpected type "${key}" detected at ${path}`);
|
|
514
514
|
}
|
|
515
515
|
|
|
516
516
|
if (key === 'type') {
|
|
@@ -525,7 +525,7 @@ function checkPanel(context, path, jsonConfig, isRoot) {
|
|
|
525
525
|
const type = jsonConfig['items'][subkey].type;
|
|
526
526
|
common.debug(` item ${subkey} / ${type}`);
|
|
527
527
|
if (!type) {
|
|
528
|
-
context.errors.push(`[
|
|
528
|
+
context.errors.push(`[E552] no type specified at ${path}`);
|
|
529
529
|
}
|
|
530
530
|
|
|
531
531
|
if (type === 'panel') {
|
|
@@ -561,10 +561,10 @@ function checkTabs(context, path, jsonConfig) {
|
|
|
561
561
|
const type = jsonConfig[key].type;
|
|
562
562
|
common.debug(` item ${key} / ${type}`);
|
|
563
563
|
if (!type) {
|
|
564
|
-
context.errors.push(`[
|
|
564
|
+
context.errors.push(`[E552] no type specified at ${path}; expected "panel"`);
|
|
565
565
|
}
|
|
566
566
|
if (type !== 'panel') {
|
|
567
|
-
context.errors.push(`[
|
|
567
|
+
context.errors.push(`[E553] unexpected type "${key}" detected at ${path}; expected "panel"`);
|
|
568
568
|
} else {
|
|
569
569
|
checkPanel(context, `${path}/${key}`, jsonConfig[key]);
|
|
570
570
|
}
|
|
@@ -590,7 +590,7 @@ function checkJsonConfig(context, path, jsonConfig) {
|
|
|
590
590
|
baseType = jsonConfig['type'];
|
|
591
591
|
common.debug(` base type ${baseType}`);
|
|
592
592
|
if (!validTypes.includes(baseType)) {
|
|
593
|
-
context.errors.push(`[
|
|
593
|
+
context.errors.push(`[E550] unexpected base type "!${baseType}" detected at ${path}`);
|
|
594
594
|
}
|
|
595
595
|
}
|
|
596
596
|
|
|
@@ -606,7 +606,7 @@ function checkJsonConfig(context, path, jsonConfig) {
|
|
|
606
606
|
common.debug(``);
|
|
607
607
|
common.debug(`scanning base attribute ${key}`);
|
|
608
608
|
if (!validAttributes.includes(key)) {
|
|
609
|
-
context.errors.push(`[
|
|
609
|
+
context.errors.push(`[E551] unexpected attribute "${key}" detected at ${path}`);
|
|
610
610
|
}
|
|
611
611
|
if (key === 'items') {
|
|
612
612
|
if (baseType == 'panel') {
|
|
@@ -625,15 +625,15 @@ exports.checkJsonConfig = checkJsonConfig;
|
|
|
625
625
|
// List of error and warnings used at this module
|
|
626
626
|
// ----------------------------------------------
|
|
627
627
|
|
|
628
|
-
// [
|
|
629
|
-
// [
|
|
630
|
-
// [
|
|
631
|
-
// [
|
|
632
|
-
// [
|
|
633
|
-
// [
|
|
634
|
-
// [
|
|
635
|
-
// [
|
|
636
|
-
// [
|
|
637
|
-
// [
|
|
638
|
-
// [
|
|
639
|
-
// [
|
|
628
|
+
// [550] unexpected base type "!${baseType}" detected at ${path}
|
|
629
|
+
// [551] unexpected attribute "${key}" detected at ${path}
|
|
630
|
+
// [552] no type specified at ${path}
|
|
631
|
+
// [553] unexpected type "${key}" detected at ${path}
|
|
632
|
+
// [554] unexpected component "${type}" detected at ${path}
|
|
633
|
+
// [555]
|
|
634
|
+
// [556]
|
|
635
|
+
// [557] responsive check: missing size attributes [${missing.join(',')}] at ${path}
|
|
636
|
+
// [558] responsive check: attribute "xs" should specify a value of "12" at ${path}
|
|
637
|
+
// [559] responsive check: "sm" value (${jsonConfig.sm}) greater then value for smaller displays
|
|
638
|
+
// [560] responsive check: maximum issues reached, please fix reported ones and recheck
|
|
639
|
+
// [561] invalid size attributes "${size}":"${jsonConfig[size]}" for ${component} at ${path}. Value must be 1 to 12.
|
package/lib/M800_Github.js
CHANGED
|
@@ -16,7 +16,10 @@ const issuesToWatchAsError = [
|
|
|
16
16
|
'Compatibility check and testing for Responsive Design (materialize)',
|
|
17
17
|
];
|
|
18
18
|
|
|
19
|
-
const issuesToWatchAsWarning = [
|
|
19
|
+
const issuesToWatchAsWarning = [
|
|
20
|
+
'Migration to ESLint 9 and @iobroker/eslint-config',
|
|
21
|
+
'Translations update from ioBroker Translation System',
|
|
22
|
+
];
|
|
20
23
|
|
|
21
24
|
// disable axios caching
|
|
22
25
|
axios.defaults.headers.common = {
|
package/lib/M900_GitNpmIgnore.js
CHANGED
|
@@ -79,6 +79,28 @@ async function checkGitIgnore(context) {
|
|
|
79
79
|
}
|
|
80
80
|
});
|
|
81
81
|
}
|
|
82
|
+
|
|
83
|
+
// Check for .commitinfo file presence
|
|
84
|
+
if (context.filesList.includes('/.commitinfo')) {
|
|
85
|
+
context.errors.push('[E905] .commitinfo file found in repository, please remove it');
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Check if .commitinfo is excluded by .gitignore (independent of file presence)
|
|
89
|
+
if (!tooComplexToCheck) {
|
|
90
|
+
const isIgnored = rules.some(rule => {
|
|
91
|
+
if (typeof rule === 'string') {
|
|
92
|
+
return rule === '.commitinfo' || rule === '/.commitinfo';
|
|
93
|
+
}
|
|
94
|
+
return rule.test('.commitinfo');
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
if (!isIgnored) {
|
|
98
|
+
// convert to warning mid of 2026
|
|
99
|
+
context.warnings.push(
|
|
100
|
+
'[S906] .commitinfo file should be excluded by .gitignore, consider adding it to .gitignore',
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
82
104
|
}
|
|
83
105
|
|
|
84
106
|
return context;
|
|
@@ -194,9 +216,12 @@ exports.checkNpmIgnore = checkNpmIgnore;
|
|
|
194
216
|
// [902] node_modules not found in .npmignore
|
|
195
217
|
// [903] iob_npm.done not found in .gitignore
|
|
196
218
|
// [904] file ${file} found in repository, but not found in .gitignore
|
|
219
|
+
// [905] .commitinfo file found in repository, please remove it
|
|
197
220
|
|
|
198
221
|
// [951] .npmignore found but "files" is used at package.json. Please remove .npmignore.
|
|
199
222
|
// [952] .npmignore not found
|
|
200
223
|
// [953] .npmignore found - consider using package.json object "files" instead.
|
|
201
224
|
// [954] node_modules not found in `.npmignore`
|
|
202
225
|
// [955] iob_npm.done not found in .npmignore` ### removed ###
|
|
226
|
+
|
|
227
|
+
// [W906] .commitinfo file should be excluded by .gitignore, consider adding it to .gitignore
|
package/lib/common.js
CHANGED
|
@@ -13,6 +13,10 @@ let gInfo = true;
|
|
|
13
13
|
let gSuccess = false;
|
|
14
14
|
let gLocal = false;
|
|
15
15
|
|
|
16
|
+
// Cache for getFilesList and getFile functions
|
|
17
|
+
const filesListCache = new Map();
|
|
18
|
+
const fileCache = new Map();
|
|
19
|
+
|
|
16
20
|
// disable axios caching
|
|
17
21
|
axios.defaults.headers.common = {
|
|
18
22
|
'Cache-Control': 'no-cache',
|
|
@@ -103,6 +107,15 @@ async function downloadURL(url, binary) {
|
|
|
103
107
|
}
|
|
104
108
|
|
|
105
109
|
async function getFile(context, path, binary) {
|
|
110
|
+
// Create cache key based on context and path
|
|
111
|
+
const cacheKey = context ? `${context.repository}@${context.lastCommitSha}${path || ''}` : `local:${path}`;
|
|
112
|
+
|
|
113
|
+
// Check if file is already cached
|
|
114
|
+
if (fileCache.has(cacheKey)) {
|
|
115
|
+
debug(`Retrieved file from cache: ${cacheKey}`);
|
|
116
|
+
return fileCache.get(cacheKey);
|
|
117
|
+
}
|
|
118
|
+
|
|
106
119
|
let file;
|
|
107
120
|
if (!isLocal()) {
|
|
108
121
|
const url = context
|
|
@@ -115,10 +128,24 @@ async function getFile(context, path, binary) {
|
|
|
115
128
|
path = path.replace(/^\/+/, '');
|
|
116
129
|
file = await fs.readFile(path, binary ? null : 'utf8');
|
|
117
130
|
}
|
|
131
|
+
|
|
132
|
+
// Cache the result
|
|
133
|
+
fileCache.set(cacheKey, file);
|
|
134
|
+
debug(`Cached file: ${cacheKey}`);
|
|
135
|
+
|
|
118
136
|
return file;
|
|
119
137
|
}
|
|
120
138
|
|
|
121
139
|
async function getFilesList(context) {
|
|
140
|
+
// Create cache key based on repository and commit SHA
|
|
141
|
+
const cacheKey = `${context.repository}@${context.lastCommitSha}`;
|
|
142
|
+
|
|
143
|
+
// Check if files list is already cached
|
|
144
|
+
if (filesListCache.has(cacheKey)) {
|
|
145
|
+
debug(`Retrieved files list from cache: ${cacheKey}`);
|
|
146
|
+
return filesListCache.get(cacheKey);
|
|
147
|
+
}
|
|
148
|
+
|
|
122
149
|
const url = `https://data.jsdelivr.com/v1/packages/gh/${context.repository}@${context.lastCommitSha}?structure=flat`;
|
|
123
150
|
debug(`Download ${url}`);
|
|
124
151
|
const filesList = [];
|
|
@@ -149,6 +176,10 @@ async function getFilesList(context) {
|
|
|
149
176
|
debug('Files detected at repository:');
|
|
150
177
|
filesList.forEach(filename => debug(` ${filename}`));
|
|
151
178
|
|
|
179
|
+
// Cache the result
|
|
180
|
+
filesListCache.set(cacheKey, filesList);
|
|
181
|
+
debug(`Cached files list: ${cacheKey}`);
|
|
182
|
+
|
|
152
183
|
return filesList;
|
|
153
184
|
}
|
|
154
185
|
|
package/lib/config.js
CHANGED
|
@@ -422,6 +422,12 @@ const reservedAdapterNames = [
|
|
|
422
422
|
'_design',
|
|
423
423
|
];
|
|
424
424
|
|
|
425
|
+
const schemaUrls = {
|
|
426
|
+
'io-package': 'https://raw.githubusercontent.com/ioBroker/ioBroker.js-controller/master/schemas/io-package.json',
|
|
427
|
+
jsonConfig:
|
|
428
|
+
'https://raw.githubusercontent.com/ioBroker/ioBroker.admin/master/packages/jsonConfig/schemas/jsonConfig.json',
|
|
429
|
+
};
|
|
430
|
+
|
|
425
431
|
function initConfig(context) {
|
|
426
432
|
console.log('[init] initializing configuration');
|
|
427
433
|
|
|
@@ -436,7 +442,7 @@ function initConfig(context) {
|
|
|
436
442
|
return context;
|
|
437
443
|
}
|
|
438
444
|
|
|
439
|
-
function updateConfig(context) {
|
|
445
|
+
async function updateConfig(context) {
|
|
440
446
|
console.log('[init] updating configuration');
|
|
441
447
|
|
|
442
448
|
if (common.isLocal()) {
|
|
@@ -451,6 +457,10 @@ function updateConfig(context) {
|
|
|
451
457
|
context.ioPackageJson.common.adminUI?.custom === 'json'
|
|
452
458
|
);
|
|
453
459
|
|
|
460
|
+
// Check for JSON5 files in the repository
|
|
461
|
+
const filesList = await common.getFilesList(context);
|
|
462
|
+
context.cfg.usesJson5 = filesList.some(file => file.endsWith('.json5') && !file.includes('node_modules'));
|
|
463
|
+
|
|
454
464
|
return context;
|
|
455
465
|
}
|
|
456
466
|
|
|
@@ -470,6 +480,7 @@ function logEnvironment(context) {
|
|
|
470
480
|
common.info('Configuration flags set:');
|
|
471
481
|
common.info(` hasJsonConfig: ${context.cfg.hasJsonConfig ? 'true' : 'false'}`);
|
|
472
482
|
common.info(` onlyWWW: ${context.cfg.onlyWWW ? 'true' : 'false'}`);
|
|
483
|
+
common.info(` usesJson5: ${context.cfg.usesJson5 ? 'true' : 'false'}`);
|
|
473
484
|
|
|
474
485
|
return context;
|
|
475
486
|
}
|
|
@@ -477,3 +488,4 @@ function logEnvironment(context) {
|
|
|
477
488
|
exports.initConfig = initConfig;
|
|
478
489
|
exports.logEnvironment = logEnvironment;
|
|
479
490
|
exports.updateConfig = updateConfig;
|
|
491
|
+
exports.schemaUrls = schemaUrls;
|
package/package.json
CHANGED