oxc-project/oxc · warning · OxcDiagnostic

IIFE with parenthesized arrow function body is considered un

Error message

IIFE with parenthesized arrow function body is considered unreadable.

What it means

Diagnostic from the oxlint rule `unicorn/no-unreadable-iife` (crates/oxc_linter/src/rules/unicorn/no_unreadable_iife.rs). It fires when an immediately-invoked function expression (IIFE) is called with an arrow function as the callee and that arrow has a concise expression body wrapped in parentheses, e.g. `(() => (a ? b : c))()`. The inner parentheses add no meaning and make the construct hard to read. The rule is in the pedantic category with fix status `pending`, so no automatic fix is offered.

Source

Thrown at crates/oxc_linter/src/rules/unicorn/no_unreadable_iife.rs:9

use oxc_ast::{AstKind, ast::Expression};
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::{GetSpan, Span};

use crate::{AstNode, context::LintContext, rule::Rule};

fn no_unreadable_iife_diagnostic(span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn("IIFE with parenthesized arrow function body is considered unreadable.")
        .with_help("Rewrite the IIFE to avoid having a parenthesized arrow function body.")
        .with_label(span)
}

#[derive(Debug, Default, Clone)]
pub struct NoUnreadableIife;

declare_oxc_lint!(
    /// ### What it does
    ///
    /// This rule disallows IIFEs with a parenthesized arrow function body.
    ///
    /// ### Why is this bad?
    ///
    /// IIFEs with a parenthesized arrow function body are unreadable.
    ///
    /// ### Examples
    ///

View on GitHub (pinned to e1e7af627c)

Solutions

  1. Remove the extra parentheses around the arrow body, or switch to a block body: `(() => { return a ? b : c; })()`.
  2. Hoist the argument and drop the IIFE entirely: `const bar = getBar(); const foo = bar ? bar.baz : baz;`.
  3. Extract the arrow into a named helper: `const getBaz = bar => (bar ? bar.baz : baz); const foo = getBaz(getBar());`.
  4. If the pattern is deliberate, silence it with an inline `oxlint-disable-next-line unicorn/no-unreadable-iife` comment.

Example fix

// before
const foo = (() => (bar ? bar.baz : baz))(getBar());

// after
const bar = getBar();
const foo = bar ? bar.baz : baz;
Defensive patterns

Strategy: validation

Validate before calling

# pre-commit grep for IIFE arrow bodies wrapped in parentheses
rg -n --type js -U '=>\s*\(\s*[^)]' src/ | rg '\)\s*\)\s*\(' || echo 'clean'

Prevention

When it happens

Trigger: A CallExpression whose callee (outer parentheses stripped) is an ArrowFunctionExpression whose expression body is a ParenthesizedExpression. Concrete cases from the rule's tests: `const foo = (() => (a ? b : c))();`, `(bar => (bar))();`, `(async () => ({ bar }))();`, `(() => (a, b))();`. Not fired for block bodies `() => { return a ? b : c; }` or unparenthesized bodies `() => bar`.

Common situations: Expression-scope tricks such as computing a default inline (`(bar => (bar ? bar.baz : baz))(getBar())`) or returning object literals from one-liner IIFEs. Appears when a project enables the oxlint unicorn plugin or the pedantic category, or when migrating an eslint-plugin-unicorn config to oxlint.

Related errors


AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20). Data as JSON: /api/errors/ffac4721ad2efb1d. Report an issue: GitHub.