@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.
- package/lib/diagnostic.d.ts +9 -20
- package/lib/diagnostic.js +4 -1
- package/package.json +2 -2
- package/src/diagnostic.js +22 -28
package/lib/diagnostic.d.ts
CHANGED
|
@@ -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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
144
|
-
|
|
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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parcel/diagnostic",
|
|
3
|
-
"version": "2.0.0-
|
|
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": "
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
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 */
|