Skip to content

[Code Quality] Fix no-core-error-then-process-exit autofix: return is not equivalent to process.exit #46642

Description

@github-actions

Description

The no-core-error-then-process-exit ESLint rule's autofix converts core.error(msg); process.exit(nonzero) to core.setFailed(msg); return;. This is not control-flow equivalent: return exits only the enclosing function, while process.exit aborts the process entirely. In value-returning helpers like requireEnvVar and loadGatewayContext in convert_gateway_config_shared.cjs, the autofix would let callers continue with bad/undefined state.

Suggested Changes

  • Fix the autofix to use process.exit(1) after core.setFailed() OR suppress the autofix for functions that have callers
  • Alternatively, gate the autofix to only apply in top-level script contexts (not inside helper functions)
  • Add test cases for the helper-function pattern

Files Affected

  • actions/setup/js/eslint-factory/rules/no-core-error-then-process-exit.ts (rule implementation)
  • actions/setup/js/eslint-factory/rules/no-core-error-then-process-exit.test.ts (tests)
  • Affected sites: convert_gateway_config_shared.cjs (requireEnvVar:45-52, loadGatewayContext:66-72)

Success Criteria

  • Autofix generates control-flow-equivalent code
  • Helper functions with return values are excluded from unsafe autofix
  • New test cases cover helper-function pattern

Source

Extracted from ESLint Refiner Report #46543

Priority

High — Current autofix introduces latent bugs (execution continues with bad state)

🔍 Task mining by Discussion Task Miner - Code Quality Improvement Agent · 40.8 AIC · ⌖ 6.1 AIC · ⊞ 7K ·

  • expires on Jul 20, 2026, 11:13 AM UTC-08:00

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions