@iobroker/repochecker 5.18.2 → 5.18.4
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 +10 -1
- package/lib/M0000_PackageJson.js +3 -2
- package/lib/M1000_IOPackageJson.js +16 -24
- package/lib/M5000_Code.js +67 -34
- package/lib/M5600__I18n.js +8 -1
- package/lib/M6000_Readme.js +1 -1
- package/lib/config_StateRoles.js +6 -4
- package/lib/objectStructure.js +63 -7
- package/lib/postprocessing.js +107 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -25,7 +25,16 @@ Example:
|
|
|
25
25
|
Placeholder for the next version (at the beginning of the line):
|
|
26
26
|
### **WORK IN PROGRESS**
|
|
27
27
|
-->
|
|
28
|
-
### 5.18.
|
|
28
|
+
### 5.18.4 (2026-06-09)
|
|
29
|
+
|
|
30
|
+
- (mcm1957) build directory excluded from I18n scans
|
|
31
|
+
- (mcm1957) Handling of alpha releasea at changelog corrected
|
|
32
|
+
- (mcm1957) Changing text for missing updates limited to 50 days
|
|
33
|
+
- (mcm1957) Encrypted / protected UI data depuplicated
|
|
34
|
+
- (mcm1957) Scanning for sourcefiles and imports corrected
|
|
35
|
+
- (mcm1957) Special filtering added
|
|
36
|
+
|
|
37
|
+
### 5.18.3 (2026-06-06)
|
|
29
38
|
|
|
30
39
|
- (mcm1957) Support for objectStructure check added
|
|
31
40
|
|
package/lib/M0000_PackageJson.js
CHANGED
|
@@ -569,10 +569,11 @@ async function checkNpmDependencyUpdateSuggestions(context) {
|
|
|
569
569
|
return;
|
|
570
570
|
}
|
|
571
571
|
|
|
572
|
-
const dayLabel = packageAgeDays === 1 ? 'day' : 'days';
|
|
573
572
|
const issueCode = updateRule.level === 'W' ? 'W0083' : 'S0082';
|
|
573
|
+
const ageThreshold = Math.floor(packageAgeDays / 50) * 50;
|
|
574
|
+
const ageInfo = ageThreshold >= 50 ? ` The newer version has been published for more than ${ageThreshold} days.` : '';
|
|
574
575
|
context.warnings.push(
|
|
575
|
-
`[${issueCode}] A newer version (${latestVersion}) for package "${packageName}" (${sourceType}) exists
|
|
576
|
+
`[${issueCode}] A newer version (${latestVersion}) for package "${packageName}" (${sourceType}) exists.${ageInfo} Please evaluate if upgrading from ${packageVersion} to ${latestVersion} is possible.`,
|
|
576
577
|
);
|
|
577
578
|
} catch (e) {
|
|
578
579
|
common.debug(
|
|
@@ -388,35 +388,27 @@ async function checkIOPackageJson(context) {
|
|
|
388
388
|
common.debug(`Suspicious key test: suspiciousKeys (filtered): ${suspiciousKeys}`);
|
|
389
389
|
}
|
|
390
390
|
if (suspiciousKeys.length) {
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
`[W1073] Potential sensitive data "${missingProtected.join()}" not listed at "protectedNative" in io-package.json`,
|
|
399
|
-
);
|
|
400
|
-
}
|
|
401
|
-
} else {
|
|
391
|
+
const missingProtected = context.ioPackageJson.protectedNative
|
|
392
|
+
? suspiciousKeys.filter(
|
|
393
|
+
key => !context.ioPackageJson.protectedNative.includes(key),
|
|
394
|
+
)
|
|
395
|
+
: [...suspiciousKeys];
|
|
396
|
+
context.reportedMissingProtectedNativeKeys = missingProtected;
|
|
397
|
+
if (missingProtected.length) {
|
|
402
398
|
context.warnings.push(
|
|
403
|
-
`[W1073] Potential sensitive data "${
|
|
399
|
+
`[W1073] Potential sensitive data "${missingProtected.join()}" not listed at "protectedNative" in io-package.json`,
|
|
404
400
|
);
|
|
405
401
|
}
|
|
406
402
|
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
`[W1074] Potential sensitive data "${missingProtected.join(', ')}" not listed at "encryptedNative" in io-package.json`,
|
|
415
|
-
);
|
|
416
|
-
}
|
|
417
|
-
} else {
|
|
403
|
+
const missingEncrypted = context.ioPackageJson.encryptedNative
|
|
404
|
+
? suspiciousKeys.filter(
|
|
405
|
+
key => !context.ioPackageJson.encryptedNative.includes(key),
|
|
406
|
+
)
|
|
407
|
+
: [...suspiciousKeys];
|
|
408
|
+
context.reportedMissingEncryptedNativeKeys = missingEncrypted;
|
|
409
|
+
if (missingEncrypted.length) {
|
|
418
410
|
context.warnings.push(
|
|
419
|
-
`[W1074] Potential sensitive data "${
|
|
411
|
+
`[W1074] Potential sensitive data "${missingEncrypted.join(', ')}" not listed at "encryptedNative" in io-package.json`,
|
|
420
412
|
);
|
|
421
413
|
}
|
|
422
414
|
}
|
package/lib/M5000_Code.js
CHANGED
|
@@ -1203,6 +1203,12 @@ async function checkCode(context) {
|
|
|
1203
1203
|
const encryptedNative = new Set(
|
|
1204
1204
|
Array.isArray(context.ioPackageJson.encryptedNative) ? context.ioPackageJson.encryptedNative : [],
|
|
1205
1205
|
);
|
|
1206
|
+
const reportedProtectedKeys = new Set(
|
|
1207
|
+
Array.isArray(context.reportedMissingProtectedNativeKeys) ? context.reportedMissingProtectedNativeKeys : [],
|
|
1208
|
+
);
|
|
1209
|
+
const reportedEncryptedKeys = new Set(
|
|
1210
|
+
Array.isArray(context.reportedMissingEncryptedNativeKeys) ? context.reportedMissingEncryptedNativeKeys : [],
|
|
1211
|
+
);
|
|
1206
1212
|
const passwordLocations = new Map();
|
|
1207
1213
|
|
|
1208
1214
|
for (const adminFile of context.filesList) {
|
|
@@ -1225,19 +1231,28 @@ async function checkCode(context) {
|
|
|
1225
1231
|
}
|
|
1226
1232
|
}
|
|
1227
1233
|
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
);
|
|
1234
|
+
const missingProtected = [];
|
|
1235
|
+
const missingEncrypted = [];
|
|
1236
|
+
|
|
1237
|
+
for (const [nativeKey] of passwordLocations.entries()) {
|
|
1238
|
+
if (!protectedNative.has(nativeKey) && !reportedProtectedKeys.has(nativeKey)) {
|
|
1239
|
+
missingProtected.push(nativeKey);
|
|
1234
1240
|
}
|
|
1235
|
-
if (!encryptedNative.has(nativeKey)) {
|
|
1236
|
-
|
|
1237
|
-
`[W5058] jsonConfig password field "${nativeKey}" (${locationList}) is not listed at "encryptedNative" in io-package.json`,
|
|
1238
|
-
);
|
|
1241
|
+
if (!encryptedNative.has(nativeKey) && !reportedEncryptedKeys.has(nativeKey)) {
|
|
1242
|
+
missingEncrypted.push(nativeKey);
|
|
1239
1243
|
}
|
|
1240
1244
|
}
|
|
1245
|
+
|
|
1246
|
+
if (missingProtected.length) {
|
|
1247
|
+
context.warnings.push(
|
|
1248
|
+
`[W5057] jsonConfig password field(s) "${missingProtected.join(', ')}" is not listed at "protectedNative" in io-package.json`,
|
|
1249
|
+
);
|
|
1250
|
+
}
|
|
1251
|
+
if (missingEncrypted.length) {
|
|
1252
|
+
context.warnings.push(
|
|
1253
|
+
`[W5058] jsonConfig password field(s) "${missingEncrypted.join(', ')}" is not listed at "encryptedNative" in io-package.json`,
|
|
1254
|
+
);
|
|
1255
|
+
}
|
|
1241
1256
|
}
|
|
1242
1257
|
|
|
1243
1258
|
// Check for table/accordion components with encryptedAttributes requiring js-controller >= 7.0.7
|
|
@@ -1779,29 +1794,44 @@ async function checkCode(context) {
|
|
|
1779
1794
|
// Exclude files in admin/, build/, doc/, docs/, src-admin/, admin-src/, test/ directories
|
|
1780
1795
|
// and *.test.* and *.config.* files
|
|
1781
1796
|
const sourceFileExtensions = new Set(['.js', '.mjs', '.cjs', '.ts']);
|
|
1797
|
+
// '/path' entries match repository root directories only, while entries without '/'
|
|
1798
|
+
// match directory names at any level in the repository tree.
|
|
1782
1799
|
const excludedSourceDirs = new Set([
|
|
1783
|
-
'admin',
|
|
1784
|
-
'build',
|
|
1785
|
-
'doc',
|
|
1786
|
-
'docs',
|
|
1787
|
-
'scripts',
|
|
1788
|
-
'template',
|
|
1789
|
-
'templates',
|
|
1790
|
-
'src-admin',
|
|
1791
|
-
'src-editor', // java-script adapter
|
|
1792
|
-
'src-rules',
|
|
1793
|
-
'src-widgets',
|
|
1794
|
-
'www',
|
|
1795
|
-
'widgets',
|
|
1796
|
-
'admin-src',
|
|
1797
|
-
'rules-src',
|
|
1798
|
-
'test',
|
|
1799
|
-
'node_modules',
|
|
1800
|
-
'
|
|
1801
|
-
'
|
|
1802
|
-
'
|
|
1803
|
-
'hass_frontend', // special for ioBroker.hass
|
|
1800
|
+
'/admin',
|
|
1801
|
+
'/build',
|
|
1802
|
+
'/doc',
|
|
1803
|
+
'/docs',
|
|
1804
|
+
'/scripts',
|
|
1805
|
+
'/template',
|
|
1806
|
+
'/templates',
|
|
1807
|
+
'/src-admin',
|
|
1808
|
+
'/src-editor', // java-script adapter
|
|
1809
|
+
'/src-rules',
|
|
1810
|
+
'/src-widgets',
|
|
1811
|
+
'/www',
|
|
1812
|
+
'/widgets',
|
|
1813
|
+
'/admin-src',
|
|
1814
|
+
'/rules-src',
|
|
1815
|
+
'/test',
|
|
1816
|
+
'/node_modules',
|
|
1817
|
+
'/.git',
|
|
1818
|
+
'/.vscode',
|
|
1819
|
+
'/.dev-server',
|
|
1820
|
+
'/hass_frontend', // special for ioBroker.hass
|
|
1821
|
+
'tmp',
|
|
1804
1822
|
]);
|
|
1823
|
+
const excludedSourceRootDirNames = new Set();
|
|
1824
|
+
const excludedSourceAnyLevelDirs = new Set();
|
|
1825
|
+
for (const excludedSourceDir of excludedSourceDirs) {
|
|
1826
|
+
if (excludedSourceDir.startsWith('/')) {
|
|
1827
|
+
const rootDirName = excludedSourceDir.slice(1);
|
|
1828
|
+
if (rootDirName) {
|
|
1829
|
+
excludedSourceRootDirNames.add(rootDirName);
|
|
1830
|
+
}
|
|
1831
|
+
} else {
|
|
1832
|
+
excludedSourceAnyLevelDirs.add(excludedSourceDir);
|
|
1833
|
+
}
|
|
1834
|
+
}
|
|
1805
1835
|
// Exact file base names to exclude from scanning
|
|
1806
1836
|
const excludedSourceFiles = new Set(['tasks.js', 'tasks.ts', 'Gruntfile.js', 'gulpfile.js']);
|
|
1807
1837
|
|
|
@@ -1856,7 +1886,10 @@ async function checkCode(context) {
|
|
|
1856
1886
|
|
|
1857
1887
|
// Skip files in excluded directories
|
|
1858
1888
|
const pathParts = filePath.split('/').filter(p => p !== '');
|
|
1859
|
-
|
|
1889
|
+
const isInExcludedSourceRootDir = pathParts.length > 0 && excludedSourceRootDirNames.has(pathParts[0]);
|
|
1890
|
+
const isInExcludedSourceAnyLevelDir = pathParts.some(pathPart => excludedSourceAnyLevelDirs.has(pathPart));
|
|
1891
|
+
const isInExcludedSourceDir = isInExcludedSourceRootDir || isInExcludedSourceAnyLevelDir;
|
|
1892
|
+
if (isInExcludedSourceDir) {
|
|
1860
1893
|
continue;
|
|
1861
1894
|
}
|
|
1862
1895
|
|
|
@@ -2195,8 +2228,8 @@ exports.getFilesList = getFilesList;
|
|
|
2195
2228
|
// [W5054] "admin/blockly.js" found but blockly support is not declared in io-package.json. Consider removing the file or setting "common.blockly": true.
|
|
2196
2229
|
// [W5055] "admin/index.html" found but materialize is used. This file is for admin2 (old UI) and is outdated. Please consider removing it.
|
|
2197
2230
|
// [W5056] "admin/custom.html" or "admin/custom_m.html" is no longer supported. Please migrate to "admin/jsonCustom.json".
|
|
2198
|
-
// [W5057] jsonConfig password field "${
|
|
2199
|
-
// [W5058] jsonConfig password field "${
|
|
2231
|
+
// [W5057] jsonConfig password field(s) "${nativeKey1, nativeKey2}" is not listed at "protectedNative" in io-package.json
|
|
2232
|
+
// [W5058] jsonConfig password field(s) "${nativeKey1, nativeKey2}" is not listed at "encryptedNative" in io-package.json
|
|
2200
2233
|
// [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.
|
|
2201
2234
|
// [W5060] Package "${dependency}" is listed in dependencies of package.json but not imported or required by any scanned source file. Dependency might be unused.
|
|
2202
2235
|
// [W5061] "utils.commonTools.letsEncrypt" usage detected. Let's Encrypt support was removed in js-controller 6.
|
package/lib/M5600__I18n.js
CHANGED
|
@@ -12,7 +12,14 @@ const JSON5 = require('json5');
|
|
|
12
12
|
const common = require('./common.js');
|
|
13
13
|
|
|
14
14
|
// Directories to always exclude when scanning for i18n content
|
|
15
|
-
|
|
15
|
+
// eslint-disable-next-line prettier/prettier
|
|
16
|
+
const I18N_EXCLUDED_DIRS = new Set([
|
|
17
|
+
'node_modules',
|
|
18
|
+
'.git',
|
|
19
|
+
'.vscode',
|
|
20
|
+
'.dev-server',
|
|
21
|
+
'build',
|
|
22
|
+
]);
|
|
16
23
|
|
|
17
24
|
// Translatable attributes in jsonConfig to scan for proper i18n usage.
|
|
18
25
|
// Add new attribute names here to extend the list of attributes checked.
|
package/lib/M6000_Readme.js
CHANGED
|
@@ -385,7 +385,7 @@ async function checkReadme(context) {
|
|
|
385
385
|
context.checks.push('README.md changelog contains "###" entries');
|
|
386
386
|
const invalidVersionHeaders = [];
|
|
387
387
|
for (const header of changelogHeaders) {
|
|
388
|
-
const match = /^(\d+\.\d+\.\d+)(?:\s+.*)?$/.exec(header);
|
|
388
|
+
const match = /^(\d+\.\d+\.\d+(-\w+\.\d+)?)(?:\s+.*)?$/.exec(header);
|
|
389
389
|
if (!match) {
|
|
390
390
|
if (!header.includes('WORK IN PROGRESS') && !header.includes('CHANGELOG_OLD.md')) {
|
|
391
391
|
invalidVersionHeaders.push(header);
|
package/lib/config_StateRoles.js
CHANGED
|
@@ -9,8 +9,10 @@ const ROOT_OBJECT_SCHEMA = {
|
|
|
9
9
|
ts: { type: 'number', optional: true },
|
|
10
10
|
acl: { type: 'object', optional: true },
|
|
11
11
|
user: { type: 'string', optional: true },
|
|
12
|
-
ack: { type: 'boolean', optional: true },
|
|
13
|
-
val: { optional: true, matchesCommonType: true },
|
|
12
|
+
ack: { type: 'boolean', optional: true, stateOnly: true },
|
|
13
|
+
val: { optional: true, matchesCommonType: true, stateOnly: true },
|
|
14
|
+
q: { type: 'number', optional: true, stateOnly: true },
|
|
15
|
+
lc: { type: 'number', optional: true, stateOnly: true },
|
|
14
16
|
};
|
|
15
17
|
|
|
16
18
|
const ALLOWED_OBJECT_TYPES = new Set([
|
|
@@ -54,7 +56,7 @@ const STATE_SCHEMA = {
|
|
|
54
56
|
'common.unit': { types: ['string'] },
|
|
55
57
|
'common.def': { any: true, matchesCommonType: true },
|
|
56
58
|
'common.defAck': { types: ['boolean'] },
|
|
57
|
-
'common.desc': {
|
|
59
|
+
'common.desc': { i18n: true },
|
|
58
60
|
'common.read': { types: ['boolean'], required: true },
|
|
59
61
|
'common.write': { types: ['boolean'], required: true },
|
|
60
62
|
'common.role': { types: ['string'], required: true, role: true },
|
|
@@ -62,7 +64,7 @@ const STATE_SCHEMA = {
|
|
|
62
64
|
'common.workingID': { any: true },
|
|
63
65
|
'common.custom': { any: true },
|
|
64
66
|
'common.type': { types: ['string'], required: true },
|
|
65
|
-
'common.name': { required: true,
|
|
67
|
+
'common.name': { required: true, i18n: true },
|
|
66
68
|
'common.expert': { types: ['boolean'] },
|
|
67
69
|
'common.dontDelete':{ types: ['boolean'] },
|
|
68
70
|
'common.color': { types: ['string'] },
|
package/lib/objectStructure.js
CHANGED
|
@@ -72,11 +72,53 @@ function isPlainObject(value) {
|
|
|
72
72
|
return getValueType(value) === 'object';
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
75
|
+
const I18N_REQUIRED_KEYS = ['en', 'de'];
|
|
76
|
+
const I18N_ALLOWED_KEYS = new Set(['en', 'de', 'ru', 'pt', 'nl', 'fr', 'it', 'es', 'pl', 'uk', 'zh-cn']);
|
|
77
|
+
const I18N_RECOMMENDED_KEYS = ['ru', 'pt', 'nl', 'fr', 'it', 'es', 'pl', 'uk', 'zh-cn'];
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Validates a value that must be either a plain string or an i18n object.
|
|
81
|
+
* Returns an array of error/warning strings (empty = valid).
|
|
82
|
+
*
|
|
83
|
+
* @param {*} value - The value to validate.
|
|
84
|
+
* @param {string} fieldPath - Human-readable path for error messages (e.g. "common.desc").
|
|
85
|
+
* @returns {{ errors: string[], warnings: string[] }}
|
|
86
|
+
*/
|
|
87
|
+
function validateI18n(value, fieldPath) {
|
|
88
|
+
const errors = [];
|
|
89
|
+
const warnings = [];
|
|
90
|
+
|
|
91
|
+
if (typeof value === 'string') return { errors, warnings };
|
|
92
|
+
|
|
93
|
+
if (!isPlainObject(value)) {
|
|
94
|
+
errors.push(`"${fieldPath}" must be a string or an i18n object.`);
|
|
95
|
+
return { errors, warnings };
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Must be an object — validate as i18n
|
|
99
|
+
const keys = Object.keys(value);
|
|
100
|
+
|
|
101
|
+
for (const key of keys) {
|
|
102
|
+
if (!I18N_ALLOWED_KEYS.has(key)) {
|
|
103
|
+
errors.push(`"${fieldPath}" i18n object contains unknown key "${key}".`);
|
|
104
|
+
}
|
|
105
|
+
if (typeof value[key] !== 'string') {
|
|
106
|
+
errors.push(`"${fieldPath}" i18n object key "${key}" must be a string.`);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
for (const required of I18N_REQUIRED_KEYS) {
|
|
111
|
+
if (!Object.prototype.hasOwnProperty.call(value, required)) {
|
|
112
|
+
errors.push(`"${fieldPath}" i18n object is missing required key "${required}".`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const missingRecommended = I18N_RECOMMENDED_KEYS.filter(k => !Object.prototype.hasOwnProperty.call(value, k));
|
|
117
|
+
if (missingRecommended.length > 0) {
|
|
118
|
+
warnings.push(`"${fieldPath}" i18n object is missing recommended keys: ${missingRecommended.join(', ')}.`);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return { errors, warnings };
|
|
80
122
|
}
|
|
81
123
|
|
|
82
124
|
function matchesCommonType(value, commonType) {
|
|
@@ -223,8 +265,14 @@ function validateStateCommon(stateId, common, collector, roleRuleMaps) {
|
|
|
223
265
|
);
|
|
224
266
|
}
|
|
225
267
|
|
|
226
|
-
if (schema.
|
|
227
|
-
|
|
268
|
+
if (schema.i18n) {
|
|
269
|
+
const { errors: i18nErrors, warnings: i18nWarnings } = validateI18n(value, schemaKey);
|
|
270
|
+
for (const msg of i18nErrors) {
|
|
271
|
+
collector.error('E1007', `Object "${stateId}": ${msg}`);
|
|
272
|
+
}
|
|
273
|
+
for (const msg of i18nWarnings) {
|
|
274
|
+
collector.warning('W1001', `Object "${stateId}": ${msg}`);
|
|
275
|
+
}
|
|
228
276
|
}
|
|
229
277
|
|
|
230
278
|
if (schema.role) {
|
|
@@ -337,6 +385,14 @@ function validateObjectDump(objects, adapter, collector) {
|
|
|
337
385
|
// optional + absent → silently skip
|
|
338
386
|
continue;
|
|
339
387
|
}
|
|
388
|
+
// stateOnly keys are only permitted on objects of type 'state'
|
|
389
|
+
if (descriptor.stateOnly && objectData.type !== 'state') {
|
|
390
|
+
collector.error(
|
|
391
|
+
'E3005',
|
|
392
|
+
`Object "${objectId}": key "${schemaKey}" is only allowed on objects of type "state".`,
|
|
393
|
+
);
|
|
394
|
+
continue;
|
|
395
|
+
}
|
|
340
396
|
const actualType = getValueType(objectData[schemaKey]);
|
|
341
397
|
if (descriptor.type && actualType !== descriptor.type) {
|
|
342
398
|
collector.error(
|
package/lib/postprocessing.js
CHANGED
|
@@ -7,10 +7,34 @@
|
|
|
7
7
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
+
const common = require('./common.js');
|
|
11
|
+
|
|
10
12
|
// ---------------------------------------------------------------------------
|
|
11
13
|
// Configuration tables
|
|
12
14
|
// ---------------------------------------------------------------------------
|
|
13
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Per-adapter issue filter table (used by filterIssuesByAdapter).
|
|
18
|
+
*
|
|
19
|
+
* Key : adapter name without the "ioBroker." prefix and without owner,
|
|
20
|
+
* e.g. 'backitup'.
|
|
21
|
+
* Value : array of issue text patterns to suppress for that adapter.
|
|
22
|
+
* Each pattern is matched against the full issue string.
|
|
23
|
+
* The wildcard character '*' may appear anywhere in the pattern
|
|
24
|
+
* and matches any sequence of characters (including the empty string).
|
|
25
|
+
*
|
|
26
|
+
* Example entry:
|
|
27
|
+
* backitup: [
|
|
28
|
+
* '[E5050] process.exit() used in * (lib/restore.js)*',
|
|
29
|
+
* ],
|
|
30
|
+
*/
|
|
31
|
+
const filterByAdapter = {
|
|
32
|
+
// eslint-disable-next-line prettier/prettier
|
|
33
|
+
backitup: [
|
|
34
|
+
'[E5050] process.exit() used in * (lib/restore.js)*',
|
|
35
|
+
],
|
|
36
|
+
};
|
|
37
|
+
|
|
14
38
|
/**
|
|
15
39
|
* Severity remapping table for new adapters (used by adaptSeverity4New).
|
|
16
40
|
*
|
|
@@ -41,7 +65,7 @@ const mapSeverity4New = {
|
|
|
41
65
|
W5018: 'E', // [W5018] "@alcalzone/release-script" (>=3.0.0) is used, but ".releaseconfig.json" not found. Please create.',
|
|
42
66
|
W5512: 'E', // [W5512] admin/jsonConfig.json schema validation error: ...
|
|
43
67
|
W5612: 'E', // W5612] "admin/jsonConfig.json/items/..." attribute "label" uses key "..." which is not found in the English translation file at "admin/i18n/en".
|
|
44
|
-
W6020: 'E', // [W6020] Consider adding a CHANGELOG_OLD.md file to store older changelog entries.
|
|
68
|
+
W6020: 'E', // [W6020] Consider adding a CHANGELOG_OLD.md file to store older changelog entries.
|
|
45
69
|
W6021: 'E', // [W6021] "## License" is not the last section in README.md.
|
|
46
70
|
W8915: 'E', // [W8915] Dependabot npm entry (directory: "/") has no "cooldown" configured.
|
|
47
71
|
W8916: 'E', // [W8916] Dependabot configuration "/.github/dependabot.yml" has no entry with "package-ecosystem: github-actions".
|
|
@@ -70,6 +94,87 @@ const mapSeverity4New = {
|
|
|
70
94
|
// Postprocessing tasks
|
|
71
95
|
// ---------------------------------------------------------------------------
|
|
72
96
|
|
|
97
|
+
/**
|
|
98
|
+
* Tests whether a single issue string matches a filter pattern.
|
|
99
|
+
* The pattern may contain '*' as a wildcard that matches any sequence of
|
|
100
|
+
* characters (including the empty string). All other characters are treated
|
|
101
|
+
* as literals.
|
|
102
|
+
*
|
|
103
|
+
* @param {string} issue - The full issue text to test
|
|
104
|
+
* @param {string} pattern - The pattern, optionally containing '*' wildcards
|
|
105
|
+
* @returns {boolean} true if the issue matches the pattern
|
|
106
|
+
*/
|
|
107
|
+
function matchesPattern(issue, pattern) {
|
|
108
|
+
// Split on '*' so each segment can be escaped independently, then
|
|
109
|
+
// rejoin with '.*' to form a full-match regular expression.
|
|
110
|
+
const segments = pattern.split('*');
|
|
111
|
+
const regexStr = segments.map(s => s.replace(/[.+?^${}()|[\]\\]/g, '\\$&')).join('.*');
|
|
112
|
+
const regex = new RegExp('^' + regexStr + '$');
|
|
113
|
+
return regex.test(issue);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Removes issues from context.errors and context.warnings that match any
|
|
118
|
+
* filter pattern defined for the current adapter in filterByAdapter.
|
|
119
|
+
*
|
|
120
|
+
* If context.adapterName is not set, or no entry exists for that adapter
|
|
121
|
+
* in filterByAdapter, the function returns immediately without changes.
|
|
122
|
+
*
|
|
123
|
+
* For every removed issue an info message is logged via common.info().
|
|
124
|
+
* If at least one issue was removed a summary suggestion
|
|
125
|
+
* "[S0000] Info: ### issues ignored for this adapter." is appended to
|
|
126
|
+
* context.warnings (where ### is the count of removed issues).
|
|
127
|
+
*
|
|
128
|
+
* @param {object} context - The checker context
|
|
129
|
+
* @returns {object} The (possibly modified) context
|
|
130
|
+
*/
|
|
131
|
+
function filterIssuesByAdapter(context) {
|
|
132
|
+
const adapterName = context.adapterName;
|
|
133
|
+
if (!adapterName) {
|
|
134
|
+
return context;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const patterns = filterByAdapter[adapterName];
|
|
138
|
+
if (!patterns || patterns.length === 0) {
|
|
139
|
+
return context;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
let removedCount = 0;
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Scan one issue array in-place and remove entries matching any pattern.
|
|
146
|
+
*
|
|
147
|
+
* @param {string[]} arr - context.errors or context.warnings
|
|
148
|
+
*/
|
|
149
|
+
function filterArray(arr) {
|
|
150
|
+
for (let i = arr.length - 1; i >= 0; i--) {
|
|
151
|
+
const issue = arr[i];
|
|
152
|
+
for (const pattern of patterns) {
|
|
153
|
+
if (matchesPattern(issue, pattern)) {
|
|
154
|
+
common.info(
|
|
155
|
+
`[postprocessing] filterIssuesByAdapter: removed issue for adapter "${adapterName}": ${issue}`,
|
|
156
|
+
);
|
|
157
|
+
arr.splice(i, 1);
|
|
158
|
+
removedCount++;
|
|
159
|
+
break; // no need to check further patterns for this issue
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
filterArray(context.errors);
|
|
166
|
+
filterArray(context.warnings);
|
|
167
|
+
|
|
168
|
+
if (removedCount > 0) {
|
|
169
|
+
common.info(
|
|
170
|
+
`[postprocessing] filterIssuesByAdapter: ${removedCount} issue(s) ignored for adapter "${adapterName}".`,
|
|
171
|
+
);
|
|
172
|
+
context.warnings.push(`[S0000] Info: ${removedCount} issue(s) ignored for this adapter.`);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
return context;
|
|
176
|
+
}
|
|
177
|
+
|
|
73
178
|
/**
|
|
74
179
|
* Remaps the severity of issues for new adapters according to mapSeverity4New.
|
|
75
180
|
*
|
|
@@ -159,6 +264,7 @@ function postprocessing(context) {
|
|
|
159
264
|
console.log('\n[postprocessing] running postprocessing tasks');
|
|
160
265
|
|
|
161
266
|
adaptSeverity4New(context);
|
|
267
|
+
filterIssuesByAdapter(context);
|
|
162
268
|
|
|
163
269
|
return context;
|
|
164
270
|
}
|
package/package.json
CHANGED