prettier 3.0.0-alpha.3 → 3.0.0-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -13,11 +13,11 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
13
13
  ## Licenses of bundled dependencies
14
14
 
15
15
  The published Prettier artifact additionally contains code with the following licenses:
16
- MIT, ISC, BSD-2-Clause, BSD-3-Clause, Apache-2.0, 0BSD
16
+ MIT, ISC, BSD-2-Clause, BSD-3-Clause, 0BSD, Apache-2.0
17
17
 
18
18
  ## Bundled dependencies
19
19
 
20
- ### @angular/compiler@v14.2.6
20
+ ### @angular/compiler@v14.2.7
21
21
 
22
22
  License: MIT
23
23
  By: angular
@@ -118,7 +118,7 @@ Repository: <https://github.com/babel/babel.git>
118
118
 
119
119
  ----------------------------------------
120
120
 
121
- ### @babel/parser@v7.19.3
121
+ ### @babel/parser@v7.19.6
122
122
 
123
123
  License: MIT
124
124
  By: The Babel Team
@@ -337,6 +337,35 @@ License: MIT
337
337
 
338
338
  ----------------------------------------
339
339
 
340
+ ### @prettier/is-es5-identifier-name@v0.0.2
341
+
342
+ License: MIT
343
+ By: fisker Cheung
344
+
345
+ > MIT License
346
+ >
347
+ > Copyright (c) fisker Cheung <lionkay@gmail.com> (https://www.fiskercheung.com/)
348
+ >
349
+ > Permission is hereby granted, free of charge, to any person obtaining a copy
350
+ > of this software and associated documentation files (the "Software"), to deal
351
+ > in the Software without restriction, including without limitation the rights
352
+ > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
353
+ > copies of the Software, and to permit persons to whom the Software is
354
+ > furnished to do so, subject to the following conditions:
355
+ >
356
+ > The above copyright notice and this permission notice shall be included in all
357
+ > copies or substantial portions of the Software.
358
+ >
359
+ > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
360
+ > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
361
+ > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
362
+ > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
363
+ > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
364
+ > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
365
+ > SOFTWARE.
366
+
367
+ ----------------------------------------
368
+
340
369
  ### @prettier/parse-srcset@v2.0.2
341
370
 
342
371
  License: MIT
@@ -366,7 +395,7 @@ By: Alex Bell
366
395
 
367
396
  ----------------------------------------
368
397
 
369
- ### @typescript-eslint/types@v5.40.0
398
+ ### @typescript-eslint/types@v5.40.1
370
399
 
371
400
  License: MIT
372
401
  Repository: <https://github.com/typescript-eslint/typescript-eslint.git>
@@ -395,7 +424,7 @@ Repository: <https://github.com/typescript-eslint/typescript-eslint.git>
395
424
 
396
425
  ----------------------------------------
397
426
 
398
- ### @typescript-eslint/typescript-estree@v5.40.0
427
+ ### @typescript-eslint/typescript-estree@v5.40.1
399
428
 
400
429
  License: BSD-2-Clause
401
430
  Repository: <https://github.com/typescript-eslint/typescript-eslint.git>
@@ -429,35 +458,6 @@ Repository: <https://github.com/typescript-eslint/typescript-eslint.git>
429
458
 
430
459
  ----------------------------------------
431
460
 
432
- ### @typescript-eslint/visitor-keys@v5.40.0
433
-
434
- License: MIT
435
- Repository: <https://github.com/typescript-eslint/typescript-eslint.git>
436
-
437
- > MIT License
438
- >
439
- > Copyright (c) 2019 TypeScript ESLint and other contributors
440
- >
441
- > Permission is hereby granted, free of charge, to any person obtaining a copy
442
- > of this software and associated documentation files (the "Software"), to deal
443
- > in the Software without restriction, including without limitation the rights
444
- > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
445
- > copies of the Software, and to permit persons to whom the Software is
446
- > furnished to do so, subject to the following conditions:
447
- >
448
- > The above copyright notice and this permission notice shall be included in all
449
- > copies or substantial portions of the Software.
450
- >
451
- > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
452
- > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
453
- > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
454
- > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
455
- > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
456
- > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
457
- > SOFTWARE.
458
-
459
- ----------------------------------------
460
-
461
461
  ### acorn@v8.8.0
462
462
 
463
463
  License: MIT
@@ -1352,215 +1352,6 @@ By: Sindre Sorhus
1352
1352
 
1353
1353
  ----------------------------------------
1354
1354
 
1355
- ### eslint-visitor-keys@v3.3.0
1356
-
1357
- License: Apache-2.0
1358
- By: Toru Nagashima
1359
-
1360
- > Apache License
1361
- > Version 2.0, January 2004
1362
- > http://www.apache.org/licenses/
1363
- >
1364
- > TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1365
- >
1366
- > 1. Definitions.
1367
- >
1368
- > "License" shall mean the terms and conditions for use, reproduction,
1369
- > and distribution as defined by Sections 1 through 9 of this document.
1370
- >
1371
- > "Licensor" shall mean the copyright owner or entity authorized by
1372
- > the copyright owner that is granting the License.
1373
- >
1374
- > "Legal Entity" shall mean the union of the acting entity and all
1375
- > other entities that control, are controlled by, or are under common
1376
- > control with that entity. For the purposes of this definition,
1377
- > "control" means (i) the power, direct or indirect, to cause the
1378
- > direction or management of such entity, whether by contract or
1379
- > otherwise, or (ii) ownership of fifty percent (50%) or more of the
1380
- > outstanding shares, or (iii) beneficial ownership of such entity.
1381
- >
1382
- > "You" (or "Your") shall mean an individual or Legal Entity
1383
- > exercising permissions granted by this License.
1384
- >
1385
- > "Source" form shall mean the preferred form for making modifications,
1386
- > including but not limited to software source code, documentation
1387
- > source, and configuration files.
1388
- >
1389
- > "Object" form shall mean any form resulting from mechanical
1390
- > transformation or translation of a Source form, including but
1391
- > not limited to compiled object code, generated documentation,
1392
- > and conversions to other media types.
1393
- >
1394
- > "Work" shall mean the work of authorship, whether in Source or
1395
- > Object form, made available under the License, as indicated by a
1396
- > copyright notice that is included in or attached to the work
1397
- > (an example is provided in the Appendix below).
1398
- >
1399
- > "Derivative Works" shall mean any work, whether in Source or Object
1400
- > form, that is based on (or derived from) the Work and for which the
1401
- > editorial revisions, annotations, elaborations, or other modifications
1402
- > represent, as a whole, an original work of authorship. For the purposes
1403
- > of this License, Derivative Works shall not include works that remain
1404
- > separable from, or merely link (or bind by name) to the interfaces of,
1405
- > the Work and Derivative Works thereof.
1406
- >
1407
- > "Contribution" shall mean any work of authorship, including
1408
- > the original version of the Work and any modifications or additions
1409
- > to that Work or Derivative Works thereof, that is intentionally
1410
- > submitted to Licensor for inclusion in the Work by the copyright owner
1411
- > or by an individual or Legal Entity authorized to submit on behalf of
1412
- > the copyright owner. For the purposes of this definition, "submitted"
1413
- > means any form of electronic, verbal, or written communication sent
1414
- > to the Licensor or its representatives, including but not limited to
1415
- > communication on electronic mailing lists, source code control systems,
1416
- > and issue tracking systems that are managed by, or on behalf of, the
1417
- > Licensor for the purpose of discussing and improving the Work, but
1418
- > excluding communication that is conspicuously marked or otherwise
1419
- > designated in writing by the copyright owner as "Not a Contribution."
1420
- >
1421
- > "Contributor" shall mean Licensor and any individual or Legal Entity
1422
- > on behalf of whom a Contribution has been received by Licensor and
1423
- > subsequently incorporated within the Work.
1424
- >
1425
- > 2. Grant of Copyright License. Subject to the terms and conditions of
1426
- > this License, each Contributor hereby grants to You a perpetual,
1427
- > worldwide, non-exclusive, no-charge, royalty-free, irrevocable
1428
- > copyright license to reproduce, prepare Derivative Works of,
1429
- > publicly display, publicly perform, sublicense, and distribute the
1430
- > Work and such Derivative Works in Source or Object form.
1431
- >
1432
- > 3. Grant of Patent License. Subject to the terms and conditions of
1433
- > this License, each Contributor hereby grants to You a perpetual,
1434
- > worldwide, non-exclusive, no-charge, royalty-free, irrevocable
1435
- > (except as stated in this section) patent license to make, have made,
1436
- > use, offer to sell, sell, import, and otherwise transfer the Work,
1437
- > where such license applies only to those patent claims licensable
1438
- > by such Contributor that are necessarily infringed by their
1439
- > Contribution(s) alone or by combination of their Contribution(s)
1440
- > with the Work to which such Contribution(s) was submitted. If You
1441
- > institute patent litigation against any entity (including a
1442
- > cross-claim or counterclaim in a lawsuit) alleging that the Work
1443
- > or a Contribution incorporated within the Work constitutes direct
1444
- > or contributory patent infringement, then any patent licenses
1445
- > granted to You under this License for that Work shall terminate
1446
- > as of the date such litigation is filed.
1447
- >
1448
- > 4. Redistribution. You may reproduce and distribute copies of the
1449
- > Work or Derivative Works thereof in any medium, with or without
1450
- > modifications, and in Source or Object form, provided that You
1451
- > meet the following conditions:
1452
- >
1453
- > (a) You must give any other recipients of the Work or
1454
- > Derivative Works a copy of this License; and
1455
- >
1456
- > (b) You must cause any modified files to carry prominent notices
1457
- > stating that You changed the files; and
1458
- >
1459
- > (c) You must retain, in the Source form of any Derivative Works
1460
- > that You distribute, all copyright, patent, trademark, and
1461
- > attribution notices from the Source form of the Work,
1462
- > excluding those notices that do not pertain to any part of
1463
- > the Derivative Works; and
1464
- >
1465
- > (d) If the Work includes a "NOTICE" text file as part of its
1466
- > distribution, then any Derivative Works that You distribute must
1467
- > include a readable copy of the attribution notices contained
1468
- > within such NOTICE file, excluding those notices that do not
1469
- > pertain to any part of the Derivative Works, in at least one
1470
- > of the following places: within a NOTICE text file distributed
1471
- > as part of the Derivative Works; within the Source form or
1472
- > documentation, if provided along with the Derivative Works; or,
1473
- > within a display generated by the Derivative Works, if and
1474
- > wherever such third-party notices normally appear. The contents
1475
- > of the NOTICE file are for informational purposes only and
1476
- > do not modify the License. You may add Your own attribution
1477
- > notices within Derivative Works that You distribute, alongside
1478
- > or as an addendum to the NOTICE text from the Work, provided
1479
- > that such additional attribution notices cannot be construed
1480
- > as modifying the License.
1481
- >
1482
- > You may add Your own copyright statement to Your modifications and
1483
- > may provide additional or different license terms and conditions
1484
- > for use, reproduction, or distribution of Your modifications, or
1485
- > for any such Derivative Works as a whole, provided Your use,
1486
- > reproduction, and distribution of the Work otherwise complies with
1487
- > the conditions stated in this License.
1488
- >
1489
- > 5. Submission of Contributions. Unless You explicitly state otherwise,
1490
- > any Contribution intentionally submitted for inclusion in the Work
1491
- > by You to the Licensor shall be under the terms and conditions of
1492
- > this License, without any additional terms or conditions.
1493
- > Notwithstanding the above, nothing herein shall supersede or modify
1494
- > the terms of any separate license agreement you may have executed
1495
- > with Licensor regarding such Contributions.
1496
- >
1497
- > 6. Trademarks. This License does not grant permission to use the trade
1498
- > names, trademarks, service marks, or product names of the Licensor,
1499
- > except as required for reasonable and customary use in describing the
1500
- > origin of the Work and reproducing the content of the NOTICE file.
1501
- >
1502
- > 7. Disclaimer of Warranty. Unless required by applicable law or
1503
- > agreed to in writing, Licensor provides the Work (and each
1504
- > Contributor provides its Contributions) on an "AS IS" BASIS,
1505
- > WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
1506
- > implied, including, without limitation, any warranties or conditions
1507
- > of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
1508
- > PARTICULAR PURPOSE. You are solely responsible for determining the
1509
- > appropriateness of using or redistributing the Work and assume any
1510
- > risks associated with Your exercise of permissions under this License.
1511
- >
1512
- > 8. Limitation of Liability. In no event and under no legal theory,
1513
- > whether in tort (including negligence), contract, or otherwise,
1514
- > unless required by applicable law (such as deliberate and grossly
1515
- > negligent acts) or agreed to in writing, shall any Contributor be
1516
- > liable to You for damages, including any direct, indirect, special,
1517
- > incidental, or consequential damages of any character arising as a
1518
- > result of this License or out of the use or inability to use the
1519
- > Work (including but not limited to damages for loss of goodwill,
1520
- > work stoppage, computer failure or malfunction, or any and all
1521
- > other commercial damages or losses), even if such Contributor
1522
- > has been advised of the possibility of such damages.
1523
- >
1524
- > 9. Accepting Warranty or Additional Liability. While redistributing
1525
- > the Work or Derivative Works thereof, You may choose to offer,
1526
- > and charge a fee for, acceptance of support, warranty, indemnity,
1527
- > or other liability obligations and/or rights consistent with this
1528
- > License. However, in accepting such obligations, You may act only
1529
- > on Your own behalf and on Your sole responsibility, not on behalf
1530
- > of any other Contributor, and only if You agree to indemnify,
1531
- > defend, and hold each Contributor harmless for any liability
1532
- > incurred by, or claims asserted against, such Contributor by reason
1533
- > of your accepting any such warranty or additional liability.
1534
- >
1535
- > END OF TERMS AND CONDITIONS
1536
- >
1537
- > APPENDIX: How to apply the Apache License to your work.
1538
- >
1539
- > To apply the Apache License to your work, attach the following
1540
- > boilerplate notice, with the fields enclosed by brackets "{}"
1541
- > replaced with your own identifying information. (Don't include
1542
- > the brackets!) The text should be enclosed in the appropriate
1543
- > comment syntax for the file format. We also recommend that a
1544
- > file or class name and description of purpose be included on the
1545
- > same "printed page" as the copyright notice for easier
1546
- > identification within third-party archives.
1547
- >
1548
- > Copyright contributors
1549
- >
1550
- > Licensed under the Apache License, Version 2.0 (the "License");
1551
- > you may not use this file except in compliance with the License.
1552
- > You may obtain a copy of the License at
1553
- >
1554
- > http://www.apache.org/licenses/LICENSE-2.0
1555
- >
1556
- > Unless required by applicable law or agreed to in writing, software
1557
- > distributed under the License is distributed on an "AS IS" BASIS,
1558
- > WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1559
- > See the License for the specific language governing permissions and
1560
- > limitations under the License.
1561
-
1562
- ----------------------------------------
1563
-
1564
1355
  ### espree@v9.4.0
1565
1356
 
1566
1357
  License: BSD-2-Clause
@@ -1594,33 +1385,6 @@ By: Nicholas C. Zakas
1594
1385
 
1595
1386
  ----------------------------------------
1596
1387
 
1597
- ### esutils@v2.0.3
1598
-
1599
- License: BSD-2-Clause
1600
- Repository: <http://github.com/estools/esutils.git>
1601
-
1602
- > Redistribution and use in source and binary forms, with or without
1603
- > modification, are permitted provided that the following conditions are met:
1604
- >
1605
- > * Redistributions of source code must retain the above copyright
1606
- > notice, this list of conditions and the following disclaimer.
1607
- > * Redistributions in binary form must reproduce the above copyright
1608
- > notice, this list of conditions and the following disclaimer in the
1609
- > documentation and/or other materials provided with the distribution.
1610
- >
1611
- > THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1612
- > AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1613
- > IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1614
- > ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
1615
- > DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
1616
- > (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
1617
- > LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
1618
- > ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1619
- > (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
1620
- > THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1621
-
1622
- ----------------------------------------
1623
-
1624
1388
  ### extend@v3.0.2
1625
1389
 
1626
1390
  License: MIT
@@ -1939,7 +1703,7 @@ Repository: <git+https://github.com/mk-pmb/flatten-js.git>
1939
1703
 
1940
1704
  ----------------------------------------
1941
1705
 
1942
- ### flow-parser@v0.190.0
1706
+ ### flow-parser@v0.190.1
1943
1707
 
1944
1708
  License: MIT
1945
1709
  By: Flow Team
@@ -4101,7 +3865,7 @@ License: ISC
4101
3865
 
4102
3866
  ----------------------------------------
4103
3867
 
4104
- ### semver@v7.3.7
3868
+ ### semver@v7.3.8
4105
3869
 
4106
3870
  License: ISC
4107
3871
  By: GitHub Inc.
package/doc.js CHANGED
@@ -194,7 +194,7 @@
194
194
  }
195
195
  return { type: DOC_TYPE_FILL, parts };
196
196
  }
197
- function ifBreak(breakContents, flatContents, opts = {}) {
197
+ function ifBreak(breakContents, flatContents = "", opts = {}) {
198
198
  if (false) {
199
199
  if (breakContents) {
200
200
  assertDoc(breakContents);
@@ -469,12 +469,7 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`;
469
469
  break;
470
470
  }
471
471
  case DOC_TYPE_IF_BREAK:
472
- if (doc2.flatContents) {
473
- docsStack.push(doc2.flatContents);
474
- }
475
- if (doc2.breakContents) {
476
- docsStack.push(doc2.breakContents);
477
- }
472
+ docsStack.push(doc2.flatContents, doc2.breakContents);
478
473
  break;
479
474
  case DOC_TYPE_GROUP:
480
475
  if (shouldTraverseConditionalGroups && doc2.expandedStates) {
@@ -539,19 +534,12 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`;
539
534
  ...doc2,
540
535
  parts: doc2.parts.map(rec)
541
536
  });
542
- case DOC_TYPE_IF_BREAK: {
543
- let {
544
- breakContents,
545
- flatContents
546
- } = doc2;
547
- breakContents && (breakContents = rec(breakContents));
548
- flatContents && (flatContents = rec(flatContents));
537
+ case DOC_TYPE_IF_BREAK:
549
538
  return cb({
550
539
  ...doc2,
551
- breakContents,
552
- flatContents
540
+ breakContents: rec(doc2.breakContents),
541
+ flatContents: rec(doc2.flatContents)
553
542
  });
554
- }
555
543
  case DOC_TYPE_GROUP: {
556
544
  let {
557
545
  expandedStates,
@@ -659,62 +647,66 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`;
659
647
  return doc.soft ? "" : " ";
660
648
  }
661
649
  if (doc.type === DOC_TYPE_IF_BREAK) {
662
- return doc.flatContents || "";
650
+ return doc.flatContents;
663
651
  }
664
652
  return doc;
665
653
  }
666
654
  function removeLines(doc) {
667
655
  return mapDoc(doc, removeLinesFn);
668
656
  }
669
- var isHardline = (doc, nextDoc) => doc && doc.type === DOC_TYPE_LINE && doc.hard && nextDoc && nextDoc.type === DOC_TYPE_BREAK_PARENT;
670
- function stripDocTrailingHardlineFromDoc(doc) {
671
- if (!doc) {
672
- return doc;
657
+ function stripTrailingHardlineFromParts(parts) {
658
+ parts = [...parts];
659
+ while (parts.length >= 2 && at_default(false, parts, -2).type === DOC_TYPE_LINE && at_default(false, parts, -1).type === DOC_TYPE_BREAK_PARENT) {
660
+ parts.length -= 2;
673
661
  }
674
- if (Array.isArray(doc) || doc.type === DOC_TYPE_FILL) {
675
- const parts = getDocParts(doc);
676
- while (parts.length > 1 && isHardline(...parts.slice(-2))) {
677
- parts.length -= 2;
678
- }
679
- if (parts.length > 0) {
680
- const lastPart = stripDocTrailingHardlineFromDoc(at_default(false, parts, -1));
681
- parts[parts.length - 1] = lastPart;
682
- }
683
- return Array.isArray(doc) ? parts : {
684
- ...doc,
685
- parts
686
- };
662
+ if (parts.length > 0) {
663
+ const lastPart = stripTrailingHardlineFromDoc(at_default(false, parts, -1));
664
+ parts[parts.length - 1] = lastPart;
687
665
  }
688
- switch (doc.type) {
666
+ return parts;
667
+ }
668
+ function stripTrailingHardlineFromDoc(doc) {
669
+ switch (get_doc_type_default(doc)) {
689
670
  case DOC_TYPE_ALIGN:
690
671
  case DOC_TYPE_INDENT:
691
672
  case DOC_TYPE_INDENT_IF_BREAK:
692
673
  case DOC_TYPE_GROUP:
693
674
  case DOC_TYPE_LINE_SUFFIX:
694
675
  case DOC_TYPE_LABEL: {
695
- const contents = stripDocTrailingHardlineFromDoc(doc.contents);
676
+ const contents = stripTrailingHardlineFromDoc(doc.contents);
696
677
  return {
697
678
  ...doc,
698
679
  contents
699
680
  };
700
681
  }
701
- case DOC_TYPE_IF_BREAK: {
702
- const breakContents = stripDocTrailingHardlineFromDoc(doc.breakContents);
703
- const flatContents = stripDocTrailingHardlineFromDoc(doc.flatContents);
682
+ case DOC_TYPE_IF_BREAK:
704
683
  return {
705
684
  ...doc,
706
- breakContents,
707
- flatContents
685
+ breakContents: stripTrailingHardlineFromDoc(doc.breakContents),
686
+ flatContents: stripTrailingHardlineFromDoc(doc.flatContents)
708
687
  };
709
- }
688
+ case DOC_TYPE_FILL:
689
+ return {
690
+ ...doc,
691
+ parts: stripTrailingHardlineFromParts(doc.parts)
692
+ };
693
+ case DOC_TYPE_ARRAY:
694
+ return stripTrailingHardlineFromParts(doc);
695
+ case DOC_TYPE_STRING:
696
+ return doc.replace(/[\n\r]*$/, "");
697
+ case DOC_TYPE_CURSOR:
698
+ case DOC_TYPE_TRIM:
699
+ case DOC_TYPE_LINE_SUFFIX_BOUNDARY:
700
+ case DOC_TYPE_LINE:
701
+ case DOC_TYPE_BREAK_PARENT:
702
+ break;
703
+ default:
704
+ throw new invalid_doc_error_default(doc);
710
705
  }
711
706
  return doc;
712
707
  }
713
708
  function stripTrailingHardline(doc) {
714
- if (typeof doc === "string") {
715
- return doc.replace(/(?:\r?\n)*$/, "");
716
- }
717
- return stripDocTrailingHardlineFromDoc(cleanDoc(doc));
709
+ return stripTrailingHardlineFromDoc(cleanDoc(doc));
718
710
  }
719
711
  function cleanDocFn(doc) {
720
712
  switch (get_doc_type_default(doc)) {
@@ -1374,6 +1366,7 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`;
1374
1366
  });
1375
1367
  init_define_process();
1376
1368
  function flattenDoc(doc) {
1369
+ var _a;
1377
1370
  if (!doc) {
1378
1371
  return "";
1379
1372
  }
@@ -1402,7 +1395,7 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`;
1402
1395
  return {
1403
1396
  ...doc,
1404
1397
  contents: flattenDoc(doc.contents),
1405
- expandedStates: doc.expandedStates && doc.expandedStates.map(flattenDoc)
1398
+ expandedStates: (_a = doc.expandedStates) == null ? void 0 : _a.map(flattenDoc)
1406
1399
  };
1407
1400
  }
1408
1401
  if (doc.type === DOC_TYPE_FILL) {