prettier-plugin-bootstrap 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +16 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -327,8 +327,14 @@ function processHtmlAst(ast, targetAttrs) {
|
|
|
327
327
|
if (node.attributes && Array.isArray(node.attributes)) for (const attr of node.attributes) {
|
|
328
328
|
const name = attr.name || attr.key && attr.key.value;
|
|
329
329
|
if (targetAttrs.includes(name) && attr.value) {
|
|
330
|
-
if (typeof attr.value === "string")
|
|
331
|
-
|
|
330
|
+
if (typeof attr.value === "string") {
|
|
331
|
+
if (attr.kind && attr.kind !== "quoted") continue;
|
|
332
|
+
if (attr.value.includes("${")) continue;
|
|
333
|
+
attr.value = sortClassString(attr.value);
|
|
334
|
+
} else if (attr.value && typeof attr.value.value === "string") {
|
|
335
|
+
if (attr.value.value.includes("${")) continue;
|
|
336
|
+
attr.value.value = sortClassString(attr.value.value);
|
|
337
|
+
}
|
|
332
338
|
}
|
|
333
339
|
}
|
|
334
340
|
});
|
|
@@ -378,6 +384,12 @@ const options = {
|
|
|
378
384
|
function createParserWrapper(parserName, processAst, astFormat) {
|
|
379
385
|
const wrapper = {
|
|
380
386
|
astFormat,
|
|
387
|
+
locStart(node) {
|
|
388
|
+
return node.range?.[0] ?? node.start ?? node.sourceSpan?.start?.offset ?? 0;
|
|
389
|
+
},
|
|
390
|
+
locEnd(node) {
|
|
391
|
+
return node.range?.[1] ?? node.end ?? node.sourceSpan?.end?.offset ?? 0;
|
|
392
|
+
},
|
|
381
393
|
async parse(text, options) {
|
|
382
394
|
const plugins = options.plugins || [];
|
|
383
395
|
let originalParser = null;
|
|
@@ -393,6 +405,8 @@ function createParserWrapper(parserName, processAst, astFormat) {
|
|
|
393
405
|
}
|
|
394
406
|
}
|
|
395
407
|
if (!originalParser) throw new Error(`prettier-plugin-bootstrap: could not find the "${parserName}" parser. Make sure Prettier and the relevant parser plugin are installed.`);
|
|
408
|
+
if (originalParser.locStart) wrapper.locStart = originalParser.locStart;
|
|
409
|
+
if (originalParser.locEnd) wrapper.locEnd = originalParser.locEnd;
|
|
396
410
|
return processAst(await originalParser.parse(text, options), [...DEFAULT_ATTRIBUTES, ...options.bootstrapAttributes || []]);
|
|
397
411
|
}
|
|
398
412
|
};
|