prettier-plugin-bootstrap 0.1.1 → 0.1.2
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 +8 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -378,6 +378,12 @@ const options = {
|
|
|
378
378
|
function createParserWrapper(parserName, processAst, astFormat) {
|
|
379
379
|
const wrapper = {
|
|
380
380
|
astFormat,
|
|
381
|
+
locStart(node) {
|
|
382
|
+
return node.range?.[0] ?? node.start ?? node.sourceSpan?.start?.offset ?? 0;
|
|
383
|
+
},
|
|
384
|
+
locEnd(node) {
|
|
385
|
+
return node.range?.[1] ?? node.end ?? node.sourceSpan?.end?.offset ?? 0;
|
|
386
|
+
},
|
|
381
387
|
async parse(text, options) {
|
|
382
388
|
const plugins = options.plugins || [];
|
|
383
389
|
let originalParser = null;
|
|
@@ -393,6 +399,8 @@ function createParserWrapper(parserName, processAst, astFormat) {
|
|
|
393
399
|
}
|
|
394
400
|
}
|
|
395
401
|
if (!originalParser) throw new Error(`prettier-plugin-bootstrap: could not find the "${parserName}" parser. Make sure Prettier and the relevant parser plugin are installed.`);
|
|
402
|
+
if (originalParser.locStart) wrapper.locStart = originalParser.locStart;
|
|
403
|
+
if (originalParser.locEnd) wrapper.locEnd = originalParser.locEnd;
|
|
396
404
|
return processAst(await originalParser.parse(text, options), [...DEFAULT_ATTRIBUTES, ...options.bootstrapAttributes || []]);
|
|
397
405
|
}
|
|
398
406
|
};
|