@prettier/plugin-ruby
Advanced tools
Comparing version 0.5.1 to 0.6.0
@@ -9,2 +9,18 @@ # Changelog | ||
## [0.6.0] - 2019-02-14 | ||
### Added | ||
- Handle non UTF-8 comments. | ||
- Handle non UTF-8 identifiers. | ||
- Handle non UTF-8 strings. | ||
- Handle empty parens. | ||
- Handle rescue with splats preceeding the exception names. | ||
### Changed | ||
- Use `JSON::fast_generate` to get the s-expressions back from the parser. | ||
- Handle broken lambdas from within `command` and `command_call` nodes. (Thanks to @NoahTheDuke for the report.) | ||
## [0.5.2] - 2019-02-13 | ||
### Changed | ||
- Support embedded expressions within strings that contain only keywords, as in `"#{super}"`. | ||
## [0.5.1] - 2019-02-13 | ||
@@ -131,3 +147,5 @@ ### Changed | ||
[Unreleased]: https://github.com/CultureHQ/add-to-calendar/compare/v0.5.1...HEAD | ||
[Unreleased]: https://github.com/CultureHQ/add-to-calendar/compare/v0.6.0...HEAD | ||
[0.6.0]: https://github.com/CultureHQ/add-to-calendar/compare/v0.5.2...v0.6.0 | ||
[0.5.2]: https://github.com/CultureHQ/add-to-calendar/compare/v0.5.1...v0.5.2 | ||
[0.5.1]: https://github.com/CultureHQ/add-to-calendar/compare/v0.5.0...v0.5.1 | ||
@@ -134,0 +152,0 @@ [0.5.0]: https://github.com/CultureHQ/add-to-calendar/compare/v0.4.1...v0.5.0 |
{ | ||
"name": "@prettier/plugin-ruby", | ||
"version": "0.5.1", | ||
"version": "0.6.0", | ||
"description": "prettier plugin for the Ruby programming language", | ||
@@ -5,0 +5,0 @@ "main": "src/ruby.js", |
@@ -95,4 +95,8 @@ const { align, breakParent, concat, dedent, dedentToRoot, group, hardline, ifBreak, indent, join, line, lineSuffix, literalline, markAsRoot, softline, trim } = require("prettier").doc.builders; | ||
assign: (path, opts, print) => { | ||
const [printedTarget, printedValue] = path.map(print, "body"); | ||
let [printedTarget, printedValue] = path.map(print, "body"); | ||
if (["mrhs_add_star", "mrhs_new_from_args"].includes(path.getValue().body[1].type)) { | ||
printedValue = group(join(concat([",", line]), printedValue)); | ||
} | ||
if (skipAssignIndent(path.getValue().body[1])) { | ||
@@ -230,6 +234,10 @@ return group(concat([printedTarget, " = ", printedValue])); | ||
makeCall(path, opts, print), | ||
path.call(print, "body", 2), | ||
" " | ||
path.call(print, "body", 2) | ||
]; | ||
if (!path.getValue().body[3]) { | ||
return concat(parts); | ||
} | ||
parts.push(" "); | ||
const args = join(concat([",", line]), path.call(print, "body", 3)); | ||
@@ -325,3 +333,13 @@ | ||
const noParams = params.body.every(type => !type); | ||
const commandNode = path.getParentNode(2); | ||
if (commandNode && ["command", "command_call"].includes(commandNode.type)) { | ||
return group(concat([ | ||
"lambda { ", | ||
noParams ? "" : concat(["|", paramsConcat, "|"]), | ||
indent(concat([line, path.call(print, "body", 1)])), | ||
concat([line, "}"]) | ||
])); | ||
} | ||
return group(ifBreak( | ||
@@ -343,7 +361,15 @@ concat([ | ||
}, | ||
massign: (path, opts, print) => group(concat([ | ||
group(join(concat([",", line]), path.call(print, "body", 0))), | ||
" =", | ||
indent(concat([line, path.call(print, "body", 1)])) | ||
])), | ||
massign: (path, opts, print) => { | ||
let right = path.call(print, "body", 1); | ||
if (["mrhs_add_star", "mrhs_new_from_args"].includes(path.getValue().body[1].type)) { | ||
right = group(join(concat([",", line]), right)); | ||
} | ||
return group(concat([ | ||
group(join(concat([",", line]), path.call(print, "body", 0))), | ||
" =", | ||
indent(concat([line, right])) | ||
])); | ||
}, | ||
method_add_arg: (path, opts, print) => { | ||
@@ -372,13 +398,15 @@ if (path.getValue().body[1].type === "args_new") { | ||
mrhs: makeList, | ||
mrhs_add_star: (path, opts, print) => group(join( | ||
concat([",", line]), | ||
[ | ||
...path.call(print, "body", 0), | ||
concat(["*", path.call(print, "body", 1)]) | ||
] | ||
)), | ||
mrhs_new_from_args: (path, opts, print) => group(join( | ||
concat([",", line]), | ||
[...path.call(print, "body", 0), path.call(print, "body", 1)] | ||
)), | ||
mrhs_add_star: (path, opts, print) => [ | ||
...path.call(print, "body", 0), | ||
concat(["*", path.call(print, "body", 1)]) | ||
], | ||
mrhs_new_from_args: (path, opts, print) => { | ||
const parts = path.call(print, "body", 0); | ||
if (path.getValue().body.length > 1) { | ||
parts.push(path.call(print, "body", 1)); | ||
} | ||
return parts; | ||
}, | ||
module: (path, opts, print) => { | ||
@@ -420,2 +448,6 @@ const declaration = group(concat(["module ", path.call(print, "body", 0)])); | ||
paren: (path, opts, print) => { | ||
if (!path.getValue().body[0]) { | ||
return "()"; | ||
} | ||
let content = path.call(print, "body", 0); | ||
@@ -447,3 +479,6 @@ | ||
} else { | ||
parts.push(" ", path.call(print, "body", 0)); | ||
parts.push( | ||
" ", | ||
align("rescue ".length, group(join(concat([",", line]), path.call(print, "body", 0)))) | ||
); | ||
} | ||
@@ -450,0 +485,0 @@ } |
@@ -59,3 +59,3 @@ const { concat, group, hardline, indent, join, line, softline } = require("prettier").doc.builders; | ||
const isHeredoc = stmts.length === 1 && ( | ||
stmts[0].type === "heredoc" || stmts[0].body[0].type === "heredoc" | ||
stmts[0].type === "heredoc" || (stmts[0].body[0] && stmts[0].body[0].type === "heredoc") | ||
); | ||
@@ -62,0 +62,0 @@ |
Sorry, the diff of this file is not supported yet
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
180739
1172