From d5da779cb195443c935fd7171f5e81141e2f62e5 Mon Sep 17 00:00:00 2001 From: Sosuke Suzuki Date: Thu, 3 Sep 2020 02:57:17 +0900 Subject: [PATCH 1/8] GraphQL: Fix formatting for directives in fields (#9116) * Fix formatting for directives in FragmentDefinition * Add changelog * Update src/language-graphql/printer-graphql.js Co-authored-by: Georgii Dolzhykov * Fix by Prettier * Refactor Co-authored-by: Georgii Dolzhykov --- changelog_unreleased/graphql/pr-9116.md | 28 +++++++++++++++++++ src/language-graphql/printer-graphql.js | 8 +++++- .../__snapshots__/jsfmt.spec.js.snap | 10 +++---- .../newline/__snapshots__/jsfmt.spec.js.snap | 14 +++++----- 4 files changed, 47 insertions(+), 13 deletions(-) create mode 100644 changelog_unreleased/graphql/pr-9116.md diff --git a/changelog_unreleased/graphql/pr-9116.md b/changelog_unreleased/graphql/pr-9116.md new file mode 100644 index 000000000..6ccaf6cbf --- /dev/null +++ b/changelog_unreleased/graphql/pr-9116.md @@ -0,0 +1,28 @@ +#### Fix formatting for directives in fields (#9116 by @sosukesuzuki) + + +```graphql +# Input +type Query { + someQuery(id: ID!, someOtherData: String!): String! @deprecated @isAuthenticated + versions: Versions! +} + + +# Prettier stable +type Query { + someQuery(id: ID!, someOtherData: String!): String! + @deprecated + @isAuthenticated + versions: Versions! +} + +# Prettier master +type Query { + someQuery(id: ID!, someOtherData: String!): String! + @deprecated + @isAuthenticated + versions: Versions! +} + +``` diff --git a/src/language-graphql/printer-graphql.js b/src/language-graphql/printer-graphql.js index 637a4f262..5320a063a 100644 --- a/src/language-graphql/printer-graphql.js +++ b/src/language-graphql/printer-graphql.js @@ -611,7 +611,13 @@ function printDirectives(path, print, n) { return ""; } - return group(concat([line, join(line, path.map(print, "directives"))])); + const printed = join(line, path.map(print, "directives")); + + if (n.kind === "FragmentDefinition" || n.kind === "OperationDefinition") { + return group(concat([line, printed])); + } + + return concat([" ", group(indent(concat([softline, printed])))]); } function printSequence(sequencePath, options, print) { diff --git a/tests/graphql/directives/__snapshots__/jsfmt.spec.js.snap b/tests/graphql/directives/__snapshots__/jsfmt.spec.js.snap index c943173bf..119499302 100644 --- a/tests/graphql/directives/__snapshots__/jsfmt.spec.js.snap +++ b/tests/graphql/directives/__snapshots__/jsfmt.spec.js.snap @@ -32,7 +32,7 @@ query MyQuery @directive(arg: 5) { field @skip(if: true) @nope otherField ...fragmentSpread - @include(if: ["this isn't even a boolean", "wow, that's really odd"]) + @include(if: ["this isn't even a boolean", "wow, that's really odd"]) } fragment YouCanHaveDirectivesHereToo on SomeType @yesReally(what: "yes") { @@ -45,10 +45,10 @@ fragment YouCanHaveDirectivesHereToo on SomeType @yesReally(what: "yes") { } thisFieldHasALotOfDirectives - @thisIsthefirst - @thisIsTheSecond - @thisIsTheThird - @thisIstheFourthWillBeTooLongForSure(and: "it has arguments as well") + @thisIsthefirst + @thisIsTheSecond + @thisIsTheThird + @thisIstheFourthWillBeTooLongForSure(and: "it has arguments as well") } query QueryWVars($x: String) @directive { diff --git a/tests/graphql/newline/__snapshots__/jsfmt.spec.js.snap b/tests/graphql/newline/__snapshots__/jsfmt.spec.js.snap index 7af04e274..70320b53d 100644 --- a/tests/graphql/newline/__snapshots__/jsfmt.spec.js.snap +++ b/tests/graphql/newline/__snapshots__/jsfmt.spec.js.snap @@ -63,16 +63,16 @@ query MyQuery arg2: 10 ) { field - @skip( - if: true + @skip( + if: true - # comment - cursor: 10 - ) - @nope + # comment + cursor: 10 + ) + @nope otherField ...fragmentSpread - @include(if: ["this isn't even a boolean", "wow, that's really odd"]) + @include(if: ["this isn't even a boolean", "wow, that's really odd"]) } ================================================================================ From ab9474eacc9c883e588ef2500c6230057328ade5 Mon Sep 17 00:00:00 2001 From: Sosuke Suzuki Date: Fri, 4 Sep 2020 13:12:58 +0900 Subject: [PATCH 2/8] Fix line breaks for CSS in JS (#9136) * Fix 2.1 regression for css-in-js * Add changelog --- changelog_unreleased/javascript/pr-9136.md | 46 +++++++++++++++++++ src/document/doc-utils.js | 15 ++++++ src/language-js/embed.js | 4 +- src/language-markdown/embed.js | 16 +------ .../__snapshots__/jsfmt.spec.js.snap | 26 +++++++++++ tests/js/multiparser-css/styled-components.js | 13 ++++++ 6 files changed, 104 insertions(+), 16 deletions(-) create mode 100644 changelog_unreleased/javascript/pr-9136.md diff --git a/changelog_unreleased/javascript/pr-9136.md b/changelog_unreleased/javascript/pr-9136.md new file mode 100644 index 000000000..62f8518f4 --- /dev/null +++ b/changelog_unreleased/javascript/pr-9136.md @@ -0,0 +1,46 @@ +#### Fix line breaks for CSS in JS (#9136 by @sosukesuzuki) + + +```js +// Input +styled.div` + // prettier-ignore + @media (aaaaaaaaaaaaa) { + z-index: ${(props) => (props.isComplete ? '1' : '0')}; + } +`; +styled.div` + ${props => getSize(props.$size.xs)} + ${props => getSize(props.$size.sm, 'sm')} + ${props => getSize(props.$size.md, 'md')} +`; + +// Prettier stable +styled.div` + // prettier-ignore + @media (aaaaaaaaaaaaa) { + z-index: ${(props) => + props.isComplete ? "1" : "0"}; + } +`; +styled.div` + ${(props) => getSize(props.$size.xs)} + ${(props) => getSize(props.$size.sm, "sm")} + ${(props) => + getSize(props.$size.md, "md")} +`; + +// Prettier master +styled.div` + // prettier-ignore + @media (aaaaaaaaaaaaa) { + z-index: ${(props) => (props.isComplete ? "1" : "0")}; + } +`; +styled.div` + ${(props) => getSize(props.$size.xs)} + ${(props) => getSize(props.$size.sm, "sm")} + ${(props) => getSize(props.$size.md, "md")} +`; + +``` diff --git a/src/document/doc-utils.js b/src/document/doc-utils.js index e31adbbca..d9fe00900 100644 --- a/src/document/doc-utils.js +++ b/src/document/doc-utils.js @@ -1,5 +1,7 @@ "use strict"; +const { literalline, concat } = require("./doc-builders"); + // Using a unique object to compare by reference. const traverseDocOnExitStackMarker = {}; @@ -258,6 +260,18 @@ function normalizeDoc(doc) { }); } +function replaceNewlinesWithLiterallines(doc) { + return mapDoc(doc, (currentDoc) => + typeof currentDoc === "string" && currentDoc.includes("\n") + ? concat( + currentDoc + .split(/(\n)/g) + .map((v, i) => (i % 2 === 0 ? v : literalline)) + ) + : currentDoc + ); +} + module.exports = { isEmpty, willBreak, @@ -270,4 +284,5 @@ module.exports = { stripTrailingHardline, normalizeParts, normalizeDoc, + replaceNewlinesWithLiterallines, }; diff --git a/src/language-js/embed.js b/src/language-js/embed.js index 64ce711f4..1bf4ce926 100644 --- a/src/language-js/embed.js +++ b/src/language-js/embed.js @@ -12,7 +12,7 @@ const { group, dedentToRoot, }, - utils: { mapDoc }, + utils: { mapDoc, replaceNewlinesWithLiterallines }, } = require("../document"); const { isBlockComment, hasLeadingComment } = require("./comments"); @@ -301,7 +301,7 @@ function replacePlaceholders(quasisDoc, expressionDocs) { part.split(/@prettier-placeholder-(\d+)-id/).forEach((component, idx) => { // The placeholder is always at odd indices if (idx % 2 === 0) { - replacedParts.push(component); + replacedParts.push(replaceNewlinesWithLiterallines(component)); return; } diff --git a/src/language-markdown/embed.js b/src/language-markdown/embed.js index c5e7d10ef..199aa2326 100644 --- a/src/language-markdown/embed.js +++ b/src/language-markdown/embed.js @@ -2,8 +2,8 @@ const { getParserName, getMaxContinuousCount } = require("../common/util"); const { - builders: { hardline, literalline, concat, markAsRoot }, - utils: { mapDoc }, + builders: { hardline, concat, markAsRoot }, + utils: { replaceNewlinesWithLiterallines }, } = require("../document"); const { print: printFrontMatter } = require("../utils/front-matter"); const { getFencedCodeBlockValue } = require("./utils"); @@ -66,18 +66,6 @@ function embed(path, print, textToDoc, options) { } return null; - - function replaceNewlinesWithLiterallines(doc) { - return mapDoc(doc, (currentDoc) => - typeof currentDoc === "string" && currentDoc.includes("\n") - ? concat( - currentDoc - .split(/(\n)/g) - .map((v, i) => (i % 2 === 0 ? v : literalline)) - ) - : currentDoc - ); - } } module.exports = embed; diff --git a/tests/js/multiparser-css/__snapshots__/jsfmt.spec.js.snap b/tests/js/multiparser-css/__snapshots__/jsfmt.spec.js.snap index ec8e35c05..9a895a283 100644 --- a/tests/js/multiparser-css/__snapshots__/jsfmt.spec.js.snap +++ b/tests/js/multiparser-css/__snapshots__/jsfmt.spec.js.snap @@ -535,6 +535,19 @@ const Foo = styled.p\` } \`; +styled(A)\` + // prettier-ignore + @media (aaaaaaaaaaaaa) { + z-index: \${(props) => (props.isComplete ? '1' : '0')}; + } +\`; + +const StyledDiv = styled.div\` + \${props => getSize(props.$size.xs)} + \${props => getSize(props.$size.sm, 'sm')} + \${props => getSize(props.$size.md, 'md')} +\`; + =====================================output===================================== const ListItem1 = styled.li\`\`; @@ -788,6 +801,19 @@ const Foo = styled.p\` } \`; +styled(A)\` + // prettier-ignore + @media (aaaaaaaaaaaaa) { + z-index: \${(props) => (props.isComplete ? "1" : "0")}; + } +\`; + +const StyledDiv = styled.div\` + \${(props) => getSize(props.$size.xs)} + \${(props) => getSize(props.$size.sm, "sm")} + \${(props) => getSize(props.$size.md, "md")} +\`; + ================================================================================ `; diff --git a/tests/js/multiparser-css/styled-components.js b/tests/js/multiparser-css/styled-components.js index e9d5bc387..ceff80287 100644 --- a/tests/js/multiparser-css/styled-components.js +++ b/tests/js/multiparser-css/styled-components.js @@ -246,3 +246,16 @@ const Foo = styled.p` margin-top: 3rem; } `; + +styled(A)` + // prettier-ignore + @media (aaaaaaaaaaaaa) { + z-index: ${(props) => (props.isComplete ? '1' : '0')}; + } +`; + +const StyledDiv = styled.div` + ${props => getSize(props.$size.xs)} + ${props => getSize(props.$size.sm, 'sm')} + ${props => getSize(props.$size.md, 'md')} +`; From ec1b4193079a625633dd0dc86f9a9217a3ad9d7e Mon Sep 17 00:00:00 2001 From: Sosuke Suzuki Date: Mon, 7 Sep 2020 20:10:05 +0900 Subject: [PATCH 3/8] YAML: Fix printing doubles a blank line before a comment (#9143) * Print hardline for endComments only when under mappingValue * Add changelog * Fix from linter * Update tests * Use shouldPrintEndCommentsWithAlign * Add tests * Add test * Fix format * Update test * Test map too * Update tests * `shouldPrintEndCommentsWithAlign` -> `shouldPrintEndComments` Co-authored-by: fisker --- changelog_unreleased/yaml/pr-9143.md | 27 +++ src/language-yaml/printer-yaml.js | 14 +- .../comment/__snapshots__/jsfmt.spec.js.snap | 202 ++++++++++++++++++ tests/yaml/comment/issue-9130.yml | 13 ++ tests/yaml/comment/map-4.yml | 28 +++ tests/yaml/comment/sequence-2.yml | 28 +++ tests/yaml/comment/sequence.yml | 13 ++ 7 files changed, 322 insertions(+), 3 deletions(-) create mode 100644 changelog_unreleased/yaml/pr-9143.md create mode 100644 tests/yaml/comment/issue-9130.yml create mode 100644 tests/yaml/comment/map-4.yml create mode 100644 tests/yaml/comment/sequence-2.yml create mode 100644 tests/yaml/comment/sequence.yml diff --git a/changelog_unreleased/yaml/pr-9143.md b/changelog_unreleased/yaml/pr-9143.md new file mode 100644 index 000000000..9ddb64472 --- /dev/null +++ b/changelog_unreleased/yaml/pr-9143.md @@ -0,0 +1,27 @@ +#### Fix printing doubles a blank line before a comment (#9143 by @sosukesuzuki) + + +```yaml +# Input +- foo: 0 + bar: 1 + + # baz: 2 +- quux: 3 + +# Prettier stable +- foo: 0 + bar: 1 + + + # baz: 2 +- quux: 3 + +# Prettier master +- foo: 0 + bar: 1 + + # baz: 2 +- quux: 3 + +``` diff --git a/src/language-yaml/printer-yaml.js b/src/language-yaml/printer-yaml.js index 42a51a471..460bd0d3d 100644 --- a/src/language-yaml/printer-yaml.js +++ b/src/language-yaml/printer-yaml.js @@ -127,8 +127,7 @@ function genericPrint(path, options, print) { ]) ) : "", - nextEmptyLine, - hasEndComments(node) && !isNode(node, ["documentHead", "documentBody"]) + shouldPrintEndComments(node) ? align( node.type === "sequenceItem" ? 2 : 0, concat([ @@ -153,6 +152,7 @@ function genericPrint(path, options, print) { ]) ) : "", + nextEmptyLine, ]); } @@ -703,6 +703,12 @@ function needsSpaceInFrontOfMappingValue(node) { return node.key.content && node.key.content.type === "alias"; } +function shouldPrintEndComments(node) { + return ( + hasEndComments(node) && !isNode(node, ["documentHead", "documentBody"]) + ); +} + function printNextEmptyLine(path, originalText) { const node = path.getValue(); const root = path.stack[0]; @@ -713,7 +719,9 @@ function printNextEmptyLine(path, originalText) { if (!root.isNextEmptyLinePrintedChecklist[node.position.end.line]) { if (isNextLineEmpty(node, originalText)) { root.isNextEmptyLinePrintedChecklist[node.position.end.line] = true; - return softline; + if (!shouldPrintEndComments(path.getParentNode())) { + return softline; + } } } diff --git a/tests/yaml/comment/__snapshots__/jsfmt.spec.js.snap b/tests/yaml/comment/__snapshots__/jsfmt.spec.js.snap index 3a14d8b4c..2217ba604 100644 --- a/tests/yaml/comment/__snapshots__/jsfmt.spec.js.snap +++ b/tests/yaml/comment/__snapshots__/jsfmt.spec.js.snap @@ -137,6 +137,44 @@ printWidth: 80 ================================================================================ `; +exports[`issue-9130.yml format 1`] = ` +====================================options===================================== +parsers: ["yaml"] +printWidth: 80 + | printWidth +=====================================input====================================== +- foo: 0 + bar: 1 + + # baz: 2 +- quux: 3 + +- foo: 0 + bar: 1 + + # baz: 2 + + # baz: 3 +- quux: 3 + +=====================================output===================================== +- foo: 0 + bar: 1 + + # baz: 2 +- quux: 3 + +- foo: 0 + bar: 1 + + # baz: 2 + + # baz: 3 +- quux: 3 + +================================================================================ +`; + exports[`map.yml format 1`] = ` ====================================options===================================== parsers: ["yaml"] @@ -282,6 +320,69 @@ foo2: ================================================================================ `; +exports[`map-4.yml format 1`] = ` +====================================options===================================== +parsers: ["yaml"] +printWidth: 80 + | printWidth +=====================================input====================================== +before: + + # before.comment +after: + # after.comment + +before-after: + + # before-after.comment + +none: + # none.comment +before(2 line): + + + # before.comment +after(2 line): + # after.comment + + +before-after(2 line): + + + # before-after.comment + + +none(2): + # none.comment +=====================================output===================================== +before: + +# before.comment +after: + # after.comment + +before-after: + + # before-after.comment + +none: + # none.comment +before(2 line): + + # before.comment +after(2 line): + # after.comment + +before-after(2 line): + + # before-after.comment + +none(2): + # none.comment + +================================================================================ +`; + exports[`object.yml format 1`] = ` ====================================options===================================== parsers: ["yaml"] @@ -336,6 +437,107 @@ printWidth: 80 ================================================================================ `; +exports[`sequence.yml format 1`] = ` +====================================options===================================== +parsers: ["yaml"] +printWidth: 80 + | printWidth +=====================================input====================================== +- - a + + # - b + + # - c + + - e + +- - a + + # - b + + # - c + +=====================================output===================================== +- - a + + # - b + + # - c + + - e + +- - a + + # - b + + # - c + +================================================================================ +`; + +exports[`sequence-2.yml format 1`] = ` +====================================options===================================== +parsers: ["yaml"] +printWidth: 80 + | printWidth +=====================================input====================================== +- before + + # before.comment +- after + # after.comment + +- before-after + + # before-after.comment + +- none: + # none.comment +- before(2 line) + + + # before.comment +- after(2 line) + # after.comment + + +- before-after(2 line) + + + # before-after.comment + + +- none(2) + # none.comment +=====================================output===================================== +- before + +# before.comment +- after + # after.comment + +- before-after + + # before-after.comment + +- none: + # none.comment +- before(2 line) + + # before.comment +- after(2 line) + # after.comment + +- before-after(2 line) + + # before-after.comment + +- none(2) + # none.comment + +================================================================================ +`; + exports[`set.yml format 1`] = ` ====================================options===================================== parsers: ["yaml"] diff --git a/tests/yaml/comment/issue-9130.yml b/tests/yaml/comment/issue-9130.yml new file mode 100644 index 000000000..ba54265aa --- /dev/null +++ b/tests/yaml/comment/issue-9130.yml @@ -0,0 +1,13 @@ +- foo: 0 + bar: 1 + + # baz: 2 +- quux: 3 + +- foo: 0 + bar: 1 + + # baz: 2 + + # baz: 3 +- quux: 3 diff --git a/tests/yaml/comment/map-4.yml b/tests/yaml/comment/map-4.yml new file mode 100644 index 000000000..2f80f700b --- /dev/null +++ b/tests/yaml/comment/map-4.yml @@ -0,0 +1,28 @@ +before: + + # before.comment +after: + # after.comment + +before-after: + + # before-after.comment + +none: + # none.comment +before(2 line): + + + # before.comment +after(2 line): + # after.comment + + +before-after(2 line): + + + # before-after.comment + + +none(2): + # none.comment \ No newline at end of file diff --git a/tests/yaml/comment/sequence-2.yml b/tests/yaml/comment/sequence-2.yml new file mode 100644 index 000000000..24be5d595 --- /dev/null +++ b/tests/yaml/comment/sequence-2.yml @@ -0,0 +1,28 @@ +- before + + # before.comment +- after + # after.comment + +- before-after + + # before-after.comment + +- none: + # none.comment +- before(2 line) + + + # before.comment +- after(2 line) + # after.comment + + +- before-after(2 line) + + + # before-after.comment + + +- none(2) + # none.comment \ No newline at end of file diff --git a/tests/yaml/comment/sequence.yml b/tests/yaml/comment/sequence.yml new file mode 100644 index 000000000..950714151 --- /dev/null +++ b/tests/yaml/comment/sequence.yml @@ -0,0 +1,13 @@ +- - a + + # - b + + # - c + + - e + +- - a + + # - b + + # - c From 9153bf20ac2dfcd525b5dd3f3b37d9b6005d20bc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 10 Sep 2020 21:30:40 +0800 Subject: [PATCH 4/8] Build(deps): Bump yaml-unist-parser from 1.3.0 to 1.3.1 (#9169) * Build(deps): Bump yaml-unist-parser from 1.3.0 to 1.3.1 Bumps [yaml-unist-parser](https://github.com/ikatyang/yaml-unist-parser) from 1.3.0 to 1.3.1. - [Release notes](https://github.com/ikatyang/yaml-unist-parser/releases) - [Changelog](https://github.com/ikatyang/yaml-unist-parser/blob/master/CHANGELOG.md) - [Commits](https://github.com/ikatyang/yaml-unist-parser/compare/v1.3.0...v1.3.1) Signed-off-by: dependabot[bot] * Update snapshot * Update changelog * spellcheck Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: fisker --- changelog_unreleased/yaml/pr-9143.md | 40 +++++++++++++------ cspell.json | 1 + package.json | 2 +- .../comment/__snapshots__/jsfmt.spec.js.snap | 4 +- yarn.lock | 8 ++-- 5 files changed, 35 insertions(+), 20 deletions(-) diff --git a/changelog_unreleased/yaml/pr-9143.md b/changelog_unreleased/yaml/pr-9143.md index 9ddb64472..772e3f362 100644 --- a/changelog_unreleased/yaml/pr-9143.md +++ b/changelog_unreleased/yaml/pr-9143.md @@ -1,27 +1,41 @@ -#### Fix printing doubles a blank line before a comment (#9143 by @sosukesuzuki) +#### Fix comment printing in mapping and sequence (#9143, #9169 by @sosukesuzuki, @fisker, fix in `yaml-unist-parser` by @ikatyang) ```yaml # Input -- foo: 0 - bar: 1 +- a + # Should indent +- bb - # baz: 2 -- quux: 3 +--- +- a: a + b: b + + # Should print one empty line before +- another # Prettier stable -- foo: 0 - bar: 1 +- a +# Should indent +- bb + +--- +- a: a + b: b - # baz: 2 -- quux: 3 + # Should print one empty line before +- another # Prettier master -- foo: 0 - bar: 1 +- a + # Should indent +- bb - # baz: 2 -- quux: 3 +--- +- a: a + b: b + # Should print one empty line before +- another ``` diff --git a/cspell.json b/cspell.json index c74e75d43..053c7f85c 100644 --- a/cspell.json +++ b/cspell.json @@ -399,6 +399,7 @@ "ignoreRegExpList": [ "\\n(`{3,})\\w*\\n[\\s\\S]+?\\1", "\\[(\\*{2})?@[-\\w]+?\\1\\]", + "by @[-\\w]+(?:, @[-\\w]+)?", "\\[`\\w+`\\]", "ve{2,}r{2,}y", "ve+r+y+long\\w*", diff --git a/package.json b/package.json index 822a4105a..e41730820 100644 --- a/package.json +++ b/package.json @@ -80,7 +80,7 @@ "unicode-regex": "3.0.0", "unified": "9.2.0", "vnopts": "1.0.2", - "yaml-unist-parser": "1.3.0" + "yaml-unist-parser": "1.3.1" }, "devDependencies": { "@babel/core": "7.11.4", diff --git a/tests/yaml/comment/__snapshots__/jsfmt.spec.js.snap b/tests/yaml/comment/__snapshots__/jsfmt.spec.js.snap index 2217ba604..9e899d762 100644 --- a/tests/yaml/comment/__snapshots__/jsfmt.spec.js.snap +++ b/tests/yaml/comment/__snapshots__/jsfmt.spec.js.snap @@ -357,7 +357,7 @@ none(2): =====================================output===================================== before: -# before.comment + # before.comment after: # after.comment @@ -512,7 +512,7 @@ printWidth: 80 =====================================output===================================== - before -# before.comment + # before.comment - after # after.comment diff --git a/yarn.lock b/yarn.lock index f18d5b697..ce41b55d0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8469,10 +8469,10 @@ yallist@^4.0.0: resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72" integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A== -yaml-unist-parser@1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/yaml-unist-parser/-/yaml-unist-parser-1.3.0.tgz#f64f1af96171fe4d7eb462e94225d42a6009b60e" - integrity sha512-kF1OS6fi9BzqX+vVC5hp+R5mmrHLH4f19Nx8fAwb08VqUwgFDBPOOu24VZO06nSOur13CGUTgHuaw5RIzpRnCw== +yaml-unist-parser@1.3.1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/yaml-unist-parser/-/yaml-unist-parser-1.3.1.tgz#4305a54d8f8750dfff782bb998ff93d0da538d1a" + integrity sha512-4aHBMpYcnByF8l2OKj5hlBJlxSYIMON8Z1Hm57ymbBL4omXMlGgY+pEf4Di6h2qNT8ZG8seTVvAQYNOa7CZ9eA== dependencies: lines-and-columns "^1.1.6" tslib "^1.10.0" From f75844a453beb6cb16791c14e5ff738c02d0b4df Mon Sep 17 00:00:00 2001 From: sosukesuzuki Date: Wed, 16 Sep 2020 08:35:59 +0900 Subject: [PATCH 5/8] Fix changelog --- changelog_unreleased/graphql/pr-9116.md | 2 +- changelog_unreleased/javascript/pr-9136.md | 2 +- changelog_unreleased/yaml/pr-9143.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/changelog_unreleased/graphql/pr-9116.md b/changelog_unreleased/graphql/pr-9116.md index 6ccaf6cbf..ae07229b0 100644 --- a/changelog_unreleased/graphql/pr-9116.md +++ b/changelog_unreleased/graphql/pr-9116.md @@ -1,4 +1,4 @@ -#### Fix formatting for directives in fields (#9116 by @sosukesuzuki) +#### Fix formatting for directives in fields ([#9116](https://github.com/prettier/prettier/pull/9116) by [@sosukesuzuki](https://github.com/sosukesuzuki)) ```graphql diff --git a/changelog_unreleased/javascript/pr-9136.md b/changelog_unreleased/javascript/pr-9136.md index 62f8518f4..39e1f545f 100644 --- a/changelog_unreleased/javascript/pr-9136.md +++ b/changelog_unreleased/javascript/pr-9136.md @@ -1,4 +1,4 @@ -#### Fix line breaks for CSS in JS (#9136 by @sosukesuzuki) +#### Fix line breaks for CSS in JS ([#9136](https://github.com/prettier/prettier/pull/9136) by [@sosukesuzuki](https://github.com/sosukesuzuki)) ```js diff --git a/changelog_unreleased/yaml/pr-9143.md b/changelog_unreleased/yaml/pr-9143.md index 772e3f362..72522b561 100644 --- a/changelog_unreleased/yaml/pr-9143.md +++ b/changelog_unreleased/yaml/pr-9143.md @@ -1,4 +1,4 @@ -#### Fix comment printing in mapping and sequence (#9143, #9169 by @sosukesuzuki, @fisker, fix in `yaml-unist-parser` by @ikatyang) +#### Fix comment printing in mapping and sequence ([#9143](https://github.com/prettier/prettier/pull/9143), [#9169](https://github.com/prettier/prettier/pull/9169) by [@sosukesuzuki](https://github.com/sosukesuzuki), [@fisker](https://github.com/fisker), fix in `yaml-unist-parser` by [@ikatyang](https://github.com/ikatyang)) ```yaml From 8eb8f9ed2dc5eb1c3e6f787e5a5e6fe68af2b8d1 Mon Sep 17 00:00:00 2001 From: sosukesuzuki Date: Wed, 16 Sep 2020 09:46:05 +0900 Subject: [PATCH 6/8] Release 2.1.2 --- .github/ISSUE_TEMPLATE/formatting.md | 2 +- .github/ISSUE_TEMPLATE/integration.md | 2 +- CHANGELOG.md | 122 ++++++++++++++++++ changelog_unreleased/graphql/pr-9116.md | 28 ---- changelog_unreleased/javascript/pr-9136.md | 46 ------- changelog_unreleased/yaml/pr-9143.md | 41 ------ docs/browser.md | 12 +- package.json | 2 +- .../versioned_docs/version-stable/browser.md | 12 +- 9 files changed, 137 insertions(+), 130 deletions(-) delete mode 100644 changelog_unreleased/graphql/pr-9116.md delete mode 100644 changelog_unreleased/javascript/pr-9136.md delete mode 100644 changelog_unreleased/yaml/pr-9143.md diff --git a/.github/ISSUE_TEMPLATE/formatting.md b/.github/ISSUE_TEMPLATE/formatting.md index 6b189dac4..ba91ba43f 100644 --- a/.github/ISSUE_TEMPLATE/formatting.md +++ b/.github/ISSUE_TEMPLATE/formatting.md @@ -26,7 +26,7 @@ Tip! Don't write this stuff manually. --> -**Prettier 2.1.1** +**Prettier 2.1.2** [Playground link](https://prettier.io/playground/#.....) ```sh diff --git a/.github/ISSUE_TEMPLATE/integration.md b/.github/ISSUE_TEMPLATE/integration.md index 86ef35c25..73e97d703 100644 --- a/.github/ISSUE_TEMPLATE/integration.md +++ b/.github/ISSUE_TEMPLATE/integration.md @@ -20,7 +20,7 @@ BEFORE SUBMITTING AN ISSUE: **Environments:** -- Prettier Version: 2.1.1 +- Prettier Version: 2.1.2 - Running Prettier via: - Runtime: - Operating System: diff --git a/CHANGELOG.md b/CHANGELOG.md index 6751aaf7d..6270e1b7c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,125 @@ +# 2.1.2 + +[diff](https://github.com/prettier/prettier/compare/2.1.1...2.1.2) + +#### Fix formatting for directives in fields ([#9116](https://github.com/prettier/prettier/pull/9116) by [@sosukesuzuki](https://github.com/sosukesuzuki)) + + +```graphql +# Input +type Query { + someQuery(id: ID!, someOtherData: String!): String! @deprecated @isAuthenticated + versions: Versions! +} + + +# Prettier stable +type Query { + someQuery(id: ID!, someOtherData: String!): String! + @deprecated + @isAuthenticated + versions: Versions! +} + +# Prettier master +type Query { + someQuery(id: ID!, someOtherData: String!): String! + @deprecated + @isAuthenticated + versions: Versions! +} + +``` + +#### Fix line breaks for CSS in JS ([#9136](https://github.com/prettier/prettier/pull/9136) by [@sosukesuzuki](https://github.com/sosukesuzuki)) + + +```js +// Input +styled.div` + // prettier-ignore + @media (aaaaaaaaaaaaa) { + z-index: ${(props) => (props.isComplete ? '1' : '0')}; + } +`; +styled.div` + ${props => getSize(props.$size.xs)} + ${props => getSize(props.$size.sm, 'sm')} + ${props => getSize(props.$size.md, 'md')} +`; + +// Prettier stable +styled.div` + // prettier-ignore + @media (aaaaaaaaaaaaa) { + z-index: ${(props) => + props.isComplete ? "1" : "0"}; + } +`; +styled.div` + ${(props) => getSize(props.$size.xs)} + ${(props) => getSize(props.$size.sm, "sm")} + ${(props) => + getSize(props.$size.md, "md")} +`; + +// Prettier master +styled.div` + // prettier-ignore + @media (aaaaaaaaaaaaa) { + z-index: ${(props) => (props.isComplete ? "1" : "0")}; + } +`; +styled.div` + ${(props) => getSize(props.$size.xs)} + ${(props) => getSize(props.$size.sm, "sm")} + ${(props) => getSize(props.$size.md, "md")} +`; + +``` + +#### Fix comment printing in mapping and sequence ([#9143](https://github.com/prettier/prettier/pull/9143), [#9169](https://github.com/prettier/prettier/pull/9169) by [@sosukesuzuki](https://github.com/sosukesuzuki), [@fisker](https://github.com/fisker), fix in `yaml-unist-parser` by [@ikatyang](https://github.com/ikatyang)) + + +```yaml +# Input +- a + # Should indent +- bb + +--- +- a: a + b: b + + # Should print one empty line before +- another + +# Prettier stable +- a +# Should indent +- bb + +--- +- a: a + b: b + + + # Should print one empty line before +- another + +# Prettier master +- a + # Should indent +- bb + +--- +- a: a + b: b + + # Should print one empty line before +- another +``` + # 2.1.1 [diff](https://github.com/prettier/prettier/compare/2.1.0...2.1.1) diff --git a/changelog_unreleased/graphql/pr-9116.md b/changelog_unreleased/graphql/pr-9116.md deleted file mode 100644 index ae07229b0..000000000 --- a/changelog_unreleased/graphql/pr-9116.md +++ /dev/null @@ -1,28 +0,0 @@ -#### Fix formatting for directives in fields ([#9116](https://github.com/prettier/prettier/pull/9116) by [@sosukesuzuki](https://github.com/sosukesuzuki)) - - -```graphql -# Input -type Query { - someQuery(id: ID!, someOtherData: String!): String! @deprecated @isAuthenticated - versions: Versions! -} - - -# Prettier stable -type Query { - someQuery(id: ID!, someOtherData: String!): String! - @deprecated - @isAuthenticated - versions: Versions! -} - -# Prettier master -type Query { - someQuery(id: ID!, someOtherData: String!): String! - @deprecated - @isAuthenticated - versions: Versions! -} - -``` diff --git a/changelog_unreleased/javascript/pr-9136.md b/changelog_unreleased/javascript/pr-9136.md deleted file mode 100644 index 39e1f545f..000000000 --- a/changelog_unreleased/javascript/pr-9136.md +++ /dev/null @@ -1,46 +0,0 @@ -#### Fix line breaks for CSS in JS ([#9136](https://github.com/prettier/prettier/pull/9136) by [@sosukesuzuki](https://github.com/sosukesuzuki)) - - -```js -// Input -styled.div` - // prettier-ignore - @media (aaaaaaaaaaaaa) { - z-index: ${(props) => (props.isComplete ? '1' : '0')}; - } -`; -styled.div` - ${props => getSize(props.$size.xs)} - ${props => getSize(props.$size.sm, 'sm')} - ${props => getSize(props.$size.md, 'md')} -`; - -// Prettier stable -styled.div` - // prettier-ignore - @media (aaaaaaaaaaaaa) { - z-index: ${(props) => - props.isComplete ? "1" : "0"}; - } -`; -styled.div` - ${(props) => getSize(props.$size.xs)} - ${(props) => getSize(props.$size.sm, "sm")} - ${(props) => - getSize(props.$size.md, "md")} -`; - -// Prettier master -styled.div` - // prettier-ignore - @media (aaaaaaaaaaaaa) { - z-index: ${(props) => (props.isComplete ? "1" : "0")}; - } -`; -styled.div` - ${(props) => getSize(props.$size.xs)} - ${(props) => getSize(props.$size.sm, "sm")} - ${(props) => getSize(props.$size.md, "md")} -`; - -``` diff --git a/changelog_unreleased/yaml/pr-9143.md b/changelog_unreleased/yaml/pr-9143.md deleted file mode 100644 index 72522b561..000000000 --- a/changelog_unreleased/yaml/pr-9143.md +++ /dev/null @@ -1,41 +0,0 @@ -#### Fix comment printing in mapping and sequence ([#9143](https://github.com/prettier/prettier/pull/9143), [#9169](https://github.com/prettier/prettier/pull/9169) by [@sosukesuzuki](https://github.com/sosukesuzuki), [@fisker](https://github.com/fisker), fix in `yaml-unist-parser` by [@ikatyang](https://github.com/ikatyang)) - - -```yaml -# Input -- a - # Should indent -- bb - ---- -- a: a - b: b - - # Should print one empty line before -- another - -# Prettier stable -- a -# Should indent -- bb - ---- -- a: a - b: b - - - # Should print one empty line before -- another - -# Prettier master -- a - # Should indent -- bb - ---- -- a: a - b: b - - # Should print one empty line before -- another -``` diff --git a/docs/browser.md b/docs/browser.md index 19c7bfbe1..6f856eb8c 100644 --- a/docs/browser.md +++ b/docs/browser.md @@ -18,8 +18,8 @@ See [Usage](#usage) below for examples. ### Global ```html - - + + - + +