@huggingface/prettier-plugin-vertical-align
Advanced tools
Comparing version 0.0.4 to 0.0.5
import prettier from "prettier"; | ||
// import { inspect } from "node:util"; | ||
import { inspect } from "node:util"; | ||
const { doc } = prettier; | ||
@@ -15,9 +15,11 @@ import { getOriginalPrinter } from "./original-printer.js"; | ||
// } | ||
// if (node.type === "Program") { | ||
// console.log("node", inspect(path, {depth: 10})); | ||
// console.log(options); | ||
// } | ||
if (node.type === "Program") { | ||
console.log("node", inspect(node.body, { depth: 10 })); | ||
} | ||
if (node[keyLengthSymbol]) { | ||
const keyLength = node[keyLengthSymbol]; | ||
const addedLength = keyLength - (node.key.loc.end.column - node.key.loc.start.column) - (node.optional ? 1 : 0); | ||
const addedLength = keyLength - | ||
(node.key.loc.end.column - node.key.loc.start.column) - | ||
(node.optional ? 1 : 0) - | ||
(node.computed ? 2 : 0); | ||
// console.log("keyLength", keyLength); | ||
@@ -27,3 +29,5 @@ switch (node.type) { | ||
return group([ | ||
node.computed ? "[" : "", | ||
path.call(_print, "key"), | ||
node.computed ? "]" : "", | ||
":" + " ".repeat(addedLength + 1), | ||
@@ -52,3 +56,6 @@ path.call(_print, valueField(node)), | ||
for (const property of properties) { | ||
keyLength = Math.max(keyLength, property.key.loc.end.column - property.key.loc.start.column + (property.optional ? 1 : 0)); | ||
keyLength = Math.max(keyLength, property.key.loc.end.column - | ||
property.key.loc.start.column + | ||
(property.optional ? 1 : 0) + | ||
(property.computed ? 2 : 0)); | ||
} | ||
@@ -55,0 +62,0 @@ for (const property of properties) { |
{ | ||
"name": "@huggingface/prettier-plugin-vertical-align", | ||
"packageManager": "pnpm@9.11.0", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "", | ||
@@ -6,0 +6,0 @@ "scripts": { |
@@ -24,4 +24,3 @@ import type { AstPath, Printer } from "prettier"; | ||
// if (node.type === "Program") { | ||
// console.log("node", inspect(path, {depth: 10})); | ||
// console.log(options); | ||
// console.log("node", inspect(node.body, { depth: 10 })); | ||
// } | ||
@@ -31,3 +30,7 @@ | ||
const keyLength = node[keyLengthSymbol]; | ||
const addedLength = keyLength - (node.key.loc.end.column - node.key.loc.start.column) - (node.optional ? 1 : 0); | ||
const addedLength = | ||
keyLength - | ||
(node.key.loc.end.column - node.key.loc.start.column) - | ||
(node.optional ? 1 : 0) - | ||
(node.computed ? 2 : 0); | ||
@@ -39,3 +42,5 @@ // console.log("keyLength", keyLength); | ||
return group([ | ||
node.computed ? "[" : "", | ||
path.call(_print, "key"), | ||
node.computed ? "]" : "", | ||
":" + " ".repeat(addedLength + 1), | ||
@@ -69,3 +74,6 @@ path.call(_print, valueField(node)), | ||
keyLength, | ||
property.key.loc.end.column - property.key.loc.start.column + (property.optional ? 1 : 0), | ||
property.key.loc.end.column - | ||
property.key.loc.start.column + | ||
(property.optional ? 1 : 0) + | ||
(property.computed ? 2 : 0), | ||
); | ||
@@ -72,0 +80,0 @@ } |
Sorry, the diff of this file is not supported yet
16001
285