diff --git a/package.json b/package.json index b612fbb92..e47b3bd9c 100644 --- a/package.json +++ b/package.json @@ -159,8 +159,8 @@ "eslint-plugin-jest": "29.15.0", "eslint-plugin-n": "17.24.0", "eslint-plugin-regexp": "3.0.0", - "eslint-plugin-simple-import-sort": "12.1.1", - "eslint-plugin-unicorn": "63.0.0", + "eslint-plugin-simple-import-sort": "13.0.0", + "eslint-plugin-unicorn": "64.0.0", "esm-utils": "4.4.2", "get-port": "7.2.0", "gfm-test-suite": "0.0.2", diff --git a/src/document/printer/printer.js b/src/document/printer/printer.js index 0c3236797..a5738f429 100644 --- a/src/document/printer/printer.js +++ b/src/document/printer/printer.js @@ -242,84 +242,84 @@ function printDocToString(doc, options) { position -= result.trim(); break; - case DOC_TYPE_GROUP: - { + case DOC_TYPE_GROUP: { + /** @type {Command} */ + const command = (function printGroup() { + if (mode === MODE_FLAT && !shouldRemeasure) { + return { + indent, + mode: doc.break ? MODE_BREAK : MODE_FLAT, + doc: doc.contents, + }; + } + + shouldRemeasure = false; + const remainingWidth = width - position; + const hasLineSuffix = lineSuffix.length > 0; + /** @type {Command} */ - const command = (function printGroup() { - if (mode === MODE_FLAT && !shouldRemeasure) { - return { - indent, - mode: doc.break ? MODE_BREAK : MODE_FLAT, - doc: doc.contents, - }; - } + const flatCommand = { indent, mode: MODE_FLAT, doc: doc.contents }; + if ( + !doc.break && + fits( + flatCommand, + commands, + remainingWidth, + hasLineSuffix, + groupModeMap, + ) + ) { + return flatCommand; + } - shouldRemeasure = false; - const remainingWidth = width - position; - const hasLineSuffix = lineSuffix.length > 0; + if (!doc.expandedStates) { + return { indent, mode: MODE_BREAK, doc: doc.contents }; + } - /** @type {Command} */ - const flatCommand = { indent, mode: MODE_FLAT, doc: doc.contents }; - if ( - !doc.break && - fits( - flatCommand, - commands, - remainingWidth, - hasLineSuffix, - groupModeMap, - ) + if (!doc.break) { + // Expanded states are a rare case where a document + // can manually provide multiple representations of + // itself. It provides an array of documents + // going from the least expanded (most flattened) + // representation first to the most expanded. If a + // group has these, we need to manually go through + // these states and find the first one that fits. + for ( + let index = 1; + index < doc.expandedStates.length - 1; + index++ ) { - return flatCommand; - } - - if (!doc.expandedStates) { - return { indent, mode: MODE_BREAK, doc: doc.contents }; - } - - if (!doc.break) { - // Expanded states are a rare case where a document - // can manually provide multiple representations of - // itself. It provides an array of documents - // going from the least expanded (most flattened) - // representation first to the most expanded. If a - // group has these, we need to manually go through - // these states and find the first one that fits. - for ( - let index = 1; - index < doc.expandedStates.length - 1; - index++ + /** @type {Command} */ + const flatCommand = { + indent, + mode: MODE_FLAT, + doc: doc.expandedStates[index], + }; + if ( + fits( + flatCommand, + commands, + remainingWidth, + hasLineSuffix, + groupModeMap, + ) ) { - /** @type {Command} */ - const flatCommand = { - indent, - mode: MODE_FLAT, - doc: doc.expandedStates[index], - }; - if ( - fits( - flatCommand, - commands, - remainingWidth, - hasLineSuffix, - groupModeMap, - ) - ) { - return flatCommand; - } + return flatCommand; } } - - return { indent, mode: MODE_BREAK, doc: doc.expandedStates.at(-1) }; - })(); - - commands.push(command); - - if (doc.id) { - groupModeMap[doc.id] = command.mode; } + + return { indent, mode: MODE_BREAK, doc: doc.expandedStates.at(-1) }; + })(); + + commands.push(command); + + if (doc.id) { + groupModeMap[doc.id] = command.mode; } + break; + } // Fills each line with as much code as possible before moving to a new // line with the same indentation. // diff --git a/yarn.lock b/yarn.lock index 323b06bd2..87c2c3119 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1305,7 +1305,7 @@ __metadata: languageName: node linkType: hard -"@eslint-community/eslint-utils@npm:^4.1.2, @eslint-community/eslint-utils@npm:^4.2.0, @eslint-community/eslint-utils@npm:^4.5.0, @eslint-community/eslint-utils@npm:^4.8.0, @eslint-community/eslint-utils@npm:^4.9.0, @eslint-community/eslint-utils@npm:^4.9.1": +"@eslint-community/eslint-utils@npm:^4.1.2, @eslint-community/eslint-utils@npm:^4.2.0, @eslint-community/eslint-utils@npm:^4.5.0, @eslint-community/eslint-utils@npm:^4.8.0, @eslint-community/eslint-utils@npm:^4.9.1": version: 4.9.1 resolution: "@eslint-community/eslint-utils@npm:4.9.1" dependencies: @@ -3412,12 +3412,12 @@ __metadata: languageName: node linkType: hard -"baseline-browser-mapping@npm:^2.9.0": - version: 2.9.11 - resolution: "baseline-browser-mapping@npm:2.9.11" +"baseline-browser-mapping@npm:^2.10.12, baseline-browser-mapping@npm:^2.9.0": + version: 2.10.17 + resolution: "baseline-browser-mapping@npm:2.10.17" bin: - baseline-browser-mapping: dist/cli.js - checksum: 10/d71fe6693f999ee0bf1fcd72b31c01390f2bfac40d179175817f24cdb11b19d14a102227a8fa28e0a4733a17c780458c17384c75f2227e45b0e8a0080caf6532 + baseline-browser-mapping: dist/cli.cjs + checksum: 10/06ff0ada22d377600f34011811c6178d89181f02d39dcdeb1f4d9c61a26d2b7f7725be3b01ca60b54727aaec217e048b49494dcbef548b0433eecd028d3c1afd languageName: node linkType: hard @@ -3485,7 +3485,7 @@ __metadata: languageName: node linkType: hard -"browserslist@npm:4.28.1, browserslist@npm:^4.24.0, browserslist@npm:^4.25.2, browserslist@npm:^4.28.0": +"browserslist@npm:4.28.1": version: 4.28.1 resolution: "browserslist@npm:4.28.1" dependencies: @@ -3500,6 +3500,21 @@ __metadata: languageName: node linkType: hard +"browserslist@npm:^4.24.0, browserslist@npm:^4.25.2, browserslist@npm:^4.28.1": + version: 4.28.2 + resolution: "browserslist@npm:4.28.2" + dependencies: + baseline-browser-mapping: "npm:^2.10.12" + caniuse-lite: "npm:^1.0.30001782" + electron-to-chromium: "npm:^1.5.328" + node-releases: "npm:^2.0.36" + update-browserslist-db: "npm:^1.2.3" + bin: + browserslist: cli.js + checksum: 10/cff88386e5b5ba5614c9063bd32ef94865bba22b6a381844c7d09ea1eea62a2247e7106e516abdbfda6b75b9986044c991dfe45f92f10add5ad63dccc07589ec + languageName: node + linkType: hard + "bser@npm:2.1.1": version: 2.1.1 resolution: "bser@npm:2.1.1" @@ -3635,10 +3650,10 @@ __metadata: languageName: node linkType: hard -"caniuse-lite@npm:^1.0.30001759": - version: 1.0.30001762 - resolution: "caniuse-lite@npm:1.0.30001762" - checksum: 10/d60a589180198ac759fa1775e521862f03503286cc9354144adcd88e76d275f03b2b6e9cab1c606790eee9d6af5cedbedb048ec652f5ff77a2b229992b7c4845 +"caniuse-lite@npm:^1.0.30001759, caniuse-lite@npm:^1.0.30001782": + version: 1.0.30001787 + resolution: "caniuse-lite@npm:1.0.30001787" + checksum: 10/2b3a2400b21d89123f13b7a8a7ad58dbdeb9971b62e33f43712d7209b69656f8bfd8ab67ab760c12e5fa7967b18c108ca67d7f20b7c7ccf039621f7db56baecf languageName: node linkType: hard @@ -3754,7 +3769,7 @@ __metadata: languageName: node linkType: hard -"ci-info@npm:4.4.0, ci-info@npm:^4.2.0, ci-info@npm:^4.3.1": +"ci-info@npm:4.4.0, ci-info@npm:^4.2.0, ci-info@npm:^4.4.0": version: 4.4.0 resolution: "ci-info@npm:4.4.0" checksum: 10/dfded0c630267d89660c8abb988ac8395a382bdfefedcc03e3e2858523312c5207db777c239c34774e3fcff11f015477c19d2ac8a58ea58aa476614a2e64f434 @@ -3917,12 +3932,12 @@ __metadata: languageName: node linkType: hard -"core-js-compat@npm:^3.46.0": - version: 3.47.0 - resolution: "core-js-compat@npm:3.47.0" +"core-js-compat@npm:^3.49.0": + version: 3.49.0 + resolution: "core-js-compat@npm:3.49.0" dependencies: - browserslist: "npm:^4.28.0" - checksum: 10/8555ac0aede2e61e3b37c50d31a9d63bb59e96ef76194bea0521d2778b24d8b20b45bed7bf2fce9df9856872a1c31e03fec1da101507b4dbaba669693dc95f94 + browserslist: "npm:^4.28.1" + checksum: 10/eb35ad9b31a613092d32e5eb0c9fecb695e680bb29509fe04ae297ef790cea47d06864ef8939c8f5f189cce0bd2807fef8b2d6450f7eeb917ffaaf38a775dece languageName: node linkType: hard @@ -4300,10 +4315,10 @@ __metadata: languageName: node linkType: hard -"electron-to-chromium@npm:^1.5.263": - version: 1.5.267 - resolution: "electron-to-chromium@npm:1.5.267" - checksum: 10/05e55e810cb6a3cda8d29dfdeec7ac0e59727a77a796a157f1a1d65edac16d45eed69ed5c99e354872ab16c48967c2d0a0600653051ae380a3b7a4d6210b1e60 +"electron-to-chromium@npm:^1.5.263, electron-to-chromium@npm:^1.5.328": + version: 1.5.334 + resolution: "electron-to-chromium@npm:1.5.334" + checksum: 10/ddf7c6d6064424a629b6437e7a30dc2ebb70f6100076fbfbb4833eaf4a60a4673b71292b627a456f4396a729fe50d6e9f77e1735af89902cbd48cd3672a7bd2f languageName: node linkType: hard @@ -4696,38 +4711,38 @@ __metadata: languageName: node linkType: hard -"eslint-plugin-simple-import-sort@npm:12.1.1": - version: 12.1.1 - resolution: "eslint-plugin-simple-import-sort@npm:12.1.1" +"eslint-plugin-simple-import-sort@npm:13.0.0": + version: 13.0.0 + resolution: "eslint-plugin-simple-import-sort@npm:13.0.0" peerDependencies: eslint: ">=5.0.0" - checksum: 10/2a690cea9243fbefa70345687bca8952f5e185fa459b7a8db687a908cc31082435cfee236c619d5245548fa5f89a2f2c4f8499f80512e048d2bedc60e3662d5a + checksum: 10/4ef64b0e13e6c22d929b4d8f4c68dcb001ecc273b0be7ef1318278bafef4942dcb1454f099e506dcf8bcf729311ad3f7c255a688ab06e71265f5dec4111cb71d languageName: node linkType: hard -"eslint-plugin-unicorn@npm:63.0.0": - version: 63.0.0 - resolution: "eslint-plugin-unicorn@npm:63.0.0" +"eslint-plugin-unicorn@npm:64.0.0": + version: 64.0.0 + resolution: "eslint-plugin-unicorn@npm:64.0.0" dependencies: "@babel/helper-validator-identifier": "npm:^7.28.5" - "@eslint-community/eslint-utils": "npm:^4.9.0" + "@eslint-community/eslint-utils": "npm:^4.9.1" change-case: "npm:^5.4.4" - ci-info: "npm:^4.3.1" + ci-info: "npm:^4.4.0" clean-regexp: "npm:^1.0.0" - core-js-compat: "npm:^3.46.0" + core-js-compat: "npm:^3.49.0" find-up-simple: "npm:^1.0.1" - globals: "npm:^16.4.0" + globals: "npm:^17.4.0" indent-string: "npm:^5.0.0" is-builtin-module: "npm:^5.0.0" jsesc: "npm:^3.1.0" pluralize: "npm:^8.0.0" regexp-tree: "npm:^0.1.27" regjsparser: "npm:^0.13.0" - semver: "npm:^7.7.3" + semver: "npm:^7.7.4" strip-indent: "npm:^4.1.1" peerDependencies: eslint: ">=9.38.0" - checksum: 10/bfcaf383e8e244c13311900d4e152b1a4134f844ddc8514d86aca7da932a4663b144fceca7a32a796faaf53a84a203dcd3052ef846c05990dd285c19ed6c9f17 + checksum: 10/3211dadefe8ec43526372a302e48503da42f5e1d3b45d8e20bc29e30dd142b442d70d22ea8617a4ca5494b184b36656d0e81c1e299d12a8e991ac1a86ed35e42 languageName: node linkType: hard @@ -5501,7 +5516,7 @@ __metadata: languageName: node linkType: hard -"globals@npm:17.4.0": +"globals@npm:17.4.0, globals@npm:^17.4.0": version: 17.4.0 resolution: "globals@npm:17.4.0" checksum: 10/ffad244617e94efcb3da72b7beefc941167c21316148ce378f322db7af72db06468f370e23224b3c7b17b5173a7c75b134e5e7b0949f2828519054a76892508d @@ -5515,13 +5530,6 @@ __metadata: languageName: node linkType: hard -"globals@npm:^16.4.0": - version: 16.5.0 - resolution: "globals@npm:16.5.0" - checksum: 10/f9e8a2a13f50222c127030a619e283e7bbfe32966316bdde0715af1d15a7e40cb9c24ff52cad59671f97762ed8b515353c2f8674f560c63d9385f19ee26735a6 - languageName: node - linkType: hard - "globrex@npm:^0.1.2": version: 0.1.2 resolution: "globrex@npm:0.1.2" @@ -7849,10 +7857,10 @@ __metadata: languageName: node linkType: hard -"node-releases@npm:^2.0.27": - version: 2.0.27 - resolution: "node-releases@npm:2.0.27" - checksum: 10/f6c78ddb392ae500719644afcbe68a9ea533242c02312eb6a34e8478506eb7482a3fb709c70235b01c32fe65625b68dfa9665113f816d87f163bc3819b62b106 +"node-releases@npm:^2.0.27, node-releases@npm:^2.0.36": + version: 2.0.37 + resolution: "node-releases@npm:2.0.37" + checksum: 10/c4b376a7cd15cd6a0ed93a65a51ca865a07282b583ede0b42233cec60351faafb5a5d2afe652e916b53fd34b1e97ea5444fa6ce77b06f289a9622d159d6ac9e7 languageName: node linkType: hard @@ -8636,8 +8644,8 @@ __metadata: eslint-plugin-jest: "npm:29.15.0" eslint-plugin-n: "npm:17.24.0" eslint-plugin-regexp: "npm:3.0.0" - eslint-plugin-simple-import-sort: "npm:12.1.1" - eslint-plugin-unicorn: "npm:63.0.0" + eslint-plugin-simple-import-sort: "npm:13.0.0" + eslint-plugin-unicorn: "npm:64.0.0" esm-utils: "npm:4.4.2" espree: "npm:11.2.0" fast-glob: "npm:3.3.3" @@ -10233,7 +10241,7 @@ __metadata: languageName: node linkType: hard -"update-browserslist-db@npm:^1.2.0": +"update-browserslist-db@npm:^1.2.0, update-browserslist-db@npm:^1.2.3": version: 1.2.3 resolution: "update-browserslist-db@npm:1.2.3" dependencies: