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:
- 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.
- Named
.catch(handler) references — p.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
- 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).
- 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).
- 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 · ◷
Rule
eslint-factory/src/rules/no-json-stringify-error.ts.Caught-error tracking recognizes two shapes: a
CatchClauseparam, and a callback passed directly as the first argument to.catch()(seeisCatchCallback). Two semantically-equivalent "caught error" shapes are silently out of scope:.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..catch(handler)references —p.catch(handler)wherehandlerstringifies its error param. The rule's docstring notes this is intentional, but the exclusion is not surfaced in the ruledocs.descriptionor 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/**/*.cjsfor.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
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).docs.description(and the eslint-factory README## Rulessection, which currently documents onlyprefer-number-isnanand omits this rule entirely)..then(onFulfilled, onRejected): if yes, treatnode.arguments[1]of a.then()call the same as the.catch()callback inisCatchCallback/enterFunction; if no, record the rationale in a code comment next toisCatchCallback.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.