diff --git a/docs/rationale.md b/docs/rationale.md index 84ff29dba..67115f679 100644 --- a/docs/rationale.md +++ b/docs/rationale.md @@ -132,9 +132,11 @@ One final thing: TC39 has [not yet decided if decorators come before or after `e ```js @decorator -export class Foo { } +export class Foo {} -export @decorator class Foo { } +export +@decorator +class Foo {} ``` ### Semicolons diff --git a/package.json b/package.json index 418d767a0..9d1e75732 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "prettier", - "version": "1.19.0", + "version": "1.20.0-dev", "description": "Prettier is an opinionated code formatter", "bin": { "prettier": "./bin/prettier.js" @@ -96,7 +96,7 @@ "jest-snapshot-serializer-raw": "1.1.0", "jest-watch-typeahead": "0.4.0", "mkdirp": "0.5.1", - "prettier": "1.18.2", + "prettier": "1.19.0", "prettylint": "1.0.0", "rimraf": "3.0.0", "rollup": "1.26.3", diff --git a/src/language-css/printer-postcss.js b/src/language-css/printer-postcss.js index 9d4af917f..e67e41e14 100644 --- a/src/language-css/printer-postcss.js +++ b/src/language-css/printer-postcss.js @@ -593,7 +593,8 @@ function genericPrint(path, options, print) { (isAdditionNode(iNode) || isSubtractionNode(iNode)) && i === 0 && (iNextNode.type === "value-number" || iNextNode.isHex) && - (parentParentNode && isColorAdjusterFuncNode(parentParentNode)) && + parentParentNode && + isColorAdjusterFuncNode(parentParentNode) && !hasEmptyRawBefore(iNextNode); const requireSpaceBeforeOperator = diff --git a/src/language-html/printer-html.js b/src/language-html/printer-html.js index ba073a41c..ebf2ce56b 100644 --- a/src/language-html/printer-html.js +++ b/src/language-html/printer-html.js @@ -207,10 +207,10 @@ function genericPrint(path, options, print) { const shouldHugContent = node.children.length === 1 && node.firstChild.type === "interpolation" && - (node.firstChild.isLeadingSpaceSensitive && - !node.firstChild.hasLeadingSpaces) && - (node.lastChild.isTrailingSpaceSensitive && - !node.lastChild.hasTrailingSpaces); + node.firstChild.isLeadingSpaceSensitive && + !node.firstChild.hasLeadingSpaces && + node.lastChild.isTrailingSpaceSensitive && + !node.lastChild.hasTrailingSpaces; const attrGroupId = Symbol("element-attr-group-id"); return concat([ group( diff --git a/src/language-html/utils.js b/src/language-html/utils.js index d1a6ac919..0b7827312 100644 --- a/src/language-html/utils.js +++ b/src/language-html/utils.js @@ -276,9 +276,9 @@ function forceBreakContent(node) { node.children.some(child => hasNonTextChild(child)))) || (node.firstChild && node.firstChild === node.lastChild && - (hasLeadingLineBreak(node.firstChild) && - (!node.lastChild.isTrailingSpaceSensitive || - hasTrailingLineBreak(node.lastChild)))) + hasLeadingLineBreak(node.firstChild) && + (!node.lastChild.isTrailingSpaceSensitive || + hasTrailingLineBreak(node.lastChild))) ); } diff --git a/src/language-js/comments.js b/src/language-js/comments.js index 6f3395941..5447b7f7a 100644 --- a/src/language-js/comments.js +++ b/src/language-js/comments.js @@ -428,7 +428,8 @@ function handleClassComments( enclosingNode && (enclosingNode.type === "ClassDeclaration" || enclosingNode.type === "ClassExpression") && - (enclosingNode.decorators && enclosingNode.decorators.length > 0) && + enclosingNode.decorators && + enclosingNode.decorators.length > 0 && !(followingNode && followingNode.type === "Decorator") ) { if (!enclosingNode.decorators || enclosingNode.decorators.length === 0) { @@ -573,8 +574,8 @@ function handleCommentInEmptyParens(text, enclosingNode, comment, options) { } if ( enclosingNode && - (enclosingNode.type === "MethodDefinition" && - enclosingNode.value.params.length === 0) + enclosingNode.type === "MethodDefinition" && + enclosingNode.value.params.length === 0 ) { addDanglingComment(enclosingNode.value, comment); return true; diff --git a/src/language-js/embed.js b/src/language-js/embed.js index dca4f6c44..0e5454648 100644 --- a/src/language-js/embed.js +++ b/src/language-js/embed.js @@ -161,11 +161,10 @@ function embed(path, print, textToDoc, options) { */ if ( parentParent && - (parentParent.type === "TaggedTemplateExpression" && - parent.quasis.length === 1 && - (parentParent.tag.type === "Identifier" && - (parentParent.tag.name === "md" || - parentParent.tag.name === "markdown"))) + parentParent.type === "TaggedTemplateExpression" && + parent.quasis.length === 1 && + parentParent.tag.type === "Identifier" && + (parentParent.tag.name === "md" || parentParent.tag.name === "markdown") ) { const text = parent.quasis[0].value.raw.replace( /((?:\\\\)*)\\`/g, diff --git a/src/language-js/printer-estree.js b/src/language-js/printer-estree.js index 4c592b26e..82967e586 100644 --- a/src/language-js/printer-estree.js +++ b/src/language-js/printer-estree.js @@ -597,9 +597,9 @@ function printPathNoParens(path, options, print, args) { (n === parent.body && parent.type === "ArrowFunctionExpression") || (n !== parent.body && parent.type === "ForStatement") || (parent.type === "ConditionalExpression" && - (parentParent.type !== "ReturnStatement" && - parentParent.type !== "CallExpression" && - parentParent.type !== "OptionalCallExpression")); + parentParent.type !== "ReturnStatement" && + parentParent.type !== "CallExpression" && + parentParent.type !== "OptionalCallExpression"); const shouldIndentIfInlining = parent.type === "AssignmentExpression" || @@ -3601,10 +3601,10 @@ function printPathNoParens(path, options, print, args) { isNgForOf(n, index, parentNode) || (((index === 1 && (n.key.name === "then" || n.key.name === "else")) || (index === 2 && - (n.key.name === "else" && - parentNode.body[index - 1].type === - "NGMicrosyntaxKeyedExpression" && - parentNode.body[index - 1].key.name === "then"))) && + n.key.name === "else" && + parentNode.body[index - 1].type === + "NGMicrosyntaxKeyedExpression" && + parentNode.body[index - 1].key.name === "then")) && parentNode.body[0].type === "NGMicrosyntaxExpression"); return concat([ path.call(print, "key"), @@ -4450,12 +4450,12 @@ function printExportDeclaration(path, options, print) { if ( isDefault && - (decl.declaration.type !== "ClassDeclaration" && - decl.declaration.type !== "FunctionDeclaration" && - decl.declaration.type !== "TSInterfaceDeclaration" && - decl.declaration.type !== "DeclareClass" && - decl.declaration.type !== "DeclareFunction" && - decl.declaration.type !== "TSDeclareFunction") + decl.declaration.type !== "ClassDeclaration" && + decl.declaration.type !== "FunctionDeclaration" && + decl.declaration.type !== "TSInterfaceDeclaration" && + decl.declaration.type !== "DeclareClass" && + decl.declaration.type !== "DeclareFunction" && + decl.declaration.type !== "TSDeclareFunction" ) { parts.push(semi); } @@ -5140,7 +5140,7 @@ function separatorNoWhitespace( if ( (childNode.type === "JSXElement" && !childNode.closingElement) || - (nextNode && (nextNode.type === "JSXElement" && !nextNode.closingElement)) + (nextNode && nextNode.type === "JSXElement" && !nextNode.closingElement) ) { return child.length === 1 ? softline : hardline; } diff --git a/src/language-yaml/utils.js b/src/language-yaml/utils.js index 777568ca4..4a1e8d74c 100644 --- a/src/language-yaml/utils.js +++ b/src/language-yaml/utils.js @@ -217,8 +217,13 @@ function getFlowScalarLineContents(nodeType, content, options) { index !== 0 && rawLineContents[index - 1].length !== 0 && lineContentWords.length !== 0 && - !// trailing backslash in quoteDouble should be preserved - (nodeType === "quoteDouble" && getLast(getLast(reduced)).endsWith("\\")) + !( + // trailing backslash in quoteDouble should be preserved + ( + nodeType === "quoteDouble" && + getLast(getLast(reduced)).endsWith("\\") + ) + ) ? reduced.concat([reduced.pop().concat(lineContentWords)]) : reduced.concat([lineContentWords]), [] diff --git a/tests_integration/__tests__/infer-parser.js b/tests_integration/__tests__/infer-parser.js index 071b896c0..3acaf440d 100644 --- a/tests_integration/__tests__/infer-parser.js +++ b/tests_integration/__tests__/infer-parser.js @@ -165,9 +165,11 @@ describe("--write and --list-different with unknown path and no parser", () => { }); describe("multiple files", () => { - runPrettier("cli/infer-parser/", ["--list-different", "--write", "*"]).test( - { status: 0 } - ); + runPrettier("cli/infer-parser/", [ + "--list-different", + "--write", + "*" + ]).test({ status: 0 }); }); }); diff --git a/website/blog/2017-05-03-1.3.0.md b/website/blog/2017-05-03-1.3.0.md index bfad69c5a..6026f8e48 100644 --- a/website/blog/2017-05-03-1.3.0.md +++ b/website/blog/2017-05-03-1.3.0.md @@ -468,10 +468,10 @@ In 1.0, we made class be inline inside of arrow functions. It turns out that it ```js // Before -export default (ViewComponent: Function, ContainerComponent: Function) => class - extends React.Component { - static propTypes = {}; -}; +export default (ViewComponent: Function, ContainerComponent: Function) => + class extends React.Component { + static propTypes = {}; + }; // After export default (ViewComponent: Function, ContainerComponent: Function) => diff --git a/yarn.lock b/yarn.lock index 61ed5b056..cb575cf96 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5479,10 +5479,10 @@ prettier-linter-helpers@^1.0.0: dependencies: fast-diff "^1.1.2" -prettier@1.18.2: - version "1.18.2" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.18.2.tgz#6823e7c5900017b4bd3acf46fe9ac4b4d7bda9ea" - integrity sha512-OeHeMc0JhFE9idD4ZdtNibzY0+TPHSpSSb9h8FqtP+YnoZZ1sl8Vc9b1sasjfymH3SonAF4QcA2+mzHPhMvIiw== +prettier@1.19.0: + version "1.19.0" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.19.0.tgz#3bec4489d5eebcd52b95ddd2c22467b5c852fde1" + integrity sha512-GlAIjk6DjkNT6u/Bw5QCWrbzh9YlLKwwmJT//1YiCR3WDpZDnyss64aXHQZgF8VKeGlWnX6+tGsKSVxsZT/gtA== pretty-format@^23.0.1, pretty-format@^23.2.0: version "23.2.0"