deflake 1.2.34 → 1.2.35
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/cli.js +12 -0
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -238,6 +238,18 @@ async function applyFix(res, loc) {
|
|
|
238
238
|
continue;
|
|
239
239
|
}
|
|
240
240
|
if (p.action === 'INSERT_AFTER') {
|
|
241
|
+
// SAFETY: Detect if we'd insert at class scope (outside any method)
|
|
242
|
+
// Pattern: line is '}' (end of constructor/method) and next non-blank line starts a new method
|
|
243
|
+
const targetLine = lines[idx].trim();
|
|
244
|
+
const nextMeaningful = lines.slice(p.line).find(l => l.trim() !== '');
|
|
245
|
+
const isClassScope = targetLine === '}' && nextMeaningful &&
|
|
246
|
+
/^\s*(async\s+)?\w+\s*\(|^\s*(private|public|protected|static|readonly|get |set )|^\s*}/.test(nextMeaningful);
|
|
247
|
+
|
|
248
|
+
if (isClassScope && /await |return |const |let |var /.test(p.new_line)) {
|
|
249
|
+
console.log(` ${C.YELLOW}⏭️ Blocked: would insert executable code at class scope (after ${targetLine})${C.RESET}`);
|
|
250
|
+
continue;
|
|
251
|
+
}
|
|
252
|
+
|
|
241
253
|
lines.splice(p.line, 0, cleanLine);
|
|
242
254
|
console.log(` ${C.GREEN}+ Line ${p.line + 1}: ${cleanLine.trim()}${C.RESET}`);
|
|
243
255
|
} else {
|