{"record":{"id":"ffac4721ad2efb1d","repo":"oxc-project/oxc","slug":"iife-with-parenthesized-arrow-function-body-is-con","errorCode":null,"errorMessage":"IIFE with parenthesized arrow function body is considered unreadable.","messagePattern":"IIFE with parenthesized arrow function body is considered unreadable\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"warning","filePath":"crates/oxc_linter/src/rules/unicorn/no_unreadable_iife.rs","lineNumber":9,"sourceCode":"use oxc_ast::{AstKind, ast::Expression};\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::{GetSpan, Span};\n\nuse crate::{AstNode, context::LintContext, rule::Rule};\n\nfn no_unreadable_iife_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"IIFE with parenthesized arrow function body is considered unreadable.\")\n        .with_help(\"Rewrite the IIFE to avoid having a parenthesized arrow function body.\")\n        .with_label(span)\n}\n\n#[derive(Debug, Default, Clone)]\npub struct NoUnreadableIife;\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///\n    /// This rule disallows IIFEs with a parenthesized arrow function body.\n    ///\n    /// ### Why is this bad?\n    ///\n    /// IIFEs with a parenthesized arrow function body are unreadable.\n    ///\n    /// ### Examples\n    ///","sourceCodeStart":1,"sourceCodeEnd":27,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/unicorn/no_unreadable_iife.rs#L1-L27","documentation":"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.","triggerScenarios":"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`.","commonSituations":"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.","solutions":["Remove the extra parentheses around the arrow body, or switch to a block body: `(() => { return a ? b : c; })()`.","Hoist the argument and drop the IIFE entirely: `const bar = getBar(); const foo = bar ? bar.baz : baz;`.","Extract the arrow into a named helper: `const getBaz = bar => (bar ? bar.baz : baz); const foo = getBaz(getBar());`.","If the pattern is deliberate, silence it with an inline `oxlint-disable-next-line unicorn/no-unreadable-iife` comment."],"exampleFix":"// before\nconst foo = (() => (bar ? bar.baz : baz))(getBar());\n\n// after\nconst bar = getBar();\nconst foo = bar ? bar.baz : baz;","handlingStrategy":"validation","validationCode":"# pre-commit grep for IIFE arrow bodies wrapped in parentheses\nrg -n --type js -U '=>\\s*\\(\\s*[^)]' src/ | rg '\\)\\s*\\)\\s*\\(' || echo 'clean'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Avoid IIFEs for defaults; hoist a const instead and the pattern cannot appear.","Prefer block-bodied arrows inside IIFEs so the concise-body paren problem never arises.","Run oxlint with the unicorn pedantic category in CI so the warning blocks before merge."],"tags":["lint","oxlint","unicorn","iife","arrow-function","readability","pedantic"],"backgroundTag":"unreadable-iife","analyzedSha":"e1e7af627c8843ab64044ed466b128fcc21a035b","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}