Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

prettier-plugin-svelte

Package Overview
Dependencies
Maintainers
1
Versions
60
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 0.1.0 to 0.1.1

2

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

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

@@ -260,2 +260,3 @@ 'use strict';

let isFirst = true;
const childNodes = path.getValue().children;
path.each(childPath => {

@@ -268,5 +269,28 @@ const child = childPath.getValue();

}
if (!(isFirst && skipFirst) && child.type !== 'Text' && child.type !== 'MustacheTag') {
children.push(hardline);
if (!(isFirst && skipFirst)) {
if (isInlineNode(child)) {
if (!isEmptyNode(child)) {
let lineType = softline;
if (child.type === 'Text') {
if (/^\s+/.test(child.data)) {
// Remove leading spaces
child.data = trimStart(child.data);
if (!isFirst) {
lineType = line;
}
}
}
children.push(lineType);
}
}
else {
children.push(hardline);
}
}
if (child.type === 'Text') {
if (isLastNode(childNodes, filter, index)) {
// Remove trailing spaces
child.data = trimEnd(child.data);
}
}
children.push(childPath.call(print));

@@ -285,2 +309,22 @@ isFirst = false;

}
function isInlineNode(node) {
return node.type === 'Text' || node.type === 'MustacheTag';
}
function isEmptyNode(node) {
return node.type === 'Text' && node.data.trim() === '';
}
function isLastNode(nodes, filter, index) {
for (let i = index + 1; i < nodes.length; i++) {
if (filter(nodes[i], i)) {
return false;
}
}
return true;
}
function trimStart(text) {
return text.replace(/^\s+/, '');
}
function trimEnd(text) {
return text.replace(/\s+$/, '');
}

@@ -287,0 +331,0 @@ const { builders: { concat: concat$1, hardline: hardline$1 }, utils: { removeLines }, } = prettier.doc;

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