@prettier/plugin-ruby
Advanced tools
Comparing version 2.0.0-rc2 to 2.0.0-rc3
@@ -9,2 +9,9 @@ # Changelog | ||
## [2.0.0-rc3] | ||
### Changed | ||
- [#987](https://github.com/prettier/plugin-ruby/pull/9870) - valscion - Ignore stderr when checking for node <-> ruby connection clients, restoring the behavior of v1.x | ||
- [#989](https://github.com/prettier/plugin-ruby/issues/989) - hubertjakubiak, kddnewton - Make sure comments after the keyword/lbrace are not moved inside the body of the statements of do and brace blocks. | ||
## [2.0.0-rc2] | ||
@@ -1166,3 +1173,4 @@ | ||
[unreleased]: https://github.com/prettier/plugin-ruby/compare/v2.0.0-rc2...HEAD | ||
[unreleased]: https://github.com/prettier/plugin-ruby/compare/v2.0.0-rc3...HEAD | ||
[2.0.0-rc3]: https://github.com/prettier/plugin-ruby/compare/v2.0.0-rc2...v2.0.0-rc3 | ||
[2.0.0-rc2]: https://github.com/prettier/plugin-ruby/compare/v2.0.0-rc1...v2.0.0-rc2 | ||
@@ -1169,0 +1177,0 @@ [2.0.0-rc1]: https://github.com/prettier/plugin-ruby/compare/v1.6.1...v2.0.0-rc1 |
@@ -20,2 +20,19 @@ "use strict"; | ||
exports.printBlockVar = printBlockVar; | ||
// You have to go through the main print function if you could potentially have | ||
// comments attached. So we're doing this weird reflection on the printed docs | ||
// to retroactively change the printed keyword depending on if we're using | ||
// braces or not. Ideally we wouldn't do this, we would instead do this | ||
// reflection in the child printer, but this keeps the logic to just this file | ||
// and contains it, so keeping it here for now. | ||
function printBlockBeging(path, print, useBraces) { | ||
let docs = print(path); | ||
const doc = useBraces ? "{" : "do"; | ||
if (Array.isArray(docs)) { | ||
docs[1] = doc; | ||
} | ||
else { | ||
docs = doc; | ||
} | ||
return docs; | ||
} | ||
function printBlock(braces) { | ||
@@ -38,3 +55,4 @@ return function printBlockWithBraces(path, opts, print) { | ||
const doBlock = [ | ||
useBraces ? " {" : " do", | ||
" ", | ||
path.call((begingPath) => printBlockBeging(begingPath, print, useBraces), "beging"), | ||
variables ? [" ", path.call(print, "body", 0)] : "", | ||
@@ -59,3 +77,4 @@ doBlockBody, | ||
const braceBlock = [ | ||
" {", | ||
" ", | ||
path.call((begingPath) => printBlockBeging(begingPath, print, true), "beging"), | ||
hasBody || variables ? " " : "", | ||
@@ -62,0 +81,0 @@ variables ? path.call(print, "body", 0) : "", |
@@ -70,2 +70,6 @@ "use strict"; | ||
} | ||
case "brace_block": | ||
return [node.body[0], node.body[1], node.beging]; | ||
case "do_block": | ||
return [node.body[0], node.body[1], node.beging]; | ||
case "paren": | ||
@@ -72,0 +76,0 @@ return [node.lparen, node.body[0]]; |
{ | ||
"name": "@prettier/plugin-ruby", | ||
"version": "2.0.0-rc2", | ||
"version": "2.0.0-rc3", | ||
"description": "prettier plugin for the Ruby programming language", | ||
@@ -5,0 +5,0 @@ "main": "dist/plugin.js", |
@@ -24,5 +24,28 @@ import type { Plugin, Ruby } from "../../types"; | ||
function printBlock( | ||
braces: boolean | ||
): Plugin.Printer<Ruby.BraceBlock | Ruby.DoBlock> { | ||
// You have to go through the main print function if you could potentially have | ||
// comments attached. So we're doing this weird reflection on the printed docs | ||
// to retroactively change the printed keyword depending on if we're using | ||
// braces or not. Ideally we wouldn't do this, we would instead do this | ||
// reflection in the child printer, but this keeps the logic to just this file | ||
// and contains it, so keeping it here for now. | ||
function printBlockBeging( | ||
path: Plugin.Path<Ruby.Lbrace | Ruby.Keyword>, | ||
print: Plugin.Print, | ||
useBraces: boolean | ||
) { | ||
let docs = print(path); | ||
const doc = useBraces ? "{" : "do"; | ||
if (Array.isArray(docs)) { | ||
docs[1] = doc; | ||
} else { | ||
docs = doc; | ||
} | ||
return docs; | ||
} | ||
type Block = Ruby.BraceBlock | Ruby.DoBlock; | ||
function printBlock(braces: boolean): Plugin.Printer<Block> { | ||
return function printBlockWithBraces(path, opts, print) { | ||
@@ -50,3 +73,7 @@ const [variables, statements] = path.getValue().body; | ||
const doBlock = [ | ||
useBraces ? " {" : " do", | ||
" ", | ||
path.call( | ||
(begingPath) => printBlockBeging(begingPath, print, useBraces), | ||
"beging" | ||
), | ||
variables ? [" ", path.call(print, "body", 0)] : "", | ||
@@ -77,3 +104,7 @@ doBlockBody, | ||
const braceBlock = [ | ||
" {", | ||
" ", | ||
path.call( | ||
(begingPath) => printBlockBeging(begingPath, print, true), | ||
"beging" | ||
), | ||
hasBody || variables ? " " : "", | ||
@@ -80,0 +111,0 @@ variables ? path.call(print, "body", 0) : "", |
@@ -80,2 +80,6 @@ import type { Plugin, Ruby } from "../types"; | ||
} | ||
case "brace_block": | ||
return [node.body[0], node.body[1], node.beging]; | ||
case "do_block": | ||
return [node.body[0], node.body[1], node.beging]; | ||
case "paren": | ||
@@ -82,0 +86,0 @@ return [node.lparen, node.body[0]]; |
@@ -187,7 +187,7 @@ // This file contains all of the types that represent objects being returned | ||
export type BlockVar = ParserEvent<"block_var", { body: [Params, false | Identifier[]] }>; | ||
export type BraceBlock = ParserEvent<"brace_block", { body: [null | BlockVar, Stmts] }>; | ||
export type BraceBlock = ParserEvent<"brace_block", { body: [null | BlockVar, Stmts], beging: Lbrace }>; | ||
export type Call = ParserEvent<"call", { body: [AnyNode, CallOperator, Backtick | Op | Identifier | Const | "call"] }>; | ||
export type Command = ParserEvent<"command", { body: [Const | Identifier, Args | ArgsAddBlock] }>; | ||
export type CommandCall = ParserEvent<"command_call", { body: [AnyNode, CallOperator, Op | Identifier | Const, Args | ArgsAddBlock] }>; | ||
export type DoBlock = ParserEvent<"do_block", { body: [null | BlockVar, Bodystmt] }>; | ||
export type DoBlock = ParserEvent<"do_block", { body: [null | BlockVar, Bodystmt], beging: Keyword }>; | ||
export type Fcall = ParserEvent<"fcall", { body: [Const | Identifier] }>; | ||
@@ -194,0 +194,0 @@ export type MethodAddArg = ParserEvent<"method_add_arg", { body: [Call | Fcall, Args | ArgParen | ArgsAddBlock] }>; |
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
Sorry, the diff of this file is not supported yet
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
762305
10460
5