WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
Bug 200800
Web Inspector: JavaScript formatting of single statement arrow function can be poor
https://bugs.webkit.org/show_bug.cgi?id=200800
Summary
Web Inspector: JavaScript formatting of single statement arrow function can b...
Joseph Pecoraro
Reported
2019-08-15 17:12:12 PDT
JavaScript formatting of single statement arrow function can be poor Test: ``` () => { 1 } () => { for(x of []); } () => { try{1}catch{2} } ``` Expected: ``` () => {1} () => { for (x of []) ; } () => { try { 1 } catch { 2 } } ``` Actual: ``` () => {1} () => {for (x of []) ; } () => {try { 1 } catch { 2 } } ```
Attachments
[PATCH] Proposed Fix
(5.49 KB, patch)
2019-08-15 17:28 PDT
,
Joseph Pecoraro
no flags
Details
Formatted Diff
Diff
[PATCH] Proposed Fix
(5.49 KB, patch)
2019-08-15 17:29 PDT
,
Joseph Pecoraro
ross.kirsling
: review+
Details
Formatted Diff
Diff
[PATCH] For Landing
(5.50 KB, patch)
2019-08-16 12:08 PDT
,
Joseph Pecoraro
no flags
Details
Formatted Diff
Diff
Show Obsolete
(1)
View All
Add attachment
proposed patch, testcase, etc.
Joseph Pecoraro
Comment 1
2019-08-15 17:28:01 PDT
Created
attachment 376447
[details]
[PATCH] Proposed Fix
Joseph Pecoraro
Comment 2
2019-08-15 17:28:42 PDT
Comment on
attachment 376447
[details]
[PATCH] Proposed Fix View in context:
https://bugs.webkit.org/attachment.cgi?id=376447&action=review
> Source/WebInspectorUI/UserInterface/Workers/Formatter/EsprimaFormatter.js:309 > + let isSingleStatementArrowFunctionWithUnlikelyNewlineContent = node.parent.type === "ArrowFunctionExpression" && node.body.length === 1 && !this._isLikelyToHaveNewline(node.body[0]);
Perhaps a better name is "WithUnlikelyMultilineContent"
Joseph Pecoraro
Comment 3
2019-08-15 17:29:31 PDT
Created
attachment 376448
[details]
[PATCH] Proposed Fix
Ross Kirsling
Comment 4
2019-08-16 11:11:48 PDT
Comment on
attachment 376448
[details]
[PATCH] Proposed Fix View in context:
https://bugs.webkit.org/attachment.cgi?id=376448&action=review
Seems like a reasonable improvement. I agree with your renaming suggestion too.
> Source/WebInspectorUI/UserInterface/Workers/Formatter/EsprimaFormatter.js:196 > + if (nodeType === "ExpressionStatement") > + return false;
This shouldn't be necessary. (Unless it's meant as an optimization? But in that case it'd be incomplete, and you'd probably want to opt for a switch...)
> Source/WebInspectorUI/UserInterface/Workers/Formatter/EsprimaFormatter.js:206 > + || nodeType === "FunctionDeclaration"
"ClassDeclaration" too, right?
Joseph Pecoraro
Comment 5
2019-08-16 11:43:35 PDT
(In reply to Ross Kirsling from
comment #4
)
> Comment on
attachment 376448
[details]
> [PATCH] Proposed Fix > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=376448&action=review
> > Seems like a reasonable improvement. I agree with your renaming suggestion > too. > > > Source/WebInspectorUI/UserInterface/Workers/Formatter/EsprimaFormatter.js:196 > > + if (nodeType === "ExpressionStatement") > > + return false; > > This shouldn't be necessary. (Unless it's meant as an optimization? But in > that case it'd be incomplete, and you'd probably want to opt for a switch...)
Yeah, I'll just remove this. I assumed the common case would be Expression and no need to check 10 things if its almost _always_ this. But I didn't measure and it seems unlikely to be important.
> > > Source/WebInspectorUI/UserInterface/Workers/Formatter/EsprimaFormatter.js:206 > > + || nodeType === "FunctionDeclaration" > > "ClassDeclaration" too, right?
Yep! Thanks
Joseph Pecoraro
Comment 6
2019-08-16 12:08:28 PDT
Created
attachment 376515
[details]
[PATCH] For Landing
WebKit Commit Bot
Comment 7
2019-08-16 12:51:05 PDT
Comment on
attachment 376515
[details]
[PATCH] For Landing Clearing flags on attachment: 376515 Committed
r248785
: <
https://trac.webkit.org/changeset/248785
>
Radar WebKit Bug Importer
Comment 8
2019-08-16 19:07:17 PDT
<
rdar://problem/54417189
>
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug