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

refactor(rome_js_formatter): Remove unnecessary groups from format_separated #2770

Merged
merged 1 commit into from
Jun 24, 2022

Conversation

MichaReiser
Copy link
Contributor

format_separated used to group all elements by default. This is often undesired and also comes with a performance cost (printer needs to test if the elements fit).

This PR changes the default of format_separated so that it doesn't group the elements except if enabled explicitly using nodes_grouped.

This PR further fixes the formatting of named import specifiers to more closely match Prettier's formatting.

Test Plan

cargo test and I compared the snapshot changes with Prettier to make sure they match.

@MichaReiser MichaReiser temporarily deployed to aws June 23, 2022 15:41 Inactive
…eparated`

`format_separated` used to group all elements by default. This is often undesired and also comes with a performance cost (printer needs to test if the elements fit).

This PR changes the default of `format_separated` so that it doesn't group the elements except if enabled explicitly using `nodes_grouped`.

This PR further fixes the formatting of named import specifiers to more closely match Prettier's foramtting.
@MichaReiser MichaReiser force-pushed the refactor/separated-nodes-grouped branch from f8074de to 4b4a9bb Compare June 23, 2022 15:42
@cloudflare-pages
Copy link

cloudflare-pages bot commented Jun 23, 2022

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 4b4a9bb
Status: ✅  Deploy successful!
Preview URL: https://e61831a2.tools-8rn.pages.dev
Branch Preview URL: https://refactor-separated-nodes-gro.tools-8rn.pages.dev

View logs

@MichaReiser MichaReiser temporarily deployed to aws June 23, 2022 15:42 Inactive
@github-actions
Copy link

github-actions bot commented Jun 23, 2022

@MichaReiser
Copy link
Contributor Author

!bench_formatter

@github-actions
Copy link

Formatter Benchmark Results

group                                    main                                   pr
-----                                    ----                                   --
formatter/checker.ts                     1.02    430.2±4.23ms     6.0 MB/sec    1.00    420.5±3.40ms     6.2 MB/sec
formatter/compiler.js                    1.01    278.1±2.25ms     3.8 MB/sec    1.00    276.1±3.05ms     3.8 MB/sec
formatter/d3.min.js                      1.01    229.9±1.55ms  1167.6 KB/sec    1.00    227.6±2.57ms  1179.2 KB/sec
formatter/dojo.js                        1.02     15.4±0.19ms     4.4 MB/sec    1.00     15.2±0.13ms     4.5 MB/sec
formatter/ios.d.ts                       1.03    290.7±1.91ms     6.4 MB/sec    1.00    283.4±2.50ms     6.6 MB/sec
formatter/jquery.min.js                  1.00     58.9±1.21ms  1436.5 KB/sec    1.00     59.0±1.19ms  1433.2 KB/sec
formatter/math.js                        1.01    455.0±5.85ms  1457.4 KB/sec    1.00    449.1±4.70ms  1476.5 KB/sec
formatter/parser.ts                      1.00      9.8±0.12ms     4.9 MB/sec    1.00      9.8±0.12ms     4.9 MB/sec
formatter/pixi.min.js                    1.01    257.6±1.49ms  1744.4 KB/sec    1.00    254.3±3.63ms  1767.4 KB/sec
formatter/react-dom.production.min.js    1.02     75.6±0.80ms  1559.2 KB/sec    1.00     74.4±1.25ms  1585.0 KB/sec
formatter/react.production.min.js        1.00      3.6±0.02ms  1746.0 KB/sec    1.00      3.6±0.01ms  1743.0 KB/sec
formatter/router.ts                      1.01      7.2±0.11ms     8.2 MB/sec    1.00      7.2±0.09ms     8.2 MB/sec
formatter/tex-chtml-full.js              1.02    591.1±4.12ms  1578.7 KB/sec    1.00    579.7±3.48ms  1609.7 KB/sec
formatter/three.min.js                   1.01    296.9±1.41ms  2025.2 KB/sec    1.00    294.2±2.20ms  2043.5 KB/sec
formatter/typescript.js                  1.00   1713.3±9.80ms     5.5 MB/sec    1.00  1705.7±13.41ms     5.6 MB/sec
formatter/vue.global.prod.js             1.00     97.0±1.55ms  1272.4 KB/sec    1.00     97.4±1.46ms  1267.2 KB/sec

@github-actions
Copy link

Formatter Benchmark Results

group                                    main                                   pr
-----                                    ----                                   --
formatter/checker.ts                     1.03   495.5±14.39ms     5.2 MB/sec    1.00   480.7±11.80ms     5.4 MB/sec
formatter/compiler.js                    1.03    316.6±9.50ms     3.3 MB/sec    1.00   308.4±12.56ms     3.4 MB/sec
formatter/d3.min.js                      1.01    255.3±8.18ms  1051.3 KB/sec    1.00    251.6±8.54ms  1066.9 KB/sec
formatter/dojo.js                        1.04     16.6±0.55ms     4.1 MB/sec    1.00     15.9±0.47ms     4.3 MB/sec
formatter/ios.d.ts                       1.05    315.1±7.56ms     5.9 MB/sec    1.00    301.3±8.26ms     6.2 MB/sec
formatter/jquery.min.js                  1.02     64.4±3.03ms  1315.0 KB/sec    1.00     62.8±3.04ms  1346.5 KB/sec
formatter/math.js                        1.06   525.1±12.37ms  1262.9 KB/sec    1.00   496.9±11.95ms  1334.3 KB/sec
formatter/parser.ts                      1.01     10.7±0.37ms     4.5 MB/sec    1.00     10.5±0.45ms     4.6 MB/sec
formatter/pixi.min.js                    1.01    287.6±9.38ms  1562.7 KB/sec    1.00    283.4±8.07ms  1586.0 KB/sec
formatter/react-dom.production.min.js    1.02     81.6±3.37ms  1443.7 KB/sec    1.00     80.0±3.98ms  1472.9 KB/sec
formatter/react.production.min.js        1.04      4.0±0.12ms  1587.2 KB/sec    1.00      3.8±0.10ms  1658.0 KB/sec
formatter/router.ts                      1.02      7.8±0.20ms     7.5 MB/sec    1.00      7.7±0.23ms     7.7 MB/sec
formatter/tex-chtml-full.js              1.04   670.3±13.81ms  1392.1 KB/sec    1.00   642.8±13.58ms  1451.6 KB/sec
formatter/three.min.js                   1.02    328.5±9.72ms  1830.0 KB/sec    1.00   322.7±10.73ms  1863.1 KB/sec
formatter/typescript.js                  1.03  1966.1±35.15ms     4.8 MB/sec    1.00  1914.0±33.38ms     5.0 MB/sec
formatter/vue.global.prod.js             1.05    108.8±5.04ms  1134.4 KB/sec    1.00    103.8±5.70ms  1188.1 KB/sec

@MichaReiser MichaReiser merged commit e6c5ce9 into main Jun 24, 2022
@MichaReiser MichaReiser deleted the refactor/separated-nodes-grouped branch June 24, 2022 05:57
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants