Skip to content

eslint-factory: no-json-stringify-error silently skips .then(onFulfilled, onRejected) reject handlers and named .catch(handler) [Content truncated due to length] #43719

Description

@github-actions

Rule

eslint-factory/src/rules/no-json-stringify-error.ts.

Caught-error tracking recognizes two shapes: a CatchClause param, and a callback passed directly as the first argument to .catch() (see isCatchCallback). Two semantically-equivalent "caught error" shapes are silently out of scope:

  1. 2-arg .then(onFulfilled, onRejected) — the second argument is a rejection handler whose param is a caught error, identical in meaning to .catch(err => ...). promise.then(handle, err => JSON.stringify(err)) is not flagged.
  2. Named .catch(handler) referencesp.catch(handler) where handler stringifies its error param. The rule's docstring notes this is intentional, but the exclusion is not surfaced in the rule docs.description or the README, and there is no test pinning it.

Grounding

This is latent / preventive, not a live defect: a corpus sweep of actions/setup/js/**/*.cjs for .then(fn, err => ...) / 2-arg reject handlers returned 0 sites. Filing so the boundary is a deliberate, tested decision rather than an accidental gap — the repo adds error-serialization idioms over time, and .then(_, onRejected) is a standard promise form.

Ask / acceptance criteria

  1. Add a valid/invalid test matrix that pins current behavior explicitly:
    • p.then(ok, err => JSON.stringify(err)) — document as flagged or not-flagged, with a test asserting the chosen behavior.
    • p.catch(handler) (named reference) — assert not flagged (matches docstring).
  2. Surface the scope boundary in the rule docs.description (and the eslint-factory README ## Rules section, which currently documents only prefer-number-isnan and omits this rule entirely).
  3. Decide explicitly whether to extend detection to .then(onFulfilled, onRejected): if yes, treat node.arguments[1] of a .then() call the same as the .catch() callback in isCatchCallback/enterFunction; if no, record the rationale in a code comment next to isCatchCallback.

Note

Lower priority than the suggestion-quality refinement filed alongside this run (no live sites today). Kept separate because it is a distinct scope/coverage decision.

Generated by 🤖 ESLint Refiner · 261.4 AIC · ⌖ 12.3 AIC · ⊞ 4.7K ·

  • expires on Jul 12, 2026, 10:53 PM UTC-08:00

Metadata

Metadata

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions