Skip to content

Audit helper-built thrown Error messages - #51412

Merged
pelikhan merged 5 commits into
mainfrom
copilot/eslint-factory-require-error-code-in-thrown-error
Aug 8, 2026
Merged

pelikhan merged 5 commits into
mainfrom
copilot/eslint-factory-require-error-code-in-thrown-error

Conversation

Copilot AI commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

require-error-code-in-thrown-error skipped throw new Error(helper()), so helper-built messages in coded files could bypass error-code checks entirely. This left uncoded validation messages accepted silently beside coded sibling errors.

  • ESLint rule
    • Audits simple same-file helper calls with a single static return.
    • Adds callExpressionNeedsReview for imported, branched, dynamic, or indirect helper-call messages that cannot be verified statically.
    • Preserves existing low-confidence silence for unrelated non-message expressions.
throw new Error(helper()); // audited if helper is local/static; otherwise flagged for review
  • MCP validation messages

    • Prefixes generateEnhancedErrorMessage() return paths with ERR_VALIDATION.
    • Keeps enhanced schema guidance unchanged after the code prefix.
  • Tests

    • Covers coded local helpers, uncoded local helpers, dynamic helpers, imported helpers, indirect helper-call messages, and branched helpers.
    • Updates enhanced-error expectations for the new validation code prefix.

Copilot AI and others added 4 commits August 8, 2026 15:58
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix message argument check for CallExpression in require-error-code-in-thrown-error Audit helper-built thrown Error messages Aug 8, 2026
Copilot AI requested a review from pelikhan August 8, 2026 16:05
@pelikhan
pelikhan marked this pull request as ready for review August 8, 2026 16:40
Copilot AI balanced review requested due to automatic review settings August 8, 2026 16:40
@pelikhan
pelikhan merged commit 9877a9b into main Aug 8, 2026
1 check passed
@pelikhan
pelikhan deleted the copilot/eslint-factory-require-error-code-in-thrown-error branch August 8, 2026 16:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Extends error-code linting to helper-built messages and standardizes MCP validation errors.

Changes:

  • Audits local helper calls and flags unresolved calls.
  • Adds ERR_VALIDATION prefixes to enhanced errors.
  • Expands rule and MCP tests.
Show a summary per file
File Description
eslint-factory/src/rules/require-error-code-in-thrown-error.ts Adds helper-call auditing.
eslint-factory/src/rules/require-error-code-in-thrown-error.test.ts Tests helper-call cases.
actions/setup/js/mcp_enhanced_errors.cjs Prefixes validation messages.
actions/setup/js/mcp_enhanced_errors.test.cjs Updates expected messages.

Review details

Tip

Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 4/4 changed files
  • Comments generated: 3
  • Review effort level: Balanced

Comment on lines +88 to +91
if (!isAuditableMessageExpression(resolved)) return resolved.type === AST_NODE_TYPES.CallExpression ? "needsReview" : "hasCode";
return messageReferencesErrorCode(resolved) ? "hasCode" : "missingCode";
}
return "missingCode";
function resolveSimpleLocalCallReturns(node: TSESTree.CallExpression): TSESTree.Expression[] | null {
if (node.callee.type !== AST_NODE_TYPES.Identifier) return null;
const variable = findVariableInScopeChain(sourceCode.getScope(node.callee), node.callee.name);
if (!variable || variable.defs.length !== 1) return null;
Comment on lines +104 to +111
let body: TSESTree.BlockStatement | TSESTree.Expression | null = null;
if (def.type === "FunctionName") {
body = (def.node as TSESTree.FunctionDeclaration).body;
} else if (def.type === "Variable" && def.node.init && (def.node.init.type === AST_NODE_TYPES.FunctionExpression || def.node.init.type === AST_NODE_TYPES.ArrowFunctionExpression)) {
body = def.node.init.body;
} else {
return null;
}
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.86.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

eslint-factory: require-error-code-in-thrown-error skips CallExpression message args (helper-built messages never audited)

3 participants