Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

feat(rome_js_formatter): Call arguments formatting #3290

Merged
merged 25 commits into from
Sep 30, 2022

Conversation

MichaReiser
Copy link
Contributor

@MichaReiser MichaReiser commented Sep 29, 2022

Summary

This PR improves our formatting of call arguments:

  • Improve our recognition of call expressions calling a test method (beforeEach, it, ...)
  • Preserve empty lines between call arguments
  • Refine rules when to group first or last argument
  • Add support for Prettier's grouping of the first and last argument.
  • Add special handling for function composition (compose(sortBy(x => x), flatten, map(x => [x, x*2]));

Test Plan

Average compatibility: 89.48 -> 91.72%
Compatible lines: 90.47 -> 93.49%

@netlify
Copy link

netlify bot commented Sep 29, 2022

Deploy Preview for rometools canceled.

Name Link
🔨 Latest commit 0949f6d
🔍 Latest deploy log https://app.netlify.com/sites/rometools/deploys/63371e488aca7a0009a197b8

@MichaReiser MichaReiser temporarily deployed to netlify-playground September 29, 2022 16:22 Inactive
@MichaReiser MichaReiser linked an issue Sep 29, 2022 that may be closed by this pull request
@MichaReiser MichaReiser added this to the 0.10.0 milestone Sep 29, 2022
@MichaReiser MichaReiser added the A-Formatter Area: formatter label Sep 29, 2022
@MichaReiser MichaReiser temporarily deployed to netlify-playground September 29, 2022 16:24 Inactive
@MichaReiser MichaReiser temporarily deployed to netlify-playground September 29, 2022 16:27 Inactive
@MichaReiser MichaReiser temporarily deployed to netlify-playground September 29, 2022 16:28 Inactive
@github-actions
Copy link

github-actions bot commented Sep 29, 2022

@MichaReiser
Copy link
Contributor Author

!bench_formatter

@MichaReiser MichaReiser mentioned this pull request Sep 29, 2022
9 tasks
@github-actions
Copy link

Formatter Benchmark Results

group                                    main                                   pr
-----                                    ----                                   --
formatter/checker.ts                     1.00    390.5±3.15ms     6.7 MB/sec    1.03    401.7±3.13ms     6.5 MB/sec
formatter/compiler.js                    1.00    216.3±1.48ms     4.8 MB/sec    1.73    374.7±2.72ms     2.8 MB/sec
formatter/d3.min.js                      1.00    170.7±0.88ms  1572.1 KB/sec    1.55    264.9±2.05ms  1013.1 KB/sec
formatter/dojo.js                        1.00     11.7±0.05ms     5.8 MB/sec    1.05     12.3±0.08ms     5.6 MB/sec
formatter/ios.d.ts                       1.03    252.3±1.61ms     7.4 MB/sec    1.00    243.8±1.37ms     7.7 MB/sec
formatter/jquery.min.js                  1.00     47.6±0.22ms  1777.8 KB/sec    1.65     78.4±0.64ms  1079.9 KB/sec
formatter/math.js                        1.00    335.7±1.93ms  1975.1 KB/sec    1.22    410.4±2.72ms  1615.7 KB/sec
formatter/parser.ts                      1.00      8.1±0.03ms     6.0 MB/sec    1.01      8.1±0.02ms     6.0 MB/sec
formatter/pixi.min.js                    1.00    187.9±1.08ms     2.3 MB/sec    1.00    188.5±1.27ms     2.3 MB/sec
formatter/react-dom.production.min.js    1.00     57.7±0.58ms  2041.8 KB/sec    1.00     57.6±0.50ms  2046.0 KB/sec
formatter/react.production.min.js        1.00      2.8±0.02ms     2.2 MB/sec    1.01      2.8±0.02ms     2.2 MB/sec
formatter/router.ts                      1.00      6.6±0.05ms     9.3 MB/sec    1.67     11.0±0.10ms     5.6 MB/sec
formatter/tex-chtml-full.js              1.00    435.4±1.82ms     2.1 MB/sec    1.00    437.2±1.81ms     2.1 MB/sec
formatter/three.min.js                   1.00    223.1±1.56ms     2.6 MB/sec    1.56    348.2±2.71ms  1726.6 KB/sec
formatter/typescript.js                  1.00   1436.3±8.36ms     6.6 MB/sec    1.03   1485.8±6.58ms     6.4 MB/sec
formatter/vue.global.prod.js             1.00     73.4±0.70ms  1681.9 KB/sec    1.07     78.2±0.58ms  1578.0 KB/sec

@MichaReiser MichaReiser temporarily deployed to netlify-playground September 30, 2022 09:05 Inactive
@MichaReiser MichaReiser temporarily deployed to netlify-playground September 30, 2022 09:06 Inactive
@MichaReiser MichaReiser temporarily deployed to netlify-playground September 30, 2022 09:24 Inactive
@MichaReiser MichaReiser temporarily deployed to netlify-playground September 30, 2022 09:26 Inactive
@MichaReiser
Copy link
Contributor Author

!bench_formatter

@MichaReiser MichaReiser temporarily deployed to netlify-playground September 30, 2022 09:51 Inactive
@MichaReiser MichaReiser marked this pull request as ready for review September 30, 2022 09:52
@MichaReiser MichaReiser requested a review from a team September 30, 2022 09:52
@calibre-analytics
Copy link

calibre-analytics bot commented Sep 30, 2022

Comparing feat(rome_js_formatter): Call arguments formatting Snapshot #14 to median since last deploy of rome.tools.

LCP? CLS? TBT?
Overall
Median across all pages and test profiles
2.18s
from 561ms
0.0
no change
184ms
from 45ms
Chrome Desktop
Chrome Desktop • Cable
2.18s
from 575ms
0.0
no change
381ms
from 224ms
iPhone, 4G LTE
iPhone 12 • 4G LTE
924ms
from 212ms
0.0
no change
17ms
from 6ms
Motorola Moto G Power, 3G connection
Motorola Moto G Power • Regular 3G
13.2s
from 561ms
0.0
no change
184ms
from 45ms

1 page tested

 Home

Browser previews

Chrome Desktop iPhone, 4G LTE Motorola Moto G Power, 3G connection
Chrome Desktop iPhone, 4G LTE Motorola Moto G Power, 3G connection

Most significant changes

Value Budget
JS Parse & Compile
iPhone, 4G LTE
475ms
from 7ms
JS Parse & Compile
Motorola Moto G Power, 3G connection
1.65s
from 29ms
Total JavaScript Size in Bytes
Chrome Desktop
4.29 MB
from 86.8 KB
Total JavaScript Size in Bytes
iPhone, 4G LTE
4.29 MB
from 86.8 KB
Total JavaScript Size in Bytes
Motorola Moto G Power, 3G connection
4.29 MB
from 86.8 KB

28 other significant changes: JS Parse & Compile on Chrome Desktop, First Contentful Paint on Motorola Moto G Power, 3G connection, Largest Contentful Paint on Motorola Moto G Power, 3G connection, Speed Index on Motorola Moto G Power, 3G connection, Total Page Size in Bytes on Chrome Desktop, Total Page Size in Bytes on iPhone, 4G LTE, Total Page Size in Bytes on Motorola Moto G Power, 3G connection, Number of Requests on Chrome Desktop, Number of Requests on iPhone, 4G LTE, Number of Requests on Motorola Moto G Power, 3G connection, First Contentful Paint on Chrome Desktop, Time to Interactive on Motorola Moto G Power, 3G connection, Time to Interactive on Chrome Desktop, First Contentful Paint on iPhone, 4G LTE, Speed Index on Chrome Desktop, Speed Index on iPhone, 4G LTE, Time to Interactive on iPhone, 4G LTE, Largest Contentful Paint on iPhone, 4G LTE, Total Blocking Time on Motorola Moto G Power, 3G connection, Largest Contentful Paint on Chrome Desktop, Total Image Size in Bytes on Chrome Desktop, Total Image Size in Bytes on iPhone, 4G LTE, Total Image Size in Bytes on Motorola Moto G Power, 3G connection, Total HTML Size in Bytes on Chrome Desktop, Total HTML Size in Bytes on iPhone, 4G LTE, Total HTML Size in Bytes on Motorola Moto G Power, 3G connection, Lighthouse Performance Score on Motorola Moto G Power, 3G connection, Lighthouse Performance Score on Chrome Desktop

Calibre: Site dashboard | View this PR | Edit settings | View documentation

@github-actions
Copy link

Formatter Benchmark Results

group                                    main                                   pr
-----                                    ----                                   --
formatter/checker.ts                     1.00    411.6±2.68ms     6.3 MB/sec    1.00    412.3±3.72ms     6.3 MB/sec
formatter/compiler.js                    1.00    226.3±1.56ms     4.6 MB/sec    1.01    227.6±1.37ms     4.6 MB/sec
formatter/d3.min.js                      1.00    177.6±1.02ms  1511.2 KB/sec    1.00    178.1±0.72ms  1506.8 KB/sec
formatter/dojo.js                        1.00     11.1±0.06ms     6.2 MB/sec    1.04     11.5±0.08ms     6.0 MB/sec
formatter/ios.d.ts                       1.02    257.1±1.56ms     7.3 MB/sec    1.00    251.9±1.53ms     7.4 MB/sec
formatter/jquery.min.js                  1.00     47.0±0.49ms  1800.2 KB/sec    1.02     48.0±0.40ms  1762.3 KB/sec
formatter/math.js                        1.00    344.0±2.55ms  1927.8 KB/sec    1.02    351.5±2.03ms  1886.3 KB/sec
formatter/parser.ts                      1.00      7.7±0.03ms     6.3 MB/sec    1.01      7.8±0.03ms     6.3 MB/sec
formatter/pixi.min.js                    1.01    193.3±1.02ms     2.3 MB/sec    1.00    190.6±1.31ms     2.3 MB/sec
formatter/react-dom.production.min.js    1.00     57.3±0.74ms     2.0 MB/sec    1.02     58.4±0.60ms  2017.7 KB/sec
formatter/react.production.min.js        1.00      2.6±0.01ms     2.3 MB/sec    1.02      2.7±0.01ms     2.3 MB/sec
formatter/router.ts                      1.00      6.2±0.05ms     9.9 MB/sec    1.03      6.4±0.05ms     9.5 MB/sec
formatter/tex-chtml-full.js              1.00    449.5±2.87ms     2.0 MB/sec    1.01    454.6±1.81ms     2.0 MB/sec
formatter/three.min.js                   1.00    230.4±2.67ms     2.5 MB/sec    1.02    234.6±1.49ms     2.5 MB/sec
formatter/typescript.js                  1.00  1513.4±15.87ms     6.3 MB/sec    1.01   1526.7±6.00ms     6.2 MB/sec
formatter/vue.global.prod.js             1.00     73.6±0.90ms  1675.3 KB/sec    1.03     76.1±0.88ms  1621.5 KB/sec

crates/rome_formatter/src/buffer.rs Outdated Show resolved Hide resolved
crates/rome_formatter/src/buffer.rs Outdated Show resolved Hide resolved
crates/rome_formatter/src/lib.rs Outdated Show resolved Hide resolved
crates/rome_formatter/src/lib.rs Outdated Show resolved Hide resolved
crates/rome_formatter/src/lib.rs Outdated Show resolved Hide resolved
@MichaReiser MichaReiser temporarily deployed to netlify-playground September 30, 2022 11:02 Inactive
@MichaReiser MichaReiser temporarily deployed to netlify-playground September 30, 2022 13:19 Inactive
@MichaReiser MichaReiser temporarily deployed to netlify-playground September 30, 2022 13:20 Inactive
@MichaReiser MichaReiser temporarily deployed to netlify-playground September 30, 2022 13:23 Inactive
@MichaReiser MichaReiser temporarily deployed to netlify-playground September 30, 2022 13:24 Inactive
@MichaReiser MichaReiser temporarily deployed to netlify-playground September 30, 2022 13:28 Inactive
@MichaReiser MichaReiser temporarily deployed to netlify-playground September 30, 2022 13:47 Inactive
@MichaReiser MichaReiser temporarily deployed to netlify-playground September 30, 2022 16:50 Inactive
@MichaReiser MichaReiser merged commit 407dbbc into main Sep 30, 2022
@MichaReiser MichaReiser deleted the feat/call-arguments branch September 30, 2022 17:09
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A-Formatter Area: formatter
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Reformat issue on call arguments
2 participants