deslop/simplifiable-function

Disallow functions written less directly than needed: block-arrow-single-return, redundant-await-return, useless-async-no-await.

  • Category: Correctness
  • Severity: warn
  • Source: deslop-js
  • Framework: global
  • Enabled when: react-doctor deadCode analysis enabled (default true); whole-project scan only — skipped in --diff/--staged modes
  • Documentation: https://github.com/millionco/deslop-js

Validation prompt

Use this to decide whether a fired diagnostic is real or a false positive.

Fires from deslop's simplifiableFunctions detector in one of three kinds: block-arrow-single-return (a non-async arrow whose block body is just one return expr, reason 'arrow body is a single return statement; the block can be replaced by the expression directly'), redundant-await-return (the last two statements are const x = await …; return x;, reason 'the await is preserved by the implicit promise chain'), or useless-async-no-await (an async function — not a method or inline callback, with no explicit Promise return type — whose body has no await, no calls, and no Promise surface, reason 'the implicit Promise wrap is purely decorative'; this kind is emitted at low confidence). False positive to SUPPRESS: a block arrow body deliberately kept as { return x; } so a debug breakpoint or an imminent extra statement has somewhere to land; or an async kept on a stable public/interface-bound signature where downstream callers rely on the Promise contract; or a redundant-await-return where dropping the await would move it outside a surrounding try/catch and change error-handling timing — deslop's own suggestion gates this, recommending you collapse to plain return … only when no try/catch wraps the sequence, else keep return await … so rejections still surface inside the try.

Fix prompt

Use this once validation confirms the diagnostic is real.

Per kind: for block-arrow-single-return strip the braces and return — (x) => { return x + 1; } becomes (x) => x + 1; for redundant-await-return collapse the temp into the return — const r = await fetchUser(id); return r; becomes return fetchUser(id) by default, but if a try/catch wraps the sequence keep return await fetchUser(id) so rejections still surface here rather than at the caller; for useless-async-no-await drop the async keyword so the function returns its value synchronously — the caller's existing await keeps the inferred type identical — or, if you must keep the async signature, add an explicit : Promise<T> return type to make the contract intentional. See https://github.com/millionco/deslop-js