Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 1 addition & 15 deletions eslint-factory/src/rules/require-execsync-try-catch.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AST_NODE_TYPES, ESLintUtils, TSESLint, TSESTree } from "@typescript-eslint/utils";
import { buildTryCatchSuggestion, findEnclosingStatement, isDeferredCallback, isInsideTryBlock } from "./try-catch-rule-utils";
import { buildTryCatchSuggestion, findEnclosingStatement, isInsideTryBlock } from "./try-catch-rule-utils";

const createRule = ESLintUtils.RuleCreator(name => `https://github.com/github/gh-aw/tree/main/eslint-factory#${name}`);

Expand Down Expand Up @@ -145,20 +145,6 @@ export const requireExecSyncTryCatchRule = createRule({
if (!isExecSyncCall(node, sourceCode)) return;
if (isInsideTryBlock(sourceCode, node)) return;

// Ignore execSync inside deferred callbacks — the parent try block does not protect them.
// isInsideTryBlock already handles this, but we skip reporting when the node itself is
// inside a deferred callback that has no enclosing try block (same FP-avoidance as other rules).
const ancestors = sourceCode.getAncestors(node);
let withinDeferredBoundary = false;
for (let i = ancestors.length - 1; i >= 0; i--) {
if (isDeferredCallback(ancestors[i])) {
withinDeferredBoundary = true;
break;
}
}
// Still flag it even in deferred callbacks — execSync in async callbacks is still risky.
void withinDeferredBoundary;

const argText = node.arguments.length > 0 ? sourceCode.getText(node.arguments[0]) : "";
const stmt = findEnclosingStatement(sourceCode, node);

Expand Down