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.
Files changed (2) hide show
  1. package/dist/index.js +8 -0
  2. 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
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prettier-plugin-bootstrap",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "A Prettier plugin for automatic Bootstrap class sorting",
5
5
  "license": "MIT",
6
6
  "type": "module",