@noldova/context.diagnostics 0.0.1 → 0.0.3
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/README.md +34 -0
- package/package.json +3 -3
package/README.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# noldova.context.diagnostics
|
|
2
|
+
|
|
3
|
+
The diagnostic model CONTEXT parsers and tools report through: codes in an
|
|
4
|
+
authority's namespace (`TS` or `CTX`), categories, structured message chains,
|
|
5
|
+
source locations, related information and tags. A `Diagnostic` is complete and
|
|
6
|
+
immutable once created; reusable `DiagnosticTemplate`s create occurrences from a
|
|
7
|
+
catalog.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @noldova/context.diagnostics
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Use
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { DiagnosticAuthority, DiagnosticCategory, DiagnosticCode, DiagnosticLocation, DiagnosticTemplate } from "@noldova/context.diagnostics";
|
|
19
|
+
|
|
20
|
+
const code = new DiagnosticCode(DiagnosticAuthority.typeScript, 2304);
|
|
21
|
+
const template = new DiagnosticTemplate(code, DiagnosticCategory.Error, "Cannot find name '{0}'.");
|
|
22
|
+
|
|
23
|
+
const diagnostic = template.create(new DiagnosticLocation("example.ts", 12, 5), ["value"]);
|
|
24
|
+
diagnostic.code.displayText; // "TS2304"
|
|
25
|
+
diagnostic.message.text; // "Cannot find name 'value'."
|
|
26
|
+
diagnostic.location?.start; // 12
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Locations are UTF-16 offsets and lengths in a source. The declaration file
|
|
30
|
+
`api/index.d.ts` documents every member with its contract and examples.
|
|
31
|
+
|
|
32
|
+
## License
|
|
33
|
+
|
|
34
|
+
MIT; see `LICENSE`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@noldova/context.diagnostics",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "api/index.js",
|
|
6
6
|
"types": "api/index.d.ts",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"registry": "https://registry.npmjs.org/"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@noldova/context.core": "0.0.
|
|
23
|
-
"@noldova/context.exceptions": "0.0.
|
|
22
|
+
"@noldova/context.core": "0.0.3",
|
|
23
|
+
"@noldova/context.exceptions": "0.0.3"
|
|
24
24
|
}
|
|
25
25
|
}
|