@prettier/plugin-ruby
Advanced tools
Comparing version 0.5.0 to 0.5.1
@@ -9,2 +9,8 @@ # Changelog | ||
## [0.5.1] - 2019-02-13 | ||
### Changed | ||
- Force `do` blocks that we know have to be `do` blocks to break. (Thanks to @yuki24 for the report.) | ||
- Handle `command` and `command_call` nodes `do` blocks by forcing them to break. (Thanks to @kmcq for the report.) | ||
- Attach comments to full hash association nodes, not just the value. (Thanks to @ashfurrow for the report.) | ||
## [0.5.0] - 2019-02-13 | ||
@@ -125,3 +131,4 @@ ### Added | ||
[Unreleased]: https://github.com/CultureHQ/add-to-calendar/compare/v0.5.0...HEAD | ||
[Unreleased]: https://github.com/CultureHQ/add-to-calendar/compare/v0.5.1...HEAD | ||
[0.5.1]: https://github.com/CultureHQ/add-to-calendar/compare/v0.5.0...v0.5.1 | ||
[0.5.0]: https://github.com/CultureHQ/add-to-calendar/compare/v0.4.1...v0.5.0 | ||
@@ -128,0 +135,0 @@ [0.4.1]: https://github.com/CultureHQ/add-to-calendar/compare/v0.4.0...v0.4.1 |
{ | ||
"name": "@prettier/plugin-ruby", | ||
"version": "0.5.0", | ||
"version": "0.5.1", | ||
"description": "prettier plugin for the Ruby programming language", | ||
@@ -5,0 +5,0 @@ "main": "src/ruby.js", |
@@ -1,2 +0,2 @@ | ||
const { breakParent, concat, group, ifBreak, indent, softline } = require("prettier").doc.builders; | ||
const { breakParent, concat, group, ifBreak, indent, line, softline } = require("prettier").doc.builders; | ||
@@ -68,2 +68,6 @@ const isCall = node => ["::", "."].includes(node) || node.type === "@period"; | ||
) { | ||
if (["command", "command_call"].includes(path.getParentNode().body[0].type)) { | ||
return `, &:${method.body}`; | ||
} | ||
return `(&:${method.body})`; | ||
@@ -80,7 +84,13 @@ } | ||
const [variables, statements] = path.getValue().body; | ||
const stmts = statements.type === "stmts" ? statements.body : statements.body[0].body; | ||
let doBlockBody = ""; | ||
if (stmts.length !== 1 || stmts[0].type !== "void_stmt") { | ||
doBlockBody = indent(concat([softline, path.call(print, "body", 1)])); | ||
} | ||
const doBlock = concat([ | ||
" do", | ||
variables ? concat([" ", path.call(print, "body", 0)]) : "", | ||
indent(concat([softline, path.call(print, "body", 1)])), | ||
doBlockBody, | ||
concat([softline, "end"]) | ||
@@ -91,3 +101,2 @@ ]); | ||
// comment. | ||
const stmts = statements.type === "stmts" ? statements.body : statements.body[0].body; | ||
if (stmts.length > 1 && stmts.filter(stmt => stmt.type !== "@comment").length === 1) { | ||
@@ -99,3 +108,3 @@ return concat([breakParent, doBlock]); | ||
// the arguments to that command, so we need to break the block | ||
if (path.getParentNode().body[0].type === "command") { | ||
if (["command", "command_call"].includes(path.getParentNode().body[0].type)) { | ||
return concat([breakParent, doBlock]); | ||
@@ -102,0 +111,0 @@ } |
const { breakParent, concat, hardline, group, ifBreak, indent, softline } = require("prettier").doc.builders; | ||
const printWithAddition = (keyword, path, print) => concat([ | ||
const printWithAddition = (keyword, path, print, { breaking = false } = {}) => concat([ | ||
`${keyword} `, | ||
@@ -8,3 +8,4 @@ path.call(print, "body", 0), | ||
concat([softline, path.call(print, "body", 2)]), | ||
concat([softline, "end"]) | ||
concat([softline, "end"]), | ||
breaking ? breakParent : "" | ||
]); | ||
@@ -46,4 +47,4 @@ | ||
if (stmts.body.length === 1 && stmts.body[0].type === "command") { | ||
return printWithAddition(keyword, path, print); | ||
if (stmts.body.length === 1 && ["command", "command_call"].includes(stmts.body[0].type)) { | ||
return printWithAddition(keyword, path, print, { breaking: true }); | ||
} | ||
@@ -63,3 +64,3 @@ | ||
if (addition) { | ||
return group(printWithAddition(keyword, path, print)); | ||
return group(printWithAddition(keyword, path, print, { breaking: true })); | ||
} | ||
@@ -66,0 +67,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
178870
1145