@huggingface/prettier-plugin-vertical-align
Advanced tools
Comparing version 0.2.1 to 0.2.2
@@ -28,6 +28,3 @@ import prettier from "prettier"; | ||
const keyLength = node[keyLengthSymbol]; | ||
const addedLength = keyLength - | ||
(node.key.loc.end.column - node.key.loc.start.column) - | ||
(node.optional ? 1 : 0) - | ||
(node.computed ? 2 : 0); | ||
const addedLength = keyLength - (node.key.loc.end.column - node.key.loc.start.column) - modifierLength(node); | ||
// console.log("keyLength", keyLength); | ||
@@ -86,6 +83,3 @@ switch (node.type) { | ||
for (const property of group) { | ||
keyLength = Math.max(keyLength, property.key.loc.end.column - | ||
property.key.loc.start.column + | ||
(property.optional ? 1 : 0) + | ||
(property.computed ? 2 : 0)); | ||
keyLength = Math.max(keyLength, property.key.loc.end.column - property.key.loc.start.column + modifierLength(property)); | ||
} | ||
@@ -134,2 +128,11 @@ for (const property of group) { | ||
} | ||
function modifierLength(node) { | ||
return ((node.optional ? "?".length : 0) + | ||
(node.computed ? "[]".length : 0) + | ||
(node.static ? "static ".length : 0) + | ||
(node.accessibility ? node.accessibility.length + 1 : 0) + | ||
(node.override ? "override ".length : 0) + | ||
(node.declare ? "declare ".length : 0) + | ||
(node.readonly ? "readonly ".length : 0)); | ||
} | ||
//# sourceMappingURL=printer.js.map |
{ | ||
"name": "@huggingface/prettier-plugin-vertical-align", | ||
"packageManager": "pnpm@9.11.0", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "", | ||
@@ -6,0 +6,0 @@ "scripts": { |
@@ -39,7 +39,3 @@ import type { AstPath, Printer } from "prettier"; | ||
const keyLength = node[keyLengthSymbol]; | ||
const addedLength = | ||
keyLength - | ||
(node.key.loc.end.column - node.key.loc.start.column) - | ||
(node.optional ? 1 : 0) - | ||
(node.computed ? 2 : 0); | ||
const addedLength = keyLength - (node.key.loc.end.column - node.key.loc.start.column) - modifierLength(node); | ||
@@ -111,6 +107,3 @@ // console.log("keyLength", keyLength); | ||
keyLength, | ||
property.key.loc.end.column - | ||
property.key.loc.start.column + | ||
(property.optional ? 1 : 0) + | ||
(property.computed ? 2 : 0), | ||
property.key.loc.end.column - property.key.loc.start.column + modifierLength(property), | ||
); | ||
@@ -165,3 +158,3 @@ } | ||
} | ||
if (node.type === "TSPropertySignature" || node.type === "PropertyDefinition") { | ||
if (node.type === "TSPropertySignature" || node.type === "PropertyDefinition") { | ||
return "typeAnnotation"; | ||
@@ -171,1 +164,13 @@ } | ||
} | ||
function modifierLength(node: AstPath["node"]) { | ||
return ( | ||
(node.optional ? "?".length : 0) + | ||
(node.computed ? "[]".length : 0) + | ||
(node.static ? "static ".length : 0) + | ||
(node.accessibility ? node.accessibility.length + 1 : 0) + | ||
(node.override ? "override ".length : 0) + | ||
(node.declare ? "declare ".length : 0) + | ||
(node.readonly ? "readonly ".length : 0) | ||
); | ||
} |
Sorry, the diff of this file is not supported yet
23622
14
413