Skip to content

no-iife: peel conditional/logical callees ((cond ? () => 1 : () => 2)()) (#1310 follow-up) #1327

Description

@radandevist

From the round-3 adversarial review of #1310 (MEDIUM): publy/no-iife does not peel ConditionalExpression / LogicalExpression callees, so these IIFEs pass unflagged (verified RC=0, not covered by no-iife.test.ts):

(cond ? () => 1 : () => 2)();
(cond && (() => 3))();

Fix

  • In unwrapCallee, peel ConditionalExpression (both branches) and LogicalExpression (both operands): if ANY reachable branch is a function literal, report.
  • RuleTester cases red on the current rule for both shapes (+ nested a ? (b ? fn : fn2) : fn3), and precision cases where no branch is a function literal.
  • Re-scan apps/front/src + packages/** with the rule at error; extract any real offender the same way as lint: add custom publy/no-iife (port from DigitalPrevention) and extract existing IIFEs #1310.

Part of #1210.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions