prettier-plugin-marko
Advanced tools
Comparing version 3.1.9 to 3.1.10
@@ -880,2 +880,3 @@ "use strict"; | ||
} | ||
let bodyOverrideCode; | ||
if (node.attributes.length) { | ||
@@ -885,3 +886,8 @@ const attrsDoc = []; | ||
const attrNode = attrPath.getNode(); | ||
if (attrNode.default) { | ||
if (attrNode.type === "MarkoAttribute" && attrNode.name === "value" && !node.body.body.length && attrNode.value.type === "FunctionExpression" && !(attrNode.value.async || attrNode.value.generator || attrNode.value.returnType || attrNode.value.typeParameters)) { | ||
bodyOverrideCode = getOriginalCodeForNode( | ||
opts, | ||
attrNode.value.body | ||
).replace(/^\s*{\s*/, "").replace(/\s*}\s*$/, ""); | ||
} else if (attrNode.default) { | ||
doc4.push(print(attrPath)); | ||
@@ -906,6 +912,9 @@ } else { | ||
} | ||
if (node.body.body.length) { | ||
const wrapSep = opts.markoSyntax === "html" && (node.var || node.body.params.length || ((_a = node.arguments) == null ? void 0 : _a.length) || node.attributes.length || node.body.body.some( | ||
const bodyOverride = bodyOverrideCode !== void 0 && await toDoc(bodyOverrideCode, { | ||
parser | ||
}).catch(() => asLiteralTextContent(bodyOverrideCode)); | ||
if (bodyOverride || node.body.body.length) { | ||
const wrapSep = opts.markoSyntax === "html" && (node.var || node.body.params.length || ((_a = node.arguments) == null ? void 0 : _a.length) || node.attributes.length || !bodyOverride && node.body.body.some( | ||
(child) => !isTextLike(child, node) | ||
)) ? b5.hardline : opts.markoSyntax === "concise" || node.body.body.some( | ||
)) ? b5.hardline : opts.markoSyntax === "concise" || !bodyOverride && node.body.body.some( | ||
(child) => child.type === "MarkoScriptlet" | ||
@@ -917,19 +926,21 @@ ) ? b5.hardline : b5.softline; | ||
let embeddedCode = ""; | ||
path.each( | ||
(childPath) => { | ||
const childNode = childPath.getNode(); | ||
if (childNode.type === "MarkoText") { | ||
embeddedCode += childNode.value; | ||
} else { | ||
embeddedCode += `__EMBEDDED_PLACEHOLDER_${placeholderId++}__`; | ||
placeholders.push(print(childPath)); | ||
} | ||
}, | ||
"body", | ||
"body" | ||
); | ||
if (!bodyOverride) { | ||
path.each( | ||
(childPath) => { | ||
const childNode = childPath.getNode(); | ||
if (childNode.type === "MarkoText") { | ||
embeddedCode += childNode.value; | ||
} else { | ||
embeddedCode += `__EMBEDDED_PLACEHOLDER_${placeholderId++}__`; | ||
placeholders.push(print(childPath)); | ||
} | ||
}, | ||
"body", | ||
"body" | ||
); | ||
} | ||
const bodyDoc = b5.group([ | ||
opts.markoSyntax === "html" ? "" : b5.ifBreak("--", " --", { groupId }), | ||
opts.markoSyntax === "html" ? "" : b5.line, | ||
replaceEmbeddedPlaceholders( | ||
bodyOverride || replaceEmbeddedPlaceholders( | ||
parser === false ? asLiteralTextContent(embeddedCode.trim()) : await toDoc(embeddedCode, { | ||
@@ -936,0 +947,0 @@ parser |
import { ParserOptions } from "prettier"; | ||
import type { types as t } from "@marko/compiler"; | ||
export declare function getOriginalCodeForNode(opts: ParserOptions<t.Node>, node: t.Node): any; | ||
export declare function getOriginalCodeForNode(opts: ParserOptions<t.Node>, node: t.Node): string; |
{ | ||
"name": "prettier-plugin-marko", | ||
"description": "A prettier plugin for parsing and printing Marko files", | ||
"version": "3.1.9", | ||
"version": "3.1.10", | ||
"author": "Dylan Piercey <dpiercey@ebay.com>", | ||
"bugs": "https://github.com/marko-js/prettier/issues", | ||
"devDependencies": { | ||
"@babel/generator": "^7.26.2", | ||
"@babel/generator": "^7.26.3", | ||
"@commitlint/cli": "^17.7.2", | ||
@@ -13,4 +13,4 @@ "@commitlint/config-conventional": "^17.7.0", | ||
"@types/babel__generator": "^7.6.8", | ||
"@types/mocha": "^10.0.7", | ||
"@types/node": "^22.5.1", | ||
"@types/mocha": "^10.0.10", | ||
"@types/node": "^22.10.2", | ||
"@typescript-eslint/eslint-plugin": "^6.7.5", | ||
@@ -26,9 +26,9 @@ "@typescript-eslint/parser": "^6.7.5", | ||
"lint-staged": "^14.0.1", | ||
"marko": "^5.35.32", | ||
"marko": "^5.36.3", | ||
"mocha": "^10.7.3", | ||
"mocha-snap": "^5.0.0", | ||
"nyc": "^15.1.0", | ||
"prettier": "^3.3.3", | ||
"prettier": "^3.4.2", | ||
"semantic-release": "^22.0.5", | ||
"typescript": "^5.5.4" | ||
"typescript": "^5.7.2" | ||
}, | ||
@@ -35,0 +35,0 @@ "exports": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
102551
2769
1