@parcel/diagnostic 2.0.0-rc.0 → 2.1.1

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.
@@ -56,6 +56,8 @@ export declare type Diagnostic = {
56
56
  hints?: Array<string>;
57
57
  /** @private */
58
58
  skipFormatting?: boolean;
59
+ /** A URL to documentation to learn more about the diagnostic. */
60
+ documentationURL?: string;
59
61
  };
60
62
  export interface PrintableError extends Error {
61
63
  fileName?: string;
package/lib/diagnostic.js CHANGED
@@ -112,7 +112,7 @@ function errorToDiagnostic(error, defaultValues) {
112
112
  origin: (_defaultValues$origin2 = defaultValues === null || defaultValues === void 0 ? void 0 : defaultValues.origin) !== null && _defaultValues$origin2 !== void 0 ? _defaultValues$origin2 : 'Error',
113
113
  message: escapeMarkdown(error.message),
114
114
  name: error.name,
115
- stack: (_ref4 = (_error$highlightedCod = error.highlightedCodeFrame) !== null && _error$highlightedCod !== void 0 ? _error$highlightedCod : error.codeFrame) !== null && _ref4 !== void 0 ? _ref4 : error.stack,
115
+ stack: codeFrames == null ? (_ref4 = (_error$highlightedCod = error.highlightedCodeFrame) !== null && _error$highlightedCod !== void 0 ? _error$highlightedCod : error.codeFrame) !== null && _ref4 !== void 0 ? _ref4 : error.stack : undefined,
116
116
  codeFrames
117
117
  }];
118
118
  }
@@ -231,10 +231,24 @@ function md(strings, ...params) {
231
231
  let result = [];
232
232
 
233
233
  for (let i = 0; i < params.length; i++) {
234
- var _param$mdVerbatim;
235
-
234
+ result.push(strings[i]);
236
235
  let param = params[i];
237
- result.push(strings[i], (_param$mdVerbatim = param === null || param === void 0 ? void 0 : param[mdVerbatim]) !== null && _param$mdVerbatim !== void 0 ? _param$mdVerbatim : escapeMarkdown(`${param}`));
236
+
237
+ if (Array.isArray(param)) {
238
+ for (let j = 0; j < param.length; j++) {
239
+ var _param$j$mdVerbatim, _param$j;
240
+
241
+ result.push((_param$j$mdVerbatim = (_param$j = param[j]) === null || _param$j === void 0 ? void 0 : _param$j[mdVerbatim]) !== null && _param$j$mdVerbatim !== void 0 ? _param$j$mdVerbatim : escapeMarkdown(`${param[j]}`));
242
+
243
+ if (j < param.length - 1) {
244
+ result.push(', ');
245
+ }
246
+ }
247
+ } else {
248
+ var _param$mdVerbatim;
249
+
250
+ result.push((_param$mdVerbatim = param === null || param === void 0 ? void 0 : param[mdVerbatim]) !== null && _param$mdVerbatim !== void 0 ? _param$mdVerbatim : escapeMarkdown(`${param}`));
251
+ }
238
252
  }
239
253
 
240
254
  return result.join('') + strings[strings.length - 1];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parcel/diagnostic",
3
- "version": "2.0.0-rc.0",
3
+ "version": "2.1.1",
4
4
  "license": "MIT",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -27,5 +27,5 @@
27
27
  "json-source-map": "^0.6.1",
28
28
  "nullthrows": "^1.1.1"
29
29
  },
30
- "gitHead": "8fc248f1f8eeb4428f7abd768bd23111451b1903"
30
+ "gitHead": "f53ffe772a8259d94ca2937d02fde149454112f3"
31
31
  }
package/src/diagnostic.js CHANGED
@@ -69,6 +69,9 @@ export type Diagnostic = {|
69
69
 
70
70
  /** @private */
71
71
  skipFormatting?: boolean,
72
+
73
+ /** A URL to documentation to learn more about the diagnostic. */
74
+ documentationURL?: string,
72
75
  |};
73
76
 
74
77
  // This type should represent all error formats Parcel can encounter...
@@ -174,7 +177,10 @@ export function errorToDiagnostic(
174
177
  origin: defaultValues?.origin ?? 'Error',
175
178
  message: escapeMarkdown(error.message),
176
179
  name: error.name,
177
- stack: error.highlightedCodeFrame ?? error.codeFrame ?? error.stack,
180
+ stack:
181
+ codeFrames == null
182
+ ? error.highlightedCodeFrame ?? error.codeFrame ?? error.stack
183
+ : undefined,
178
184
  codeFrames,
179
185
  },
180
186
  ];
@@ -293,28 +299,39 @@ export function md(
293
299
  ): string {
294
300
  let result = [];
295
301
  for (let i = 0; i < params.length; i++) {
302
+ result.push(strings[i]);
303
+
296
304
  let param = params[i];
297
- result.push(strings[i], param?.[mdVerbatim] ?? escapeMarkdown(`${param}`));
305
+ if (Array.isArray(param)) {
306
+ for (let j = 0; j < param.length; j++) {
307
+ result.push(param[j]?.[mdVerbatim] ?? escapeMarkdown(`${param[j]}`));
308
+ if (j < param.length - 1) {
309
+ result.push(', ');
310
+ }
311
+ }
312
+ } else {
313
+ result.push(param?.[mdVerbatim] ?? escapeMarkdown(`${param}`));
314
+ }
298
315
  }
299
316
  return result.join('') + strings[strings.length - 1];
300
317
  }
301
318
 
302
- md.bold = function(s: TemplateInput): TemplateInput {
319
+ md.bold = function (s: TemplateInput): TemplateInput {
303
320
  // $FlowFixMe[invalid-computed-prop]
304
321
  return {[mdVerbatim]: '**' + escapeMarkdown(`${s}`) + '**'};
305
322
  };
306
323
 
307
- md.italic = function(s: TemplateInput): TemplateInput {
324
+ md.italic = function (s: TemplateInput): TemplateInput {
308
325
  // $FlowFixMe[invalid-computed-prop]
309
326
  return {[mdVerbatim]: '_' + escapeMarkdown(`${s}`) + '_'};
310
327
  };
311
328
 
312
- md.underline = function(s: TemplateInput): TemplateInput {
329
+ md.underline = function (s: TemplateInput): TemplateInput {
313
330
  // $FlowFixMe[invalid-computed-prop]
314
331
  return {[mdVerbatim]: '__' + escapeMarkdown(`${s}`) + '__'};
315
332
  };
316
333
 
317
- md.strikethrough = function(s: TemplateInput): TemplateInput {
334
+ md.strikethrough = function (s: TemplateInput): TemplateInput {
318
335
  // $FlowFixMe[invalid-computed-prop]
319
336
  return {[mdVerbatim]: '~~' + escapeMarkdown(`${s}`) + '~~'};
320
337
  };