From 303d9e803ff5a8e8e8be55d5a288a26a9d838398 Mon Sep 17 00:00:00 2001 From: Yuji Sugiura <6259812+leaysgur@users.noreply.github.com> Date: Mon, 2 Nov 2026 17:45:32 +0900 Subject: [PATCH] docs(formatter): strengthen `start-token-no-double-parens` rationale (#28711) The leading parens only guard a statement or arrow body start, so Prettier prints the same object lookup idiom without them elsewhere (`const get = ({ a: 1, b: 2 } as const)[key];`). List that sibling and the assignment arrow body in `Why`, and replace the `export default` example with a measured one. Co-authored-by: Claude Opus 5.5 --- crates/oxc_formatter/DIVERGENCES.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/crates/oxc_formatter/DIVERGENCES.md b/crates/oxc_formatter/DIVERGENCES.md index 67993a7324..b5b61694c6 100644 --- a/crates/oxc_formatter/DIVERGENCES.md +++ b/crates/oxc_formatter/DIVERGENCES.md @@ -1002,7 +1002,7 @@ Prettier's wrapping came from a syntax fix (prettier/prettier#6133), whose chang ## start-token-no-double-parens -- Why: uniform-rule (same construct, same output: `export default` and sequence arrow body) +- Why: uniform-rule (same construct, same output: outside a statement or arrow body start, after `export default`, sequence and assignment arrow bodies) - Pin: `tests/fixtures/ts/parenthesis/start-token-no-double-parens.ts` - Conformance: - `externals/prettier/js/identifier/parentheses/let.js` @@ -1031,8 +1031,11 @@ const get = (key: K) => (({ a: 1, b: 2 }) as const)[key]; ``` When an ancestor gets its own parens, a leading `{`/`function`/`class`/`let[` inside it needs none. -Prettier already does this after `export default` (`` export default (function () {} + foo)`` ``) and for a sequence arrow body (`() => ({}, 1)`), -but not at statement start or for other arrow bodies, e.g. the object lookup idiom above. +These parens only guard a statement or arrow body start: unlike readability parens (e.g. the IIFE's `(function () {})()`), +Prettier never prints them elsewhere, so the same object lookup idiom prints as ours there (`const get = ({ a: 1, b: 2 } as const)[key];`). +Prettier also drops them under an ancestor's parens after `export default` (`` export default (function () {}.a && b) || c; ``) +and for a sequence or assignment arrow body (`() => ({}.a, 1)`, `() => ({}.a = 1)`), +but not at statement start or for other arrow bodies. ## inline-logical-chain-indent