Socket
Socket
Sign inDemoInstall

prettier-plugin-svelte

Package Overview
Dependencies
Maintainers
2
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prettier-plugin-svelte - npm Package Compare versions

Comparing version 2.0.2 to 2.0.3

4

CHANGELOG.md
# prettier-plugin-svelte changelog
## 2.0.3
* When `svelteBracketNewLine` is set to `false`, don't print the closing `>` in a separate line if possible ([#183](https://github.com/sveltejs/prettier-plugin-svelte/issues/183))
## 2.0.2

@@ -4,0 +8,0 @@

2

package.json
{
"name": "prettier-plugin-svelte",
"version": "2.0.2",
"version": "2.0.3",
"description": "Svelte plugin for prettier",

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

@@ -612,2 +612,29 @@ 'use strict';

}
/**
* Returns true if the softline between `</tagName` and `>` can be omitted.
*/
function canOmitSoftlineBeforeClosingTag(node, path, options) {
return (!options.svelteBracketNewLine &&
(!hugsStartOfNextNode(node, options) || isLastChildWithinParentBlockElement(path)));
}
/**
* Return true if given node does not hug the next node, meaning there's whitespace
* or the end of the doc afterwards.
*/
function hugsStartOfNextNode(node, options) {
if (node.end === options.originalText.length) {
// end of document
return false;
}
return !options.originalText.substring(node.end).match(/^\s/);
}
function isLastChildWithinParentBlockElement(path) {
const parent = path.getParentNode();
if (!parent || !isBlockElement(parent)) {
return false;
}
const children = getChildren(parent);
const lastChild = children[children.length - 1];
return lastChild === path.getNode();
}

@@ -781,3 +808,6 @@ const { concat, join, line, group, indent, dedent, softline, hardline, fill, breakParent, literalline, } = prettier.doc.builders;

group(indent(concat([softline, groupConcat(['>', body(), `</${node.name}`])]))),
isEmpty && options.svelteBracketNewLine ? '' : softline,
(isEmpty && options.svelteBracketNewLine) ||
canOmitSoftlineBeforeClosingTag(node, path, options)
? ''
: softline,
'>',

@@ -828,3 +858,3 @@ ]);

group(indent(concat([noHugSeparatorStart, groupConcat([body(), `</${node.name}`])]))),
softline,
canOmitSoftlineBeforeClosingTag(node, path, options) ? '' : '',
'>',

@@ -831,0 +861,0 @@ ]);

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