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.3.0 to 0.4.0

14

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

@@ -26,4 +26,2 @@ "main": "plugin.js",

"dependencies": {
"prettier": "^1.16.1",
"svelte": "^2.0.0 || ^3.0.0-alpha",
"tslib": "^1.9.3"

@@ -33,4 +31,5 @@ },

"@types/node": "^10.12.18",
"@types/prettier": "^1.15.2",
"@types/prettier": "^1.16.3",
"ava": "1.2.0",
"prettier": "^1.16.4",
"rollup": "1.1.2",

@@ -40,7 +39,10 @@ "rollup-plugin-commonjs": "9.2.0",

"rollup-plugin-typescript": "1.0.0",
"test-svelte2": "npm:svelte@2.16.0",
"test-svelte3": "npm:svelte@3.0.0-alpha27",
"svelte": "^3.2.0",
"ts-node": "^7.0.1",
"typescript": "3.2.4"
},
"peerDependencies": {
"prettier": "^1.16.4",
"svelte": "^3.2.0"
}
}

@@ -53,18 +53,2 @@ 'use strict';

function isBindingNodeV2(node) {
return node.type === 'Binding' && 'value' in node;
}
function getSvelteVersion(importPath) {
const { version } = require(`${importPath}/package.json`);
const [major, minor, misc] = version.split('.');
const [patch, label] = misc.split('-');
return {
major: Number(major),
minor: Number(minor),
patch: Number(patch),
label,
};
}
const { concat, join, line, group, indent, softline, hardline } = prettier.doc.builders;

@@ -99,7 +83,3 @@ function print(path, options, print) {

}
const version = getSvelteVersion(options.sveltePath);
let [open, close] = ['{', '}'];
if (version.major < 3) {
[open, close] = ['"', '"'];
}
const [open, close] = ['{', '}'];
const node = n;

@@ -207,3 +187,3 @@ switch (node.type) {

const def = [
'{:elseif ',
'{:else if ',
path.map(ifPath => printJS(path, print, 'expression'), 'children')[0],

@@ -269,12 +249,2 @@ '}',

case 'Binding':
if (isBindingNodeV2(node)) {
return concat([
line,
'bind:',
node.name,
node.value.type === 'Identifier' && node.value.name === node.name
? ''
: concat(['=', open, printJS(path, print, 'value'), close]),
]);
}
return concat([

@@ -497,15 +467,2 @@ line,

function importSvelte(importPath) {
const version = getSvelteVersion(importPath);
if (version.major <= 2) {
return require(importPath);
}
const svelte = require(`${importPath}/compiler`);
return {
parse(text) {
return svelte.compile(text, { generate: false, onwarn: () => undefined }).ast;
},
};
}
function locStart(node) {

@@ -526,7 +483,6 @@ return node.start;

svelte: {
parse: (text, parsers, options) => {
const { parse } = importSvelte(options.sveltePath);
return parse(text);
parse: text => {
return require(`svelte/compiler`).parse(text);
},
preprocess(text) {
preprocess: text => {
text = snipTagContent('style', text);

@@ -547,9 +503,2 @@ text = snipTagContent('script', text, '{}');

};
const options = {
sveltePath: {
type: 'path',
description: 'Path to custom Svelte version to use',
default: 'svelte',
},
};

@@ -559,3 +508,2 @@ exports.languages = languages;

exports.printers = printers;
exports.options = options;
//# sourceMappingURL=plugin.js.map

@@ -1,2 +0,2 @@

# Prettier for Svelte components
# Prettier for Svelte 3 components

@@ -11,3 +11,2 @@ Format your svelte components using prettier.

- e.g. expressions inside of `{}`, event bindings `on:click=""`, and more
- Supports Svelte v2 and v3

@@ -14,0 +13,0 @@ ## How to use

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