From 521de3bf4d585b5bff731c3de3e606862e037407 Mon Sep 17 00:00:00 2001 From: fisker Cheung Date: Mon, 12 Dec 2022 17:26:29 +0800 Subject: [PATCH 1/6] Don't run scheduled workflows in forks (#13981) --- .github/workflows/bundler-friendly.yml | 2 ++ .github/workflows/dev-package-test.yml | 1 + .github/workflows/lock.yml | 1 + .github/workflows/no-response.yml | 5 +++-- 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/bundler-friendly.yml b/.github/workflows/bundler-friendly.yml index c7d98ac40..b9bd035a8 100644 --- a/.github/workflows/bundler-friendly.yml +++ b/.github/workflows/bundler-friendly.yml @@ -12,6 +12,7 @@ on: jobs: build: + if: github.event_name != 'schedule' || github.repository == 'prettier/prettier' name: Build runs-on: ubuntu-latest steps: @@ -36,6 +37,7 @@ jobs: path: dist webpack: + if: github.event_name != 'schedule' || github.repository == 'prettier/prettier' name: Bundle Prettier with webpack runs-on: ubuntu-latest needs: [build] diff --git a/.github/workflows/dev-package-test.yml b/.github/workflows/dev-package-test.yml index cf44ac4fd..6bfe936af 100644 --- a/.github/workflows/dev-package-test.yml +++ b/.github/workflows/dev-package-test.yml @@ -14,6 +14,7 @@ on: jobs: test: + if: github.event_name != 'schedule' || github.repository == 'prettier/prettier' timeout-minutes: 60 strategy: fail-fast: false diff --git a/.github/workflows/lock.yml b/.github/workflows/lock.yml index 68524e76e..7c37a1a5a 100644 --- a/.github/workflows/lock.yml +++ b/.github/workflows/lock.yml @@ -7,6 +7,7 @@ on: jobs: lock: + if: github.event_name != 'schedule' || github.repository == 'prettier/prettier' runs-on: ubuntu-latest steps: - uses: dessant/lock-threads@v3 diff --git a/.github/workflows/no-response.yml b/.github/workflows/no-response.yml index 5981ff4b7..e2ce85eac 100644 --- a/.github/workflows/no-response.yml +++ b/.github/workflows/no-response.yml @@ -7,14 +7,15 @@ on: types: - created schedule: - # “At minute 0.” https://crontab.guru/#0_*_*_*_* - - cron: "0 * * * *" + # “At 00:00.” https://crontab.guru/#0_0_*_*_* + - cron: "0 0 * * *" permissions: issues: write jobs: no-response: + if: github.event_name != 'schedule' || github.repository == 'prettier/prettier' runs-on: ubuntu-latest steps: - uses: lee-dohm/no-response@v0.5.0 From df1f6ad1acd55600f0d711e42026f5ab3766e8a7 Mon Sep 17 00:00:00 2001 From: David De Sloovere Date: Thu, 15 Dec 2022 07:50:24 +0100 Subject: [PATCH 2/6] Update Husky.Net info (#13883) Co-authored-by: fisker Cheung --- docs/precommit.md | 3 ++- website/versioned_docs/version-stable/precommit.md | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/precommit.md b/docs/precommit.md index bacd0d286..b093dad18 100644 --- a/docs/precommit.md +++ b/docs/precommit.md @@ -66,9 +66,10 @@ Read more at [mirror of prettier package for pre-commit](https://github.com/pre- **Use Case:** A dotnet solution to use Prettier along with other code quality tools (e.g. dotnet-format, ESLint, Stylelint, etc.). It supports multiple file states (staged - last-commit, git-files etc.) ```bash +dotnet new tool-manifest dotnet tool install husky dotnet husky install -dotnet husky add .husky/pre-commit +dotnet husky add pre-commit ``` after installation you can add prettier task to the `task-runner.json`. diff --git a/website/versioned_docs/version-stable/precommit.md b/website/versioned_docs/version-stable/precommit.md index 06ca39090..ef04f80c0 100644 --- a/website/versioned_docs/version-stable/precommit.md +++ b/website/versioned_docs/version-stable/precommit.md @@ -67,9 +67,10 @@ Read more at [mirror of prettier package for pre-commit](https://github.com/pre- **Use Case:** A dotnet solution to use Prettier along with other code quality tools (e.g. dotnet-format, ESLint, Stylelint, etc.). It supports multiple file states (staged - last-commit, git-files etc.) ```bash +dotnet new tool-manifest dotnet tool install husky dotnet husky install -dotnet husky add .husky/pre-commit +dotnet husky add pre-commit ``` after installation you can add prettier task to the `task-runner.json`. From 40d0f27055092ff189b4044dabcf720617118936 Mon Sep 17 00:00:00 2001 From: "James C. Davis" Date: Thu, 15 Dec 2022 01:50:51 -0500 Subject: [PATCH 3/6] [handlebars] allow custom "else if"-like with block params (#13930) --- changelog_unreleased/handlebars/13930.md | 42 ++++++++++++++++ src/language-handlebars/printer-glimmer.js | 24 +++++++--- .../__snapshots__/jsfmt.spec.js.snap | 48 +++++++++++++++++++ .../block-statement/custom-else.hbs | 20 ++++++++ 4 files changed, 128 insertions(+), 6 deletions(-) create mode 100644 changelog_unreleased/handlebars/13930.md diff --git a/changelog_unreleased/handlebars/13930.md b/changelog_unreleased/handlebars/13930.md new file mode 100644 index 000000000..6e824a32e --- /dev/null +++ b/changelog_unreleased/handlebars/13930.md @@ -0,0 +1,42 @@ +#### Allow custom "else if"-like blocks with block params (#13930 by @jamescdavis) + +#13507 added support for custom block keywords used with `else`, but failed to allow block params. This updates printer-glimmer to allow block params with custom "else if"-like blocks. + + +```hbs +{{! Input }} +{#when isAtWork as |work|}} + Ship that + {{work}}! +{{else when isReading as |book|}} + You can finish + {{book}} + eventually... +{{else}} + Go to bed! +{{/when}} + +{{! Prettier stable }} +{{#when isAtWork as |work|}} + Ship that + {{work}}! +{{else when isReading}} + You can finish + {{book}} + eventually... +{{else}} + Go to bed! +{{/when}} + +{{! Prettier main }} +{#when isAtWork as |work|}} + Ship that + {{work}}! +{{else when isReading as |book|}} + You can finish + {{book}} + eventually... +{{else}} + Go to bed! +{{/when}} +``` diff --git a/src/language-handlebars/printer-glimmer.js b/src/language-handlebars/printer-glimmer.js index 12c6b52d6..19249ff52 100644 --- a/src/language-handlebars/printer-glimmer.js +++ b/src/language-handlebars/printer-glimmer.js @@ -563,16 +563,28 @@ function printElseBlock(node, options) { } function printElseIfLikeBlock(path, print, ifLikeKeyword) { + const node = path.getValue(); + let blockParams = []; + + if (isNonEmptyArray(node.program.blockParams)) { + blockParams = [line, printBlockParams(node.program)]; + } + const parentNode = path.getParentNode(1); - return [ + return group([ printInverseBlockOpeningMustache(parentNode), - "else ", - ifLikeKeyword, - " ", - printParams(path, print), + indent( + group([ + group(["else", line, ifLikeKeyword]), + line, + printParams(path, print), + ]) + ), + indent(blockParams), + softline, printInverseBlockClosingMustache(parentNode), - ]; + ]); } function printCloseBlock(path, print, options) { diff --git a/tests/format/handlebars/block-statement/__snapshots__/jsfmt.spec.js.snap b/tests/format/handlebars/block-statement/__snapshots__/jsfmt.spec.js.snap index c9e5f6155..8894daaed 100644 --- a/tests/format/handlebars/block-statement/__snapshots__/jsfmt.spec.js.snap +++ b/tests/format/handlebars/block-statement/__snapshots__/jsfmt.spec.js.snap @@ -274,6 +274,26 @@ printWidth: 80 Another thing {{~/when~}} +{{#when a as |b|}} + {{b}} +{{else when c as |d|}} + {{d}} +{{else when e as |f|}} + {{f}} +{{else when g as |h|}} + {{h}} +{{else}} + j +{{/when}} + +{{#when abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrst as |b|}} + {{b}} +{{else when abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnop as |d|}} + {{d}} +{{else when abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz as |f|}} + {{f}} +{{/when}} + =====================================output=====================================

{{#when isAtWork}} @@ -381,6 +401,34 @@ printWidth: 80 {{~else when anotherCondition~}} Another thing {{~/when~}} + +{{#when a as |b|}} + {{b}} +{{else when c as |d|}} + {{d}} +{{else when e as |f|}} + {{f}} +{{else when g as |h|}} + {{h}} +{{else}} + j +{{/when}} + +{{#when + abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrst + as |b| +}} + {{b}} +{{else when abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnop + as |d| +}} + {{d}} +{{else when + abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz + as |f| +}} + {{f}} +{{/when}} ================================================================================ `; diff --git a/tests/format/handlebars/block-statement/custom-else.hbs b/tests/format/handlebars/block-statement/custom-else.hbs index 156d61268..72580285e 100644 --- a/tests/format/handlebars/block-statement/custom-else.hbs +++ b/tests/format/handlebars/block-statement/custom-else.hbs @@ -106,3 +106,23 @@ {{~else when anotherCondition~}} Another thing {{~/when~}} + +{{#when a as |b|}} + {{b}} +{{else when c as |d|}} + {{d}} +{{else when e as |f|}} + {{f}} +{{else when g as |h|}} + {{h}} +{{else}} + j +{{/when}} + +{{#when abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrst as |b|}} + {{b}} +{{else when abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnop as |d|}} + {{d}} +{{else when abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz as |f|}} + {{f}} +{{/when}} From 44db370ca612564e272a2a33e41863055c26c0e9 Mon Sep 17 00:00:00 2001 From: Derek Lewis Date: Thu, 15 Dec 2022 01:51:19 -0500 Subject: [PATCH 4/6] Don't lowercase Markdown link definition labels (#13155) Co-authored-by: fisker Cheung --- changelog_unreleased/markdown/13155.md | 20 +++ package.json | 1 + src/language-markdown/clean.js | 12 +- src/language-markdown/printer-markdown.js | 27 +++-- .../__snapshots__/jsfmt.spec.js.snap | 114 ++++++++++++++++++ .../case-and-space/case-and-space.md | 19 +++ .../case-and-space/issue-3835.md | 1 + .../case-and-space/issue-7118.md | 18 +++ .../case-and-space/jsfmt.spec.js | 1 + .../spec/__snapshots__/jsfmt.spec.js.snap | 22 ++-- yarn.lock | 2 +- 11 files changed, 211 insertions(+), 26 deletions(-) create mode 100644 changelog_unreleased/markdown/13155.md create mode 100644 tests/format/markdown/linkReference/case-and-space/__snapshots__/jsfmt.spec.js.snap create mode 100644 tests/format/markdown/linkReference/case-and-space/case-and-space.md create mode 100644 tests/format/markdown/linkReference/case-and-space/issue-3835.md create mode 100644 tests/format/markdown/linkReference/case-and-space/issue-7118.md create mode 100644 tests/format/markdown/linkReference/case-and-space/jsfmt.spec.js diff --git a/changelog_unreleased/markdown/13155.md b/changelog_unreleased/markdown/13155.md new file mode 100644 index 000000000..ca3b25123 --- /dev/null +++ b/changelog_unreleased/markdown/13155.md @@ -0,0 +1,20 @@ +#### Don't lowercase link references (#13155 by @DerekNonGeneric & @fisker) + + +```markdown + +We now don't strictly follow the release notes format suggested by [Keep a Changelog]. + +[Keep a Changelog]: https://example.com/ + + +We now don't strictly follow the release notes format suggested by [Keep a Changelog]. + +[keep a changelog]: https://example.com/ + + + + +``` diff --git a/package.json b/package.json index c81c9e64a..d87d6b497 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,7 @@ "chalk": "5.0.1", "ci-info": "3.3.0", "cjk-regex": "2.0.1", + "collapse-white-space": "1.0.6", "cosmiconfig": "7.0.1", "css-units-list": "1.1.0", "dashify": "2.0.0", diff --git a/src/language-markdown/clean.js b/src/language-markdown/clean.js index 60c3c7caa..29eac8a2b 100644 --- a/src/language-markdown/clean.js +++ b/src/language-markdown/clean.js @@ -1,5 +1,6 @@ "use strict"; +const collapseWhiteSpace = require("collapse-white-space"); const { isFrontMatterNode } = require("../common/util.js"); const { startWithPragma } = require("./pragma.js"); @@ -42,11 +43,12 @@ function clean(ast, newObj, parent) { newObj.value = ast.value.trim().replace(/[\t\n]+/g, " "); } - if (ast.type === "definition" || ast.type === "linkReference") { - newObj.label = ast.label - .trim() - .replace(/[\t\n ]+/g, " ") - .toLowerCase(); + if ( + ast.type === "definition" || + ast.type === "linkReference" || + ast.type === "imageReference" + ) { + newObj.label = collapseWhiteSpace(ast.label); } if ( diff --git a/src/language-markdown/printer-markdown.js b/src/language-markdown/printer-markdown.js index 6bc1918d9..f1c661368 100644 --- a/src/language-markdown/printer-markdown.js +++ b/src/language-markdown/printer-markdown.js @@ -1,5 +1,6 @@ "use strict"; +const collapseWhiteSpace = require("collapse-white-space"); const { getLast, getMinNotPresentContinuousCount, @@ -352,7 +353,7 @@ function genericPrint(path, options, print) { printChildren(path, options, print), "]", node.referenceType === "full" - ? ["[", node.identifier, "]"] + ? printLinkReference(node) : node.referenceType === "collapsed" ? "[]" : "", @@ -360,7 +361,7 @@ function genericPrint(path, options, print) { case "imageReference": switch (node.referenceType) { case "full": - return ["![", node.alt || "", "][", node.identifier, "]"]; + return ["![", node.alt || "", "]", printLinkReference(node)]; default: return [ "![", @@ -372,9 +373,8 @@ function genericPrint(path, options, print) { case "definition": { const lineOrSpace = options.proseWrap === "always" ? line : " "; return group([ - "[", - node.identifier, - "]:", + printLinkReference(node), + ":", indent([ lineOrSpace, printUrl(node.url), @@ -390,7 +390,7 @@ function genericPrint(path, options, print) { case "footnote": return ["[^", printChildren(path, options, print), "]"]; case "footnoteReference": - return ["[^", node.identifier, "]"]; + return printFootnoteReference(node); case "footnoteDefinition": { const nextNode = path.getParentNode().children[path.getName() + 1]; const shouldInlineFootnote = @@ -401,9 +401,8 @@ function genericPrint(path, options, print) { node.children[0].position.start.line === node.children[0].position.end.line)); return [ - "[^", - node.identifier, - "]: ", + printFootnoteReference(node), + ": ", shouldInlineFootnote ? printChildren(path, options, print) : group([ @@ -928,6 +927,16 @@ function hasPrettierIgnore(path) { return isPrettierIgnore(prevNode) === "next"; } +// `remark-parse` lowercase the `label` as `identifier`, we don't want do that +// https://github.com/remarkjs/remark/blob/daddcb463af2d5b2115496c395d0571c0ff87d15/packages/remark-parse/lib/tokenize/reference.js +function printLinkReference(node) { + return `[${collapseWhiteSpace(node.label)}]`; +} + +function printFootnoteReference(node) { + return `[^${node.label}]`; +} + module.exports = { preprocess, print: genericPrint, diff --git a/tests/format/markdown/linkReference/case-and-space/__snapshots__/jsfmt.spec.js.snap b/tests/format/markdown/linkReference/case-and-space/__snapshots__/jsfmt.spec.js.snap new file mode 100644 index 000000000..2a9d689f2 --- /dev/null +++ b/tests/format/markdown/linkReference/case-and-space/__snapshots__/jsfmt.spec.js.snap @@ -0,0 +1,114 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`case-and-space.md format 1`] = ` +====================================options===================================== +parsers: ["markdown"] +printWidth: 80 + | printWidth +=====================================input====================================== +# \`linkReference\` + +[ See \`AsyncGeneratorFunction\` ][ See \`AsyncGeneratorFunction\` ] + +# \`imageReference\` + +![ See \`AsyncGeneratorFunction\` ][ See \`AsyncGeneratorFunction\` ] + +# \`definition\` + +[ See \`AsyncGeneratorFunction\` ]: ./index.html + +# \`footnoteReference\` + +[^See\`AsyncGeneratorFunction\`] + +# \`footnoteDefinition\` + +[^See\`AsyncGeneratorFunction\`]: ./index.html + +=====================================output===================================== +# \`linkReference\` + +[ See \`AsyncGeneratorFunction\` ][ See \`AsyncGeneratorFunction\` ] + +# \`imageReference\` + +![ See \`AsyncGeneratorFunction\` ][ See \`AsyncGeneratorFunction\` ] + +# \`definition\` + +[ See \`AsyncGeneratorFunction\` ]: ./index.html + +# \`footnoteReference\` + +[^See\`AsyncGeneratorFunction\`] + +# \`footnoteDefinition\` + +[^See\`AsyncGeneratorFunction\`]: ./index.html + +================================================================================ +`; + +exports[`issue-3835.md format 1`] = ` +====================================options===================================== +parsers: ["markdown"] +printWidth: 80 + | printWidth +=====================================input====================================== +[1][Test Text](http://example.com) + +=====================================output===================================== +[1][Test Text](http://example.com) + +================================================================================ +`; + +exports[`issue-7118.md format 1`] = ` +====================================options===================================== +parsers: ["markdown"] +printWidth: 80 + | printWidth +=====================================input====================================== +- see[Link to Foo][master-LinkToFoo] + +[master-LinkToFoo]: http://foo.com + +Bla bla [PascalCase][] bla. + +[PascalCase]: ./PascalCase.md + +## [Unreleased] +… +[Unreleased]: https://github.com/username/project/compare/v1.0.0...HEAD + +[darktable]: https://www.darktable.org/ +[js;dr]: https://indieweb.org/js;dr +[LinuxFest Northwest]: https://www.linuxfestnorthwest.org/ +[OpenStreetMap]: https://www.openstreetmap.org/about +[SeaGL]: https://seagl.org/ +[uBlock Origin]: https://github.com/gorhill/uBlock + +=====================================output===================================== +- see[Link to Foo][master-LinkToFoo] + +[master-LinkToFoo]: http://foo.com + +Bla bla [PascalCase][] bla. + +[PascalCase]: ./PascalCase.md + +## [Unreleased] + +… +[Unreleased]: https://github.com/username/project/compare/v1.0.0...HEAD + +[darktable]: https://www.darktable.org/ +[js;dr]: https://indieweb.org/js;dr +[LinuxFest Northwest]: https://www.linuxfestnorthwest.org/ +[OpenStreetMap]: https://www.openstreetmap.org/about +[SeaGL]: https://seagl.org/ +[uBlock Origin]: https://github.com/gorhill/uBlock + +================================================================================ +`; diff --git a/tests/format/markdown/linkReference/case-and-space/case-and-space.md b/tests/format/markdown/linkReference/case-and-space/case-and-space.md new file mode 100644 index 000000000..f849494fd --- /dev/null +++ b/tests/format/markdown/linkReference/case-and-space/case-and-space.md @@ -0,0 +1,19 @@ +# `linkReference` + +[ See `AsyncGeneratorFunction` ][ See `AsyncGeneratorFunction` ] + +# `imageReference` + +![ See `AsyncGeneratorFunction` ][ See `AsyncGeneratorFunction` ] + +# `definition` + +[ See `AsyncGeneratorFunction` ]: ./index.html + +# `footnoteReference` + +[^See`AsyncGeneratorFunction`] + +# `footnoteDefinition` + +[^See`AsyncGeneratorFunction`]: ./index.html diff --git a/tests/format/markdown/linkReference/case-and-space/issue-3835.md b/tests/format/markdown/linkReference/case-and-space/issue-3835.md new file mode 100644 index 000000000..b8d5aa7e4 --- /dev/null +++ b/tests/format/markdown/linkReference/case-and-space/issue-3835.md @@ -0,0 +1 @@ +[1][Test Text](http://example.com) diff --git a/tests/format/markdown/linkReference/case-and-space/issue-7118.md b/tests/format/markdown/linkReference/case-and-space/issue-7118.md new file mode 100644 index 000000000..9507886e2 --- /dev/null +++ b/tests/format/markdown/linkReference/case-and-space/issue-7118.md @@ -0,0 +1,18 @@ +- see[Link to Foo][master-LinkToFoo] + +[master-LinkToFoo]: http://foo.com + +Bla bla [PascalCase][] bla. + +[PascalCase]: ./PascalCase.md + +## [Unreleased] +… +[Unreleased]: https://github.com/username/project/compare/v1.0.0...HEAD + +[darktable]: https://www.darktable.org/ +[js;dr]: https://indieweb.org/js;dr +[LinuxFest Northwest]: https://www.linuxfestnorthwest.org/ +[OpenStreetMap]: https://www.openstreetmap.org/about +[SeaGL]: https://seagl.org/ +[uBlock Origin]: https://github.com/gorhill/uBlock diff --git a/tests/format/markdown/linkReference/case-and-space/jsfmt.spec.js b/tests/format/markdown/linkReference/case-and-space/jsfmt.spec.js new file mode 100644 index 000000000..ff3b58b03 --- /dev/null +++ b/tests/format/markdown/linkReference/case-and-space/jsfmt.spec.js @@ -0,0 +1 @@ +run_spec(__dirname, ["markdown"]); diff --git a/tests/format/markdown/spec/__snapshots__/jsfmt.spec.js.snap b/tests/format/markdown/spec/__snapshots__/jsfmt.spec.js.snap index 4be0bcab9..cb8e1af7e 100644 --- a/tests/format/markdown/spec/__snapshots__/jsfmt.spec.js.snap +++ b/tests/format/markdown/spec/__snapshots__/jsfmt.spec.js.snap @@ -3074,7 +3074,7 @@ proseWrap: "always" [Foo*bar\\]] =====================================output===================================== -[foo*bar\\]]: my_(url) "title (with parens)" +[Foo*bar\\]]: my_(url) "title (with parens)" [Foo*bar\\]] @@ -3095,7 +3095,7 @@ proseWrap: "always" [Foo bar] =====================================output===================================== -[foo bar]: my%20url "title" +[Foo bar]: my%20url "title" [Foo bar] @@ -3235,7 +3235,7 @@ proseWrap: "always" [Foo] =====================================output===================================== -[foo]: /url +[FOO]: /url [Foo] @@ -3254,7 +3254,7 @@ proseWrap: "always" [αγω] =====================================output===================================== -[αγω]: /φου +[ΑΓΩ]: /φου [αγω] @@ -8889,7 +8889,7 @@ proseWrap: "always" [bar]: /url "title" =====================================output===================================== -[foo][bar] +[foo][BaR] [bar]: /url "title" @@ -8908,9 +8908,9 @@ proseWrap: "always" [ТОЛПОЙ]: /url =====================================output===================================== -[Толпой][толпой] is a Russian word. +[Толпой][Толпой] is a Russian word. -[толпой]: /url +[ТОЛПОЙ]: /url ================================================================================ `; @@ -8928,9 +8928,9 @@ proseWrap: "always" [Baz][Foo bar] =====================================output===================================== -[foo bar]: /url +[Foo bar]: /url -[Baz][foo bar] +[Baz][Foo bar] ================================================================================ `; @@ -9558,7 +9558,7 @@ proseWrap: "always" =====================================output===================================== ![foo *bar*][foobar] -[foobar]: train.jpg "train & tracks" +[FOOBAR]: train.jpg "train & tracks" ================================================================================ `; @@ -9656,7 +9656,7 @@ proseWrap: "always" =====================================output===================================== ![foo][bar] -[bar]: /url +[BAR]: /url ================================================================================ `; diff --git a/yarn.lock b/yarn.lock index 4145f37c0..172f1f94f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2295,7 +2295,7 @@ co@^4.6.0: resolved "https://registry.yarnpkg.com/co/-/co-4.6.0.tgz#6ea6bdf3d853ae54ccb8e47bfa0bf3f9031fb184" integrity sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ= -collapse-white-space@^1.0.2: +collapse-white-space@1.0.6, collapse-white-space@^1.0.2: version "1.0.6" resolved "https://registry.yarnpkg.com/collapse-white-space/-/collapse-white-space-1.0.6.tgz#e63629c0016665792060dbbeb79c42239d2c5287" integrity sha512-jEovNnrhMuqyCcjfEJA56v0Xq8SkIoPKDyaHahwo3POf4qcSXqMYuwNcOTzp74vTsR9Tn08z4MxWqAhcekogkQ== From d24d74930e0d038984d0861c57aff3c1323d5fb4 Mon Sep 17 00:00:00 2001 From: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com> Date: Thu, 15 Dec 2022 07:52:09 +0100 Subject: [PATCH 5/6] Rewrite sentence (#13686) Co-authored-by: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com> Co-authored-by: fisker Cheung --- website/pages/en/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/pages/en/index.js b/website/pages/en/index.js index e0d2361eb..0424dfd71 100755 --- a/website/pages/en/index.js +++ b/website/pages/en/index.js @@ -96,7 +96,7 @@ const TldrSection = ({ language }) => (

Why?

    -
  • You press save and code is formatted
  • +
  • Your code is formatted on save
  • No need to discuss style in code review
  • Saves you time and energy
  • From b50dfd1974d33abb980e9b4df949913932eeb478 Mon Sep 17 00:00:00 2001 From: Jeremy Neander Date: Thu, 15 Dec 2022 00:54:47 -0600 Subject: [PATCH 6/6] fix: preserve empty lines between nested SCSS maps (#13931) Co-authored-by: Jeremy Neander Co-authored-by: fisker Cheung --- changelog_unreleased/scss/13931.md | 36 +++++++++++++++++++ src/language-css/printer-postcss.js | 14 +++++--- .../parens/__snapshots__/jsfmt.spec.js.snap | 1 + 3 files changed, 47 insertions(+), 4 deletions(-) create mode 100644 changelog_unreleased/scss/13931.md diff --git a/changelog_unreleased/scss/13931.md b/changelog_unreleased/scss/13931.md new file mode 100644 index 000000000..426d0c712 --- /dev/null +++ b/changelog_unreleased/scss/13931.md @@ -0,0 +1,36 @@ +#### Preserve empty lines between nested SCSS maps (#13931 by @jneander) + + +```scss +/* Input */ +$map: ( + 'one': ( + 'key': 'value', + ), + + 'two': ( + 'key': 'value', + ), +) + +/* Prettier stable */ +$map: ( + 'one': ( + 'key': 'value', + ), + 'two': ( + 'key': 'value', + ), +) + +/* Prettier main */ +$map: ( + 'one': ( + 'key': 'value', + ), + + 'two': ( + 'key': 'value', + ), +) +``` diff --git a/src/language-css/printer-postcss.js b/src/language-css/printer-postcss.js index f8bbd0296..4ba444c8d 100644 --- a/src/language-css/printer-postcss.js +++ b/src/language-css/printer-postcss.js @@ -918,7 +918,8 @@ function genericPrint(path, options, print) { path.map((childPath, index) => { const child = childPath.getValue(); const isLast = index === node.groups.length - 1; - const printed = [print(), isLast ? "" : ","]; + + let printed = [print(), isLast ? "" : ","]; // Key/Value pair in open paren already indented if ( @@ -931,7 +932,7 @@ function genericPrint(path, options, print) { ) { const parts = getDocParts(printed[0].contents.contents); parts[1] = group(parts[1]); - return group(dedent(printed)); + printed = [group(dedent(printed))]; } if ( @@ -939,9 +940,14 @@ function genericPrint(path, options, print) { child.type === "value-comma_group" && isNonEmptyArray(child.groups) ) { - const last = getLast(child.groups); + let last = getLast(child.groups); + + // `value-paren_group` does not have location info, but its closing parenthesis does. + if (!last.source && last.close) { + last = last.close; + } + if ( - // `value-paren_group` missing location info last.source && isNextLineEmpty(options.originalText, last, locEnd) ) { diff --git a/tests/format/scss/parens/__snapshots__/jsfmt.spec.js.snap b/tests/format/scss/parens/__snapshots__/jsfmt.spec.js.snap index 5a8c9e105..d81779337 100644 --- a/tests/format/scss/parens/__snapshots__/jsfmt.spec.js.snap +++ b/tests/format/scss/parens/__snapshots__/jsfmt.spec.js.snap @@ -28,6 +28,7 @@ $icons: ( left: 253, top: 73, ), + /* Should preserve empty lines */ cal-week-group: ( left: 1,