@iobroker/repochecker 4.2.0 → 4.3.0-alpha.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 +4 -1
- package/lib/M000_PackageJson.js +57 -1
- package/lib/M500_Code.js +40 -28
- package/lib/M800_Github.js +8 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -31,8 +31,11 @@ npx @iobroker/repochecker https://github.com/ioBroker/ioBroker.javascript --loca
|
|
|
31
31
|
Placeholder for the next version (at the beginning of the line):
|
|
32
32
|
### **WORK IN PROGRESS**
|
|
33
33
|
-->
|
|
34
|
+
### 4.3.0-alpha.0 (2025-09-29)
|
|
35
|
+
- (@copilot) Added version format validation check (E061) for invalid semver format according to ioBroker requirements
|
|
36
|
+
- (@copilot) Added structured GitHub issue templates for bug reports, false positives, new checks, check changes, and enhancements
|
|
37
|
+
- (@copilot) Fixed deprecated function checking for adapter methods called outside class context
|
|
34
38
|
|
|
35
|
-
## Changelog
|
|
36
39
|
### 4.2.0 (2025-09-20)
|
|
37
40
|
- (mcm1957) 'Request' replacement text changed to suggest 'node:fetch' [#498].
|
|
38
41
|
- (@copilot) Fixed false positive W533 warnings for deprecated adapter methods when called on local functions with same names [#520].
|
package/lib/M000_PackageJson.js
CHANGED
|
@@ -234,6 +234,52 @@ const validObjectsPackageJson = [
|
|
|
234
234
|
'workspaces',
|
|
235
235
|
];
|
|
236
236
|
|
|
237
|
+
/**
|
|
238
|
+
* Validates release format according to ioBroker semver subset requirements
|
|
239
|
+
*
|
|
240
|
+
* @param {string} version - Version string to validate
|
|
241
|
+
* @returns {boolean} true if valid, false if invalid
|
|
242
|
+
*/
|
|
243
|
+
function validateReleaseFormat(version) {
|
|
244
|
+
if (!version || typeof version !== 'string') {
|
|
245
|
+
return false;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
// Regex to match the specified format:
|
|
249
|
+
// - version must consist of 3 digits separated by a dot
|
|
250
|
+
// - optionally followed by a Prerelease-Identifier, a dot and a Prerelease version
|
|
251
|
+
// - all numbers must not have leading zeroes (except single zero)
|
|
252
|
+
// - Prerelease-Identifier must only contain characters, numbers and a minus sign ([a-zA-Z0-9-])
|
|
253
|
+
// - Prerelease version must be a number without leading zeroes
|
|
254
|
+
// - empty fields resulting in two or more dots following each other are not valid
|
|
255
|
+
|
|
256
|
+
const regex = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([a-zA-Z0-9-]+)\.(0|[1-9]\d*))?$/;
|
|
257
|
+
|
|
258
|
+
const match = version.match(regex);
|
|
259
|
+
if (!match) {
|
|
260
|
+
return false;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
const [, , , , prereleaseId, prereleaseVersion] = match;
|
|
264
|
+
|
|
265
|
+
// Additional validation for prerelease identifier
|
|
266
|
+
if (prereleaseId !== undefined) {
|
|
267
|
+
// Ensure prerelease identifier is valid:
|
|
268
|
+
// - cannot be only numbers (RC5 is invalid)
|
|
269
|
+
// - cannot end with numbers (RC5 is invalid, RC is valid)
|
|
270
|
+
if (/^\d+$/.test(prereleaseId) || /\d+$/.test(prereleaseId)) {
|
|
271
|
+
return false;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// Ensure prerelease version is provided when prerelease ID is present
|
|
275
|
+
if (prereleaseVersion === undefined) {
|
|
276
|
+
return false;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
return true;
|
|
281
|
+
}
|
|
282
|
+
|
|
237
283
|
async function getPackageJson(context) {
|
|
238
284
|
console.log('[init] getting package.json');
|
|
239
285
|
|
|
@@ -362,6 +408,15 @@ async function checkPackageJson(context) {
|
|
|
362
408
|
context.errors.push('[E009] No "version" key found in the package.json');
|
|
363
409
|
} else {
|
|
364
410
|
context.checks.push('Version found in package.json');
|
|
411
|
+
|
|
412
|
+
// Validate version format according to ioBroker requirements
|
|
413
|
+
if (!validateReleaseFormat(context.packageJson.version)) {
|
|
414
|
+
context.errors.push(
|
|
415
|
+
`[E061] Invalid version format "${context.packageJson.version}". Version must follow semver format: MAJOR.MINOR.PATCH or MAJOR.MINOR.PATCH-PRERELEASE.NUMBER (e.g., "1.2.3" or "1.2.3-alpha.4").`,
|
|
416
|
+
);
|
|
417
|
+
} else {
|
|
418
|
+
context.checks.push('Version format is valid');
|
|
419
|
+
}
|
|
365
420
|
}
|
|
366
421
|
|
|
367
422
|
if (!context.packageJson.description) {
|
|
@@ -962,6 +1017,7 @@ async function checkPackageJson(context) {
|
|
|
962
1017
|
|
|
963
1018
|
exports.getPackageJson = getPackageJson;
|
|
964
1019
|
exports.checkPackageJson = checkPackageJson;
|
|
1020
|
+
exports.validateReleaseFormat = validateReleaseFormat;
|
|
965
1021
|
|
|
966
1022
|
// List of error and warnings used at this module
|
|
967
1023
|
// ----------------------------------------------
|
|
@@ -1030,5 +1086,5 @@ exports.checkPackageJson = checkPackageJson;
|
|
|
1030
1086
|
// [058] Key ${objectName} at package.json is not supported. Please remove.
|
|
1031
1087
|
// [059] No "scripts" key found in the package.json.
|
|
1032
1088
|
// [060] ${dependency} listed as dependency and as devDependency.
|
|
1033
|
-
// [061]
|
|
1089
|
+
// [061] Invalid version format "${context.packageJson.version}". Version must follow semver format: MAJOR.MINOR.PATCH or MAJOR.MINOR.PATCH-PRERELEASE.NUMBER (e.g., "1.2.3" or "1.2.3-alpha.4"). No leading zeros allowed, prerelease identifiers must contain only letters, numbers, and hyphens.
|
|
1034
1090
|
// [062] No devDependency declared for ${dependency}. Please consider adding "${dependency}":"${recommendedVersion}" to devDependencies at package.json`
|
package/lib/M500_Code.js
CHANGED
|
@@ -613,12 +613,7 @@ async function checkCode(context) {
|
|
|
613
613
|
}
|
|
614
614
|
}
|
|
615
615
|
|
|
616
|
-
// Pattern 2:
|
|
617
|
-
if (/\badapter\s*=\s*utils\.Adapter\s*\(/i.test(line)) {
|
|
618
|
-
return true;
|
|
619
|
-
}
|
|
620
|
-
|
|
621
|
-
// Pattern 3: extends Adapter (without utils prefix)
|
|
616
|
+
// Pattern 2: extends Adapter (without utils prefix)
|
|
622
617
|
if (/class\s+\w+\s+extends\s+Adapter/i.test(line) && i < lineIndex) {
|
|
623
618
|
// Similar brace counting logic as above
|
|
624
619
|
let braceCount = 0;
|
|
@@ -696,29 +691,46 @@ async function checkCode(context) {
|
|
|
696
691
|
continue;
|
|
697
692
|
}
|
|
698
693
|
|
|
699
|
-
// Check for this.methodName
|
|
700
|
-
const
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
if
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
694
|
+
// Check for this.methodName pattern
|
|
695
|
+
const thisPattern = new RegExp(`\\bthis\\.${method}\\s*\\(`, 'g');
|
|
696
|
+
// Check for adapter.methodName pattern
|
|
697
|
+
const adapterPattern = new RegExp(`\\badapter\\.${method}\\s*\\(`, 'g');
|
|
698
|
+
|
|
699
|
+
// Handle this.method() calls - should warn when inside adapter class context
|
|
700
|
+
if (thisPattern.test(line)) {
|
|
701
|
+
// Make sure this is not a private function definition
|
|
702
|
+
const functionDefPattern = new RegExp(
|
|
703
|
+
`(function\\s+${method}|${method}\\s*[=:]\\s*function|${method}\\s*\\([^)]*\\)\\s*{)`,
|
|
704
|
+
'i',
|
|
705
|
+
);
|
|
706
|
+
if (!functionDefPattern.test(line)) {
|
|
707
|
+
// Only warn if we're in an adapter class context
|
|
708
|
+
if (isInAdapterClassContext(lines, i)) {
|
|
709
|
+
context.warnings.push(
|
|
710
|
+
`[W533] method "${method}()" is deprecated and will be removed with future js-controller version. Please use "set/deleteObject()" instead.`,
|
|
711
|
+
);
|
|
712
|
+
reportedMethods.add(method);
|
|
713
|
+
break; // Only warn once per line
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
// Handle adapter.method() calls - should warn when called outside of any class
|
|
719
|
+
if (adapterPattern.test(line)) {
|
|
720
|
+
// Make sure this is not a private function definition
|
|
721
|
+
const functionDefPattern = new RegExp(
|
|
722
|
+
`(function\\s+${method}|${method}\\s*[=:]\\s*function|${method}\\s*\\([^)]*\\)\\s*{)`,
|
|
723
|
+
'i',
|
|
724
|
+
);
|
|
725
|
+
if (!functionDefPattern.test(line)) {
|
|
726
|
+
// Warn if we're NOT in an adapter class context (outside any class)
|
|
727
|
+
if (!isInAdapterClassContext(lines, i)) {
|
|
728
|
+
context.warnings.push(
|
|
729
|
+
`[W533] method "${method}()" is deprecated and will be removed with future js-controller version. Please use "set/deleteObject()" instead.`,
|
|
730
|
+
);
|
|
731
|
+
reportedMethods.add(method);
|
|
732
|
+
break; // Only warn once per line
|
|
720
733
|
}
|
|
721
|
-
break; // Only warn once per line
|
|
722
734
|
}
|
|
723
735
|
}
|
|
724
736
|
}
|
package/lib/M800_Github.js
CHANGED
|
@@ -92,24 +92,25 @@ async function checkGithubRepo(context) {
|
|
|
92
92
|
|
|
93
93
|
const issues = await getAllIssues(context);
|
|
94
94
|
for (const issue of issues) {
|
|
95
|
-
if (issue.pull_request) {
|
|
96
|
-
|
|
97
|
-
}
|
|
95
|
+
// if (issue.pull_request) {
|
|
96
|
+
// continue;
|
|
97
|
+
// }
|
|
98
|
+
const type = issue.pull_request ? 'PR' : 'issue';
|
|
98
99
|
if (issuesToWatchAsError.includes(issue.title)) {
|
|
99
100
|
context.errors.push(
|
|
100
|
-
`[E804] Please process
|
|
101
|
+
`[E804] Please process ${type} [[#${issue.number}] "${issue.title}"](${context.githubUrlOriginal}/issues/${issue.number})`,
|
|
101
102
|
);
|
|
102
103
|
} else if (issuesToWatchAsWarning.includes(issue.title)) {
|
|
103
104
|
context.warnings.push(
|
|
104
|
-
`[W804] Please process
|
|
105
|
+
`[W804] Please process ${type} [[#${issue.number}] "${issue.title}"](${context.githubUrlOriginal}/issues/${issue.number})`,
|
|
105
106
|
);
|
|
106
107
|
} else if (issue.title.startsWith('URGENT:')) {
|
|
107
108
|
context.errors.push(
|
|
108
|
-
`[E804] Please process
|
|
109
|
+
`[E804] Please process ${type} [[#${issue.number}] "${issue.title}"](${context.githubUrlOriginal}/issues/${issue.number})`,
|
|
109
110
|
);
|
|
110
111
|
} else if (issue.title.startsWith('IMPORTANT:')) {
|
|
111
112
|
context.warnings.push(
|
|
112
|
-
`[W804] Please process
|
|
113
|
+
`[W804] Please process ${type} [[#${issue.number}] "${issue.title}"](${context.githubUrlOriginal}/issues/${issue.number})`,
|
|
113
114
|
);
|
|
114
115
|
}
|
|
115
116
|
}
|
package/package.json
CHANGED