@iobroker/repochecker 5.5.3 → 5.5.5
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 +6 -0
- package/lib/M6000_Readme.js +105 -20
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -25,6 +25,12 @@ Example:
|
|
|
25
25
|
Placeholder for the next version (at the beginning of the line):
|
|
26
26
|
### **WORK IN PROGRESS**
|
|
27
27
|
-->
|
|
28
|
+
### 5.5.5 (2026-03-24)
|
|
29
|
+
. (mcm1957) remove '[S6014] README.md section "## Installation" should be removed unless the adapter requires special installation handling.'
|
|
30
|
+
|
|
31
|
+
### 5.5.4 (2026-03-22)
|
|
32
|
+
- (@copilot) Fixed E6015/W6016 false positives: German (and English) language detection now ignores fenced code blocks, inline code, blockquote lines, link URLs, and image markup before analyzing the README text.
|
|
33
|
+
|
|
28
34
|
### 5.5.3 (2026-03-19)
|
|
29
35
|
- (@copilot) Fixed E3016 false positive: transitive `needs` dependencies are now considered, so `deploy` depending on `adapter-tests` which already depends on `check-and-lint` is correctly accepted. Related to [#756].
|
|
30
36
|
- (@copilot) W5041 warning now includes the list of languages that contain the example keys (e.g. `languages: en, de, ru`).
|
package/lib/M6000_Readme.js
CHANGED
|
@@ -64,19 +64,23 @@ const ENGLISH_WORDS = [
|
|
|
64
64
|
// Minimum number of distinct English words that must be found to consider the text English
|
|
65
65
|
const ENGLISH_WORD_THRESHOLD = 5;
|
|
66
66
|
|
|
67
|
+
// Minimum number of distinct German words that must be detected before raising an error
|
|
68
|
+
const GERMAN_WORD_DETECTION_LIMIT = 3;
|
|
69
|
+
|
|
67
70
|
/**
|
|
68
|
-
* Search for
|
|
69
|
-
* Returns
|
|
71
|
+
* Search for all German words from the blacklist in the given text.
|
|
72
|
+
* Returns an array of all matching words (in detection order).
|
|
70
73
|
*
|
|
71
74
|
* @param {string} text - The text to analyze
|
|
72
|
-
* @returns {string
|
|
75
|
+
* @returns {string[]} Array of German words found (empty if none)
|
|
73
76
|
*/
|
|
74
|
-
function
|
|
77
|
+
function findAllGermanWords(text) {
|
|
78
|
+
const found = [];
|
|
75
79
|
for (const word of GERMAN_WORDS) {
|
|
76
80
|
if (word.includes(' ')) {
|
|
77
81
|
// For phrases, use case-insensitive substring match
|
|
78
82
|
if (text.toLowerCase().includes(word.toLowerCase())) {
|
|
79
|
-
|
|
83
|
+
found.push(word);
|
|
80
84
|
}
|
|
81
85
|
} else {
|
|
82
86
|
// Use lookbehind/lookahead for whole-word matching.
|
|
@@ -86,11 +90,87 @@ function findGermanWord(text) {
|
|
|
86
90
|
const escaped = word.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
87
91
|
const regex = new RegExp(`(?<!\\w)${escaped}(?!\\w)`);
|
|
88
92
|
if (regex.test(text)) {
|
|
89
|
-
|
|
93
|
+
found.push(word);
|
|
90
94
|
}
|
|
91
95
|
}
|
|
92
96
|
}
|
|
93
|
-
return
|
|
97
|
+
return found;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Get a short context snippet (up to 3 words) centred on the detected word in the text.
|
|
102
|
+
*
|
|
103
|
+
* @param {string} text - The text to search in
|
|
104
|
+
* @param {string} word - The word to find context for
|
|
105
|
+
* @returns {string} A snippet with one word before and one word after the detected word
|
|
106
|
+
*/
|
|
107
|
+
function getWordContext(text, word) {
|
|
108
|
+
let matchIndex;
|
|
109
|
+
let matchLength;
|
|
110
|
+
|
|
111
|
+
if (word.includes(' ')) {
|
|
112
|
+
const escaped = word.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
113
|
+
const match = new RegExp(escaped, 'i').exec(text);
|
|
114
|
+
if (!match) {
|
|
115
|
+
return word;
|
|
116
|
+
}
|
|
117
|
+
matchIndex = match.index;
|
|
118
|
+
matchLength = match[0].length;
|
|
119
|
+
} else {
|
|
120
|
+
const escaped = word.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
121
|
+
const match = new RegExp(`(?<!\\w)${escaped}(?!\\w)`).exec(text);
|
|
122
|
+
if (!match) {
|
|
123
|
+
return word;
|
|
124
|
+
}
|
|
125
|
+
matchIndex = match.index;
|
|
126
|
+
matchLength = match[0].length;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const before = text.substring(0, matchIndex).trimEnd().split(/\s+/);
|
|
130
|
+
const matchedWord = text.substring(matchIndex, matchIndex + matchLength);
|
|
131
|
+
const after = text
|
|
132
|
+
.substring(matchIndex + matchLength)
|
|
133
|
+
.trimStart()
|
|
134
|
+
.split(/\s+/);
|
|
135
|
+
|
|
136
|
+
const parts = [];
|
|
137
|
+
if (before.length > 0 && before[before.length - 1]) {
|
|
138
|
+
parts.push(before[before.length - 1]);
|
|
139
|
+
}
|
|
140
|
+
parts.push(matchedWord);
|
|
141
|
+
if (after.length > 0 && after[0]) {
|
|
142
|
+
parts.push(after[0]);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
return parts.join(' ');
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Strip markdown elements that are not visible to the user when the markdown is rendered.
|
|
150
|
+
* This prevents false positives in language detection when German words appear in:
|
|
151
|
+
* - fenced code blocks (``` ... ```)
|
|
152
|
+
* - inline code (`...`)
|
|
153
|
+
* - blockquote lines (lines starting with >)
|
|
154
|
+
* - link URLs [text](url) — the URL part is stripped, the visible text is kept
|
|
155
|
+
* - image markup  — stripped entirely (alt text and URL are both not rendered as prose)
|
|
156
|
+
*
|
|
157
|
+
* @param {string} text - The markdown text to process
|
|
158
|
+
* @returns {string} The text with non-visible parts removed
|
|
159
|
+
*/
|
|
160
|
+
function stripMarkdownForLanguageDetection(text) {
|
|
161
|
+
// Remove fenced code blocks (``` ... ```) including those with a language hint (```js ... ```)
|
|
162
|
+
text = text.replace(/```[\s\S]*?```/g, '');
|
|
163
|
+
// Remove inline code (`...`)
|
|
164
|
+
text = text.replace(/`[^`\n]*`/g, '');
|
|
165
|
+
// Remove blockquote lines (lines starting with optional whitespace then >)
|
|
166
|
+
text = text.replace(/^[ \t]*>.*$/gm, '');
|
|
167
|
+
// Remove image markup entirely:  and ![alt text][ref]
|
|
168
|
+
text = text.replace(/!\[[^\]]*\]\([^)]*\)/g, '');
|
|
169
|
+
text = text.replace(/!\[[^\]]*\]\[[^\]]*\]/g, '');
|
|
170
|
+
// For links [text](url) and [text][ref], keep only the visible link text
|
|
171
|
+
text = text.replace(/\[([^\]]*)\]\([^)]*\)/g, '$1');
|
|
172
|
+
text = text.replace(/\[([^\]]*)\]\[[^\]]*\]/g, '$1');
|
|
173
|
+
return text;
|
|
94
174
|
}
|
|
95
175
|
|
|
96
176
|
/**
|
|
@@ -287,24 +367,29 @@ async function checkReadme(context) {
|
|
|
287
367
|
context.checks.push('README.md does not contain GitHub URL install instructions');
|
|
288
368
|
}
|
|
289
369
|
|
|
290
|
-
//
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
370
|
+
// do not suggest to remove installation as several usefull install sections with additional infos exist.
|
|
371
|
+
// // Check for ## Installation section
|
|
372
|
+
// if (/^##\s+Installation\s*$/im.test(data)) {
|
|
373
|
+
// context.warnings.push(
|
|
374
|
+
// '[S6014] README.md section "## Installation" should be removed unless the adapter requires special installation handling.',
|
|
375
|
+
// );
|
|
376
|
+
// } else {
|
|
377
|
+
// context.checks.push('README.md does not contain an unnecessary Installation section');
|
|
378
|
+
// }
|
|
298
379
|
|
|
299
|
-
// Check README language
|
|
300
|
-
|
|
301
|
-
|
|
380
|
+
// Check README language — strip non-visible markdown elements first so that
|
|
381
|
+
// German words inside code blocks, blockquotes, link URLs or image markup
|
|
382
|
+
// do not trigger false positives.
|
|
383
|
+
const dataForLanguageCheck = stripMarkdownForLanguageDetection(data);
|
|
384
|
+
const germanWords = findAllGermanWords(dataForLanguageCheck);
|
|
385
|
+
if (germanWords.length >= GERMAN_WORD_DETECTION_LIMIT) {
|
|
386
|
+
const snippet = getWordContext(dataForLanguageCheck, germanWords[0]);
|
|
302
387
|
context.errors.push(
|
|
303
|
-
`[E6015] README.md appears to
|
|
388
|
+
`[E6015] README.md must use English language only but appears to contain German text (detected: "${snippet}"). Please remove or translate.`,
|
|
304
389
|
);
|
|
305
390
|
} else {
|
|
306
391
|
context.checks.push('No German language detected in README.md');
|
|
307
|
-
if (!isEnglishText(
|
|
392
|
+
if (!isEnglishText(dataForLanguageCheck)) {
|
|
308
393
|
context.warnings.push(
|
|
309
394
|
'[W6016] README.md does not appear to be written in English. README.md must be written using English language only. Please translate.',
|
|
310
395
|
);
|
package/package.json
CHANGED