prettier-plugin-marko
Advanced tools
Comparing version 3.1.6 to 3.1.7
@@ -69,6 +69,4 @@ "use strict"; | ||
const check = body[--j]; | ||
if (isText(check)) | ||
return true; | ||
else if (check.type !== "MarkoComment") | ||
break; | ||
if (isText(check)) return true; | ||
else if (check.type !== "MarkoComment") break; | ||
} | ||
@@ -78,6 +76,4 @@ j = i; | ||
const check = body[++j]; | ||
if (isText(check)) | ||
return true; | ||
else if (check.type !== "MarkoComment") | ||
break; | ||
if (isText(check)) return true; | ||
else if (check.type !== "MarkoComment") break; | ||
} | ||
@@ -203,26 +199,24 @@ } | ||
const { until, patterns } = stack[stack.length - 1]; | ||
outer: | ||
while (pos < str.length) { | ||
for (const pattern of patterns) { | ||
pattern.match.lastIndex = pos; | ||
if (pattern.match.test(str)) { | ||
pos = pattern.match.lastIndex; | ||
if (pattern.until) { | ||
stack.push(pattern); | ||
break outer; | ||
} else { | ||
continue outer; | ||
} | ||
outer: while (pos < str.length) { | ||
for (const pattern of patterns) { | ||
pattern.match.lastIndex = pos; | ||
if (pattern.match.test(str)) { | ||
pos = pattern.match.lastIndex; | ||
if (pattern.until) { | ||
stack.push(pattern); | ||
break outer; | ||
} else { | ||
continue outer; | ||
} | ||
} | ||
until.lastIndex = pos; | ||
if (until.test(str)) { | ||
pos = until.lastIndex; | ||
if (stack.length === 1) | ||
return true; | ||
stack.pop(); | ||
break; | ||
} | ||
pos++; | ||
} | ||
until.lastIndex = pos; | ||
if (until.test(str)) { | ||
pos = until.lastIndex; | ||
if (stack.length === 1) return true; | ||
stack.pop(); | ||
break; | ||
} | ||
pos++; | ||
} | ||
} while (pos < str.length && stack.length); | ||
@@ -241,4 +235,3 @@ return false; | ||
let cached = DocCache.get(doc4); | ||
if (cached !== void 0) | ||
return cached; | ||
if (cached !== void 0) return cached; | ||
if (Array.isArray(doc4)) { | ||
@@ -529,6 +522,5 @@ cached = ""; | ||
print(path, opts, print) { | ||
var _a, _b, _c, _d; | ||
var _a, _b, _c, _d, _e, _f; | ||
const node = path.getNode(); | ||
if (!node) | ||
return ""; | ||
if (!node) return ""; | ||
const { types: t } = currentCompiler; | ||
@@ -547,4 +539,3 @@ switch (node.type) { | ||
text.push(print(child)); | ||
if (i !== lastIndex) | ||
return; | ||
if (i !== lastIndex) return; | ||
} | ||
@@ -694,9 +685,9 @@ if (text.length) { | ||
} | ||
const hasAttrTags = !!((_c = node.attributeTags) == null ? void 0 : _c.length); | ||
if (voidHTMLReg.test(literalTagName)) { | ||
if (opts.markoSyntax === "html") | ||
doc4.push(">"); | ||
} else if (node.body.body.length) { | ||
if (opts.markoSyntax === "html") doc4.push(">"); | ||
} else if (node.body.body.length || hasAttrTags) { | ||
const lastIndex = node.body.body.length - 1; | ||
const bodyDocs = Array.isArray(node.attributeTags) ? tagPath.map(print, "attributeTags") : []; | ||
let textOnly = true; | ||
const bodyDocs = hasAttrTags ? tagPath.map(print, "attributeTags") : []; | ||
let textOnly = !hasAttrTags; | ||
let textDocs = []; | ||
@@ -709,4 +700,3 @@ tagPath.each( | ||
textDocs.push(print(childPath)); | ||
if (i !== lastIndex) | ||
return; | ||
if (i !== lastIndex) return; | ||
} else { | ||
@@ -736,4 +726,4 @@ textOnly = false; | ||
); | ||
const joinSep = (preserveSpace || !textOnly) && (opts.markoSyntax === "concise" || node.body.body.some((child) => child.type === "MarkoScriptlet")) ? b5.hardline : preserveSpace ? "" : b5.softline; | ||
const wrapSep = !preserveSpace && opts.markoSyntax === "html" && (node.var || node.body.params.length || ((_c = node.arguments) == null ? void 0 : _c.length) || node.attributes.length || node.body.body.some((child) => !isTextLike(child, node))) ? b5.hardline : joinSep; | ||
const joinSep = (preserveSpace || !textOnly) && (opts.markoSyntax === "concise" || ((_d = node.attributeTags) == null ? void 0 : _d.length) || node.body.body.some((child) => child.type === "MarkoScriptlet")) ? b5.hardline : preserveSpace ? "" : b5.softline; | ||
const wrapSep = !preserveSpace && opts.markoSyntax === "html" && (node.var || node.body.params.length || ((_e = node.arguments) == null ? void 0 : _e.length) || node.attributes.length || node.body.body.some((child) => !isTextLike(child, node))) ? b5.hardline : joinSep; | ||
if (opts.markoSyntax === "html") { | ||
@@ -768,3 +758,3 @@ doc4.push(">"); | ||
} | ||
if ((_d = node.arguments) == null ? void 0 : _d.length) { | ||
if ((_f = node.arguments) == null ? void 0 : _f.length) { | ||
doc4.push( | ||
@@ -1103,4 +1093,3 @@ b5.group([ | ||
} | ||
if (type.startsWith("Marko")) | ||
return null; | ||
if (type.startsWith("Marko")) return null; | ||
return async (toDoc, print) => { | ||
@@ -1121,4 +1110,3 @@ switch (node.type) { | ||
); | ||
if (printedDeclaration) | ||
return printedDeclaration; | ||
if (printedDeclaration) return printedDeclaration; | ||
} | ||
@@ -1261,4 +1249,3 @@ break; | ||
function replaceEmbeddedPlaceholders(doc4, placeholders) { | ||
if (!placeholders.length) | ||
return doc4; | ||
if (!placeholders.length) return doc4; | ||
return utils.mapDoc(doc4, (cur) => { | ||
@@ -1265,0 +1252,0 @@ if (typeof cur === "string") { |
{ | ||
"name": "prettier-plugin-marko", | ||
"description": "A prettier plugin for parsing and printing Marko files", | ||
"version": "3.1.6", | ||
"version": "3.1.7", | ||
"author": "Dylan Piercey <dpiercey@ebay.com>", | ||
"bugs": "https://github.com/marko-js/prettier/issues", | ||
"devDependencies": { | ||
"@babel/generator": "^7.25.5", | ||
"@babel/generator": "^7.26.2", | ||
"@commitlint/cli": "^17.7.2", | ||
@@ -17,4 +17,4 @@ "@commitlint/config-conventional": "^17.7.0", | ||
"@typescript-eslint/parser": "^6.7.5", | ||
"esbuild": "^0.19.4", | ||
"esbuild-register": "^3.5.0", | ||
"esbuild": "^0.24.0", | ||
"esbuild-register": "^3.6.0", | ||
"eslint": "^8.51.0", | ||
@@ -26,3 +26,3 @@ "eslint-config-prettier": "^9.0.0", | ||
"lint-staged": "^14.0.1", | ||
"marko": "^5.35.11", | ||
"marko": "^5.35.32", | ||
"mocha": "^10.7.3", | ||
@@ -29,0 +29,0 @@ "mocha-snap": "^5.0.0", |
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
100732
2747