1.3.1 (hotfix)

master
Christopher Chedeau 2017-05-03 14:41:25 -07:00
parent 8613046fd2
commit 515a565a66
3 changed files with 25 additions and 5 deletions

View File

@ -1,3 +1,7 @@
# 1.3.1
* Respect template inline-ness (#1497)
# 1.3.0
[link](https://github.com/jlongster/prettier/compare/1.2.2...1.3.0)

24
docs/prettier.min.js vendored
View File

@ -10022,7 +10022,7 @@ function printComments(path, print, options, needsSemi) {
var comments$1 = { attach, printComments, printDanglingComments };
var name = "prettier";
var version$2 = "1.3.0";
var version$2 = "1.3.1";
var description = "Prettier is an opinionated JavaScript formatter";
var bin = {"prettier":"./bin/prettier.js"};
var repository = "prettier/prettier";
@ -11156,8 +11156,7 @@ function genericPrintNoParens(path, options, print, args) {
n.body.type === "ObjectExpression" ||
n.body.type === "JSXElement" ||
n.body.type === "BlockStatement" ||
n.body.type === "TaggedTemplateExpression" ||
n.body.type === "TemplateLiteral" ||
isTemplateOnItsOwnLine(n.body, options.originalText) ||
n.body.type === "ArrowFunctionExpression"
) {
return group$1(collapsed);
@ -11479,7 +11478,8 @@ function genericPrintNoParens(path, options, print, args) {
// We want to keep require calls as a unit
(n.callee.type === "Identifier" && n.callee.name === "require") ||
// Template literals as single arguments
n.arguments.length === 1 && n.arguments[0].type === "TemplateLiteral" ||
(n.arguments.length === 1 &&
isTemplateOnItsOwnLine(n.arguments[0], options.originalText)) ||
// Keep test declarations on a single line
// e.g. `it('long name', () => {`
(n.callee.type === "Identifier" &&
@ -14708,6 +14708,22 @@ function shouldHugArguments(fun) {
);
}
function templateLiteralHasNewLines(template) {
return template.quasis.some(quasi => quasi.value.raw.includes('\n'));
}
function isTemplateOnItsOwnLine(n, text) {
return (
(n.type === "TemplateLiteral" && templateLiteralHasNewLines(n) ||
n.type === "TaggedTemplateExpression" && templateLiteralHasNewLines(n.quasi)) &&
!util$4.hasNewline(
text,
util$4.locStart(n),
{backwards: true}
)
);
}
function printArrayItems(path, options, printPath, print) {
const printedElements = [];
let separatorParts = [];

View File

@ -1,6 +1,6 @@
{
"name": "prettier",
"version": "1.3.0",
"version": "1.3.1",
"description": "Prettier is an opinionated JavaScript formatter",
"bin": {
"prettier": "./bin/prettier.js"