@parcel/diagnostic 2.0.0-canary.1543 → 2.0.0-dev.1425

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.
@@ -1,9 +1,9 @@
1
1
  import type { Mapping } from "@mischnic/json-sourcemap";
2
2
  /** These positions are 1-based (so <code>1</code> is the first line/column) */
3
- export type DiagnosticHighlightLocation = {
3
+ export interface DiagnosticHighlightLocation {
4
4
  readonly line: number;
5
5
  readonly column: number;
6
- };
6
+ }
7
7
  export type DiagnosticSeverity = "error" | "warn" | "info";
8
8
  /**
9
9
  * Note: A tab character is always counted as a single character
@@ -123,27 +123,16 @@ export declare function getJSONHighlightLocation(pos: Mapping, type?: ("key" | n
123
123
  };
124
124
  /** Result is 1-based, but end is exclusive */
125
125
  export declare function getJSONSourceLocation(pos: Mapping, type?: ("key" | null | undefined) | "value"): {
126
- start: {
127
- readonly line: number;
128
- readonly column: number;
129
- };
130
- end: {
131
- readonly line: number;
132
- readonly column: number;
133
- };
126
+ start: DiagnosticHighlightLocation;
127
+ end: DiagnosticHighlightLocation;
134
128
  };
135
- export declare function convertSourceLocationToHighlight<Location extends {
129
+ interface Location {
136
130
  /** 1-based, inclusive */
137
- readonly start: {
138
- readonly line: number;
139
- readonly column: number;
140
- };
131
+ readonly start: DiagnosticHighlightLocation;
141
132
  /** 1-based, exclusive */
142
- readonly end: {
143
- readonly line: number;
144
- readonly column: number;
145
- };
146
- }>({ start, end }: Location, message?: string): DiagnosticCodeHighlight;
133
+ readonly end: DiagnosticHighlightLocation;
134
+ }
135
+ export declare function convertSourceLocationToHighlight({ start, end }: Location, message?: string): DiagnosticCodeHighlight;
147
136
  /** Sanitizes object keys before using them as <code>key</code> in generateJSONCodeHighlights */
148
137
  export declare function encodeJSONKeyComponent(component: string): string;
149
138
  export declare function escapeMarkdown(s: string): string;
package/lib/diagnostic.js CHANGED
@@ -224,7 +224,10 @@ function convertSourceLocationToHighlight({
224
224
  }, message) {
225
225
  return {
226
226
  message,
227
- start,
227
+ start: {
228
+ line: start.line,
229
+ column: start.column
230
+ },
228
231
  end: {
229
232
  line: end.line,
230
233
  column: end.column - 1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parcel/diagnostic",
3
- "version": "2.0.0-canary.1543+ec3f4a5fb",
3
+ "version": "2.0.0-dev.1425+8b1749694",
4
4
  "license": "MIT",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -27,5 +27,5 @@
27
27
  "@mischnic/json-sourcemap": "^0.1.0",
28
28
  "nullthrows": "^1.1.1"
29
29
  },
30
- "gitHead": "ec3f4a5fbfad05bd3b645e02b90ff9c5abc738dc"
30
+ "gitHead": "8b1749694c0ef79cefdacad40bb90c869a93993a"
31
31
  }
package/src/diagnostic.js CHANGED
@@ -5,10 +5,10 @@ import nullthrows from 'nullthrows';
5
5
  import {parse, type Mapping} from '@mischnic/json-sourcemap';
6
6
 
7
7
  /** These positions are 1-based (so <code>1</code> is the first line/column) */
8
- export type DiagnosticHighlightLocation = {|
9
- +line: number,
10
- +column: number,
11
- |};
8
+ export interface DiagnosticHighlightLocation {
9
+ +line: number;
10
+ +column: number;
11
+ }
12
12
 
13
13
  export type DiagnosticSeverity = 'error' | 'warn' | 'info';
14
14
 
@@ -291,35 +291,29 @@ export function getJSONSourceLocation(
291
291
  pos: Mapping,
292
292
  type?: ?'key' | 'value',
293
293
  ): {|
294
- start: {|
295
- +line: number,
296
- +column: number,
297
- |},
298
- end: {|
299
- +line: number,
300
- +column: number,
301
- |},
294
+ start: DiagnosticHighlightLocation,
295
+ end: DiagnosticHighlightLocation,
302
296
  |} {
303
297
  let v = getJSONHighlightLocation(pos, type);
304
298
  return {start: v.start, end: {line: v.end.line, column: v.end.column + 1}};
305
299
  }
306
300
 
307
- export function convertSourceLocationToHighlight<
308
- Location: {
309
- /** 1-based, inclusive */
310
- +start: {|
311
- +line: number,
312
- +column: number,
313
- |},
314
- /** 1-based, exclusive */
315
- +end: {|
316
- +line: number,
317
- +column: number,
318
- |},
319
- ...
320
- },
321
- >({start, end}: Location, message?: string): DiagnosticCodeHighlight {
322
- return {message, start, end: {line: end.line, column: end.column - 1}};
301
+ interface Location {
302
+ /** 1-based, inclusive */
303
+ +start: DiagnosticHighlightLocation;
304
+ /** 1-based, exclusive */
305
+ +end: DiagnosticHighlightLocation;
306
+ }
307
+
308
+ export function convertSourceLocationToHighlight(
309
+ {start, end}: Location,
310
+ message?: string,
311
+ ): DiagnosticCodeHighlight {
312
+ return {
313
+ message,
314
+ start: {line: start.line, column: start.column},
315
+ end: {line: end.line, column: end.column - 1},
316
+ };
323
317
  }
324
318
 
325
319
  /** Sanitizes object keys before using them as <code>key</code> in generateJSONCodeHighlights */