Socket
Socket
Sign inDemoInstall

@prettier/plugin-ruby

Package Overview
Dependencies
Maintainers
12
Versions
78
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@prettier/plugin-ruby - npm Package Compare versions

Comparing version 1.6.0 to 1.6.1

prettier.gem

13

CHANGELOG.md

@@ -9,2 +9,12 @@ # Changelog

## [1.6.1] - 2021-06-30
### Changed
- [#862](https://github.com/prettier/plugin-ruby/issues/862) - azz, kddeisz - Group together `.where.not` calls in method chains.
- [#863](https://github.com/prettier/plugin-ruby/issues/863) - azz, kddeisz - Fix up Sorbet `sig` block formatting when chaining method calls.
- [#908](https://github.com/prettier/plugin-ruby/issues/908) - Hansenq, kddeisz - Method chains with blocks should be properly indented.
- [#916](https://github.com/prettier/plugin-ruby/issues/916) - pbrisbin, kddeisz - Ensure all of the necessary files are present in the gem.
- [#917](https://github.com/prettier/plugin-ruby/issues/917) - jscheid, kddeisz - Ensure hash keys with dynamic symbols don't strip their quotes.
## [1.6.0] - 2021-06-23

@@ -1123,3 +1133,4 @@

[unreleased]: https://github.com/prettier/plugin-ruby/compare/v1.6.0...HEAD
[unreleased]: https://github.com/prettier/plugin-ruby/compare/v1.6.1...HEAD
[1.6.1]: https://github.com/prettier/plugin-ruby/compare/v1.6.0...v1.6.1
[1.6.0]: https://github.com/prettier/plugin-ruby/compare/v1.5.5...v1.6.0

@@ -1126,0 +1137,0 @@ [1.5.5]: https://github.com/prettier/plugin-ruby/compare/v1.5.4...v1.5.5

2

package.json
{
"name": "@prettier/plugin-ruby",
"version": "1.6.0",
"version": "1.6.1",
"description": "prettier plugin for the Ruby programming language",

@@ -5,0 +5,0 @@ "main": "src/plugin.js",

@@ -36,3 +36,3 @@ const {

// and beyond.
const rightSideDoc = concat([
let rightSideDoc = concat([
receiverNode.comments ? hardline : softline,

@@ -43,2 +43,13 @@ operatorDoc,

// This is very specialized behavior wherein we group .where.not calls
// together because it looks better. For more information, see
// https://github.com/prettier/plugin-ruby/issues/862.
if (
receiverNode.type === "call" &&
receiverNode.body[2].body === "where" &&
messageDoc === "not"
) {
rightSideDoc = concat([operatorDoc, messageDoc]);
}
// Get a reference to the parent node so we can check if we're inside a chain

@@ -115,5 +126,34 @@ const parentNode = path.getParentNode();

// This is the threshold at which we will start to try to make a nicely
// indented call chain. For the most part, it's always 3.
let threshold = 3;
// Here, we have very specialized behavior where if we're within a sig block,
// then we're going to assume we're creating a Sorbet type signature. In that
// case, we really want the threshold to be lowered to 2 so that we create
// method chains off of any two method calls within the block. For more
// details, see
// https://github.com/prettier/plugin-ruby/issues/863.
let sigBlock = path.getParentNode(2);
if (sigBlock) {
// If we're at a do_block, then we want to go one more level up. This is
// because do_blocks have bodystmt nodes instead of just stmt nodes.
if (sigBlock.type === "do_block") {
sigBlock = path.getParentNode(3);
}
if (
sigBlock.type === "method_add_block" &&
sigBlock.body[1] &&
sigBlock.body[0].type === "method_add_arg" &&
sigBlock.body[0].body[0].type === "fcall" &&
sigBlock.body[0].body[0].body[0].body === "sig"
) {
threshold = 2;
}
}
// If we're at the top of a chain, then we're going to print out a nice
// multi-line layout if this doesn't break into multiple lines.
if (!chained.includes(parentNode.type) && (node.chain || 0) >= 3) {
if (!chained.includes(parentNode.type) && (node.chain || 0) >= threshold) {
// This is pretty specialized behavior. Basically if we're at the top of a

@@ -120,0 +160,0 @@ // chain but we've only had method calls without arguments and now we have

@@ -155,4 +155,6 @@ const {

quote = opts.rubySingleQuote ? "'" : '"';
} else if (node.quote.startsWith(":")) {
quote = node.quote.slice(1);
} else {
quote = node.quote.slice(1);
quote = node.quote;
}

@@ -159,0 +161,0 @@ } else {

@@ -6,3 +6,2 @@ const noIndent = [

"if",
"method_add_block",
"unless",

@@ -9,0 +8,0 @@ "xstring_literal"

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc