@prettier/plugin-ruby
Advanced tools
Comparing version 0.12.0 to 0.12.1
@@ -9,2 +9,8 @@ # Changelog | ||
## [0.12.1] - 2019-04-22 | ||
### Changed | ||
- If a lambda literal is nested under a `command` or `command_call` node anywhere in the heirarchy, then it needs to use the higher-precedence `{ ... }` braces as opposed to the `do ... end` delimiters. | ||
- Calling `super` with a block and no args was causing the parser to fail when attempting to inspect lambda nodes. (Thanks to @jpickwell for the report.) | ||
- Support better breaking within interpolation by grouping the interpolated content. | ||
## [0.12.0] - 2019-04-18 | ||
@@ -255,3 +261,4 @@ ### Added | ||
[Unreleased]: https://github.com/prettier/plugin-ruby/compare/v0.12.0...HEAD | ||
[Unreleased]: https://github.com/prettier/plugin-ruby/compare/v0.12.1...HEAD | ||
[0.12.1]: https://github.com/prettier/plugin-ruby/compare/v0.12.0...v0.12.1 | ||
[0.12.0]: https://github.com/prettier/plugin-ruby/compare/v0.11.0...v0.12.0 | ||
@@ -258,0 +265,0 @@ [0.11.0]: https://github.com/prettier/plugin-ruby/compare/v0.10.0...v0.11.0 |
{ | ||
"name": "@prettier/plugin-ruby", | ||
"version": "0.12.0", | ||
"version": "0.12.1", | ||
"description": "prettier plugin for the Ruby programming language", | ||
@@ -5,0 +5,0 @@ "main": "src/ruby.js", |
@@ -146,3 +146,3 @@ <div align="center"> | ||
<!-- prettier-ignore --> | ||
<table><tr><td align="center"><a href="https://kevindeisz.com"><img src="https://avatars2.githubusercontent.com/u/5093358?v=4" width="100px;" alt="Kevin Deisz"/><br /><sub><b>Kevin Deisz</b></sub></a><br /><a href="https://github.com/kddeisz/plugin-ruby/commits?author=kddeisz" title="Code">💻</a> <a href="https://github.com/kddeisz/plugin-ruby/commits?author=kddeisz" title="Documentation">📖</a> <a href="#maintenance-kddeisz" title="Maintenance">🚧</a> <a href="#review-kddeisz" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/kddeisz/plugin-ruby/commits?author=kddeisz" title="Tests">⚠️</a></td><td align="center"><a href="https://www.alanfoster.me/"><img src="https://avatars2.githubusercontent.com/u/1271782?v=4" width="100px;" alt="Alan Foster"/><br /><sub><b>Alan Foster</b></sub></a><br /><a href="https://github.com/kddeisz/plugin-ruby/commits?author=AlanFoster" title="Code">💻</a> <a href="https://github.com/kddeisz/plugin-ruby/commits?author=AlanFoster" title="Documentation">📖</a> <a href="#review-AlanFoster" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/kddeisz/plugin-ruby/commits?author=AlanFoster" title="Tests">⚠️</a></td><td align="center"><a href="https://github.com/johnschoeman"><img src="https://avatars0.githubusercontent.com/u/16049495?v=4" width="100px;" alt="johnschoeman"/><br /><sub><b>johnschoeman</b></sub></a><br /><a href="https://github.com/kddeisz/plugin-ruby/commits?author=johnschoeman" title="Tests">⚠️</a></td><td align="center"><a href="https://twitter.com/aaronjensen"><img src="https://avatars3.githubusercontent.com/u/8588?v=4" width="100px;" alt="Aaron Jensen"/><br /><sub><b>Aaron Jensen</b></sub></a><br /><a href="https://github.com/kddeisz/plugin-ruby/commits?author=aaronjensen" title="Documentation">📖</a></td><td align="center"><a href="http://cameronbothner.com"><img src="https://avatars1.githubusercontent.com/u/4642599?v=4" width="100px;" alt="Cameron Bothner"/><br /><sub><b>Cameron Bothner</b></sub></a><br /><a href="https://github.com/kddeisz/plugin-ruby/commits?author=cbothner" title="Code">💻</a></td><td align="center"><a href="https://localhost.dev"><img src="https://avatars3.githubusercontent.com/u/47308085?v=4" width="100px;" alt="localhost.dev"/><br /><sub><b>localhost.dev</b></sub></a><br /><a href="https://github.com/kddeisz/plugin-ruby/issues?q=author%3Alocalhostdotdev" title="Bug reports">🐛</a> <a href="https://github.com/kddeisz/plugin-ruby/commits?author=localhostdotdev" title="Code">💻</a></td><td align="center"><a href="https://deecewan.github.io"><img src="https://avatars0.githubusercontent.com/u/4755785?v=4" width="100px;" alt="David Buchan-Swanson"/><br /><sub><b>David Buchan-Swanson</b></sub></a><br /><a href="https://github.com/kddeisz/plugin-ruby/issues?q=author%3Adeecewan" title="Bug reports">🐛</a> <a href="https://github.com/kddeisz/plugin-ruby/commits?author=deecewan" title="Code">💻</a></td></tr><tr><td align="center"><a href="https://github.com/jpickwell"><img src="https://avatars1.githubusercontent.com/u/4682321?v=4" width="100px;" alt="Jordan Pickwell"/><br /><sub><b>Jordan Pickwell</b></sub></a><br /><a href="https://github.com/kddeisz/plugin-ruby/issues?q=author%3Ajpickwell" title="Bug reports">🐛</a></td></tr></table> | ||
<table><tr><td align="center"><a href="https://kevindeisz.com"><img src="https://avatars2.githubusercontent.com/u/5093358?v=4" width="100px;" alt="Kevin Deisz"/><br /><sub><b>Kevin Deisz</b></sub></a><br /><a href="https://github.com/kddeisz/plugin-ruby/commits?author=kddeisz" title="Code">💻</a> <a href="https://github.com/kddeisz/plugin-ruby/commits?author=kddeisz" title="Documentation">📖</a> <a href="#maintenance-kddeisz" title="Maintenance">🚧</a> <a href="#review-kddeisz" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/kddeisz/plugin-ruby/commits?author=kddeisz" title="Tests">⚠️</a></td><td align="center"><a href="https://www.alanfoster.me/"><img src="https://avatars2.githubusercontent.com/u/1271782?v=4" width="100px;" alt="Alan Foster"/><br /><sub><b>Alan Foster</b></sub></a><br /><a href="https://github.com/kddeisz/plugin-ruby/commits?author=AlanFoster" title="Code">💻</a> <a href="https://github.com/kddeisz/plugin-ruby/commits?author=AlanFoster" title="Documentation">📖</a> <a href="#review-AlanFoster" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/kddeisz/plugin-ruby/commits?author=AlanFoster" title="Tests">⚠️</a></td><td align="center"><a href="https://github.com/johnschoeman"><img src="https://avatars0.githubusercontent.com/u/16049495?v=4" width="100px;" alt="johnschoeman"/><br /><sub><b>johnschoeman</b></sub></a><br /><a href="https://github.com/kddeisz/plugin-ruby/commits?author=johnschoeman" title="Tests">⚠️</a></td><td align="center"><a href="https://twitter.com/aaronjensen"><img src="https://avatars3.githubusercontent.com/u/8588?v=4" width="100px;" alt="Aaron Jensen"/><br /><sub><b>Aaron Jensen</b></sub></a><br /><a href="https://github.com/kddeisz/plugin-ruby/commits?author=aaronjensen" title="Documentation">📖</a></td><td align="center"><a href="http://cameronbothner.com"><img src="https://avatars1.githubusercontent.com/u/4642599?v=4" width="100px;" alt="Cameron Bothner"/><br /><sub><b>Cameron Bothner</b></sub></a><br /><a href="https://github.com/kddeisz/plugin-ruby/commits?author=cbothner" title="Code">💻</a></td><td align="center"><a href="https://localhost.dev"><img src="https://avatars3.githubusercontent.com/u/47308085?v=4" width="100px;" alt="localhost.dev"/><br /><sub><b>localhost.dev</b></sub></a><br /><a href="https://github.com/kddeisz/plugin-ruby/issues?q=author%3Alocalhostdotdev" title="Bug reports">🐛</a> <a href="https://github.com/kddeisz/plugin-ruby/commits?author=localhostdotdev" title="Code">💻</a></td><td align="center"><a href="https://deecewan.github.io"><img src="https://avatars0.githubusercontent.com/u/4755785?v=4" width="100px;" alt="David Buchan-Swanson"/><br /><sub><b>David Buchan-Swanson</b></sub></a><br /><a href="https://github.com/kddeisz/plugin-ruby/issues?q=author%3Adeecewan" title="Bug reports">🐛</a> <a href="https://github.com/kddeisz/plugin-ruby/commits?author=deecewan" title="Code">💻</a></td></tr><tr><td align="center"><a href="https://github.com/jpickwell"><img src="https://avatars1.githubusercontent.com/u/4682321?v=4" width="100px;" alt="Jordan Pickwell"/><br /><sub><b>Jordan Pickwell</b></sub></a><br /><a href="https://github.com/kddeisz/plugin-ruby/issues?q=author%3Ajpickwell" title="Bug reports">🐛</a></td><td align="center"><a href="http://codingitwrong.com"><img src="https://avatars0.githubusercontent.com/u/15832198?v=4" width="100px;" alt="Josh Justice"/><br /><sub><b>Josh Justice</b></sub></a><br /><a href="https://github.com/kddeisz/plugin-ruby/issues?q=author%3ACodingItWrong" title="Bug reports">🐛</a></td></tr></table> | ||
@@ -149,0 +149,0 @@ <!-- ALL-CONTRIBUTORS-LIST:END --> |
@@ -234,46 +234,2 @@ const { align, breakParent, concat, dedent, group, hardline, ifBreak, indent, join, line, literalline, markAsRoot, softline, trim } = require("prettier").doc.builders; | ||
])), | ||
lambda: (path, opts, print) => { | ||
let params = path.getValue().body[0]; | ||
let paramsConcat = ""; | ||
if (params.type === "params") { | ||
paramsConcat = path.call(print, "body", 0); | ||
} else { | ||
([params] = params.body); | ||
paramsConcat = path.call(print, "body", 0, "body", 0); | ||
} | ||
const noParams = params.body.every(type => !type); | ||
const commandNode = path.getParentNode(2); | ||
const inlineLambda = concat([ | ||
"->", | ||
noParams ? "" : concat(["(", paramsConcat, ")"]), | ||
" { ", | ||
path.call(print, "body", 1), | ||
" }" | ||
]); | ||
if (commandNode && ["command", "command_call"].includes(commandNode.type)) { | ||
return group(ifBreak( | ||
concat([ | ||
"lambda {", | ||
noParams ? "" : concat([" |", removeLines(paramsConcat), "|"]), | ||
indent(concat([line, path.call(print, "body", 1)])), | ||
concat([line, "}"]) | ||
]), | ||
inlineLambda | ||
)); | ||
} | ||
return group(ifBreak( | ||
concat([ | ||
"lambda do", | ||
noParams ? "" : concat([" |", removeLines(paramsConcat), "|"]), | ||
indent(concat([softline, path.call(print, "body", 1)])), | ||
concat([softline, "end"]) | ||
]), | ||
inlineLambda | ||
)); | ||
}, | ||
massign: (path, opts, print) => { | ||
@@ -513,2 +469,3 @@ let right = path.call(print, "body", 1); | ||
require("./nodes/hooks"), | ||
require("./nodes/lambdas"), | ||
require("./nodes/loops"), | ||
@@ -515,0 +472,0 @@ require("./nodes/methods"), |
@@ -81,14 +81,7 @@ const { concat, group, hardline, indent, join, literalline, softline } = require("prettier").doc.builders; | ||
string_dvar: surround("#{", "}"), | ||
string_embexpr: (path, opts, print) => { | ||
const stmts = path.getValue().body[0].body; | ||
const isHeredoc = stmts.length === 1 && ( | ||
stmts[0].type === "heredoc" || (stmts[0].body[0] && stmts[0].body[0].type === "heredoc") | ||
); | ||
return concat([ | ||
"#{", | ||
path.call(print, "body", 0), | ||
concat([isHeredoc ? hardline : "", "}"]) | ||
]); | ||
}, | ||
string_embexpr: (path, opts, print) => group(concat([ | ||
"#{", | ||
indent(concat([softline, path.call(print, "body", 0)])), | ||
concat([softline, "}"]) | ||
])), | ||
string_literal: (path, { preferSingleQuotes }, print) => { | ||
@@ -95,0 +88,0 @@ const string = path.getValue().body[0]; |
@@ -118,3 +118,3 @@ const { breakParent, concat, hardline, lineSuffix, literalline } = require("prettier").doc.builders; | ||
const skipAssignIndent = node => ( | ||
["array", "hash", "heredoc", "regexp_literal"].includes(node.type) | ||
["array", "hash", "heredoc", "lambda", "regexp_literal"].includes(node.type) | ||
|| (node.type === "call" && skipAssignIndent(node.body[0])) | ||
@@ -121,0 +121,0 @@ || (node.type === "string_literal" && node.body[0].type === "heredoc") |
Sorry, the diff of this file is not supported yet
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
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 2 instances in 1 package
1
172332
43
1649