@glion/preset-lint-recommended 0.15.1 → 0.15.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 +31 -55
- package/package.json +16 -12
package/README.md
CHANGED
|
@@ -1,81 +1,57 @@
|
|
|
1
1
|
# @glion/preset-lint-recommended
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Preset bundling the core (version-independent) HL7v2 lint rules.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## What it does
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
This package provides a **recommended set of HL7v2 linting rules**. It ensures a consistent baseline of message quality checks when processing HL7v2 messages with [`unified`][github-unified] and [`@glion/parser`][github-hl7v2-parser].
|
|
10
|
-
|
|
11
|
-
Think of it like ESLint’s "recommended" rules, but for HL7v2.
|
|
12
|
-
|
|
13
|
-
## When should I use this?
|
|
14
|
-
|
|
15
|
-
Use this preset if you:
|
|
16
|
-
|
|
17
|
-
- Want a **sensible default** for linting HL7v2 messages
|
|
18
|
-
- Need a **starting point** for building custom HL7v2 lint configurations
|
|
19
|
-
- Are using the [`hl7v2-parser`][github-hl7v2-parser] and want to catch common mistakes
|
|
20
|
-
|
|
21
|
-
It is intended as a **minimum recommended set**. You can extend or override rules in your own configs.
|
|
7
|
+
This preset wires the core HL7v2 lint rules into a single `unified` plugin. One `.use(...)` call enables structural checks that apply to every HL7v2 message regardless of version or profile: segment header shape, message header presence, version range, and trailing field hygiene.
|
|
22
8
|
|
|
23
9
|
## Install
|
|
24
10
|
|
|
25
|
-
```
|
|
11
|
+
```bash
|
|
26
12
|
npm install @glion/preset-lint-recommended
|
|
27
13
|
```
|
|
28
14
|
|
|
29
15
|
## Use
|
|
30
16
|
|
|
31
|
-
```
|
|
17
|
+
```ts
|
|
18
|
+
import hl7v2PresetLintRecommended from "@glion/preset-lint-recommended";
|
|
19
|
+
import { hl7v2Parser } from "@glion/parser";
|
|
32
20
|
import { unified } from "unified";
|
|
33
|
-
import parse from "@glion/parser";
|
|
34
|
-
import lint from "@glion/lint";
|
|
35
|
-
import recommended from "@glion/preset-lint-recommended";
|
|
36
|
-
|
|
37
|
-
const file = await unified()
|
|
38
|
-
.use(parse)
|
|
39
|
-
.use(lint)
|
|
40
|
-
.use(recommended)
|
|
41
|
-
.process("MSH|^~\\&|...");
|
|
42
|
-
```
|
|
43
21
|
|
|
44
|
-
|
|
22
|
+
const processor = unified().use(hl7v2Parser).use(hl7v2PresetLintRecommended);
|
|
45
23
|
|
|
46
|
-
|
|
47
|
-
|
|
24
|
+
const file = await processor.process(
|
|
25
|
+
"MSH|^~\\&|SENDER||RECEIVER||20250601120000||ADT^A01|MSG00001|P|2.5"
|
|
26
|
+
);
|
|
48
27
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
## Security
|
|
28
|
+
for (const message of file.messages) {
|
|
29
|
+
console.log(`${message.ruleId}: ${message.reason}`);
|
|
30
|
+
}
|
|
31
|
+
```
|
|
54
32
|
|
|
55
|
-
|
|
33
|
+
## API
|
|
56
34
|
|
|
57
|
-
|
|
35
|
+
### `unified().use(hl7v2PresetLintRecommended)`
|
|
58
36
|
|
|
59
|
-
|
|
37
|
+
Default export is a `Preset` (unified's `{ plugins: [...] }` shape). No options — to configure individual rules, compose them directly from their own packages instead of using the preset.
|
|
60
38
|
|
|
61
|
-
|
|
62
|
-
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
|
|
63
|
-
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
|
|
64
|
-
4. Push to the branch (`git push origin feature/amazing-feature`)
|
|
65
|
-
5. Open a Pull Request
|
|
39
|
+
## What's bundled
|
|
66
40
|
|
|
67
|
-
|
|
41
|
+
The preset applies these rules in order. Three are configured at `error` severity; `no-trailing-empty-field` uses its default severity.
|
|
68
42
|
|
|
69
|
-
|
|
43
|
+
| Plugin | Purpose |
|
|
44
|
+
| ------------------------------------------------------------------------ | ---------------------------------------------------------------------------- |
|
|
45
|
+
| [`@glion/lint-segment-header-length`](../lint-segment-header-length) | Flags segment headers that are not exactly three characters. |
|
|
46
|
+
| [`@glion/lint-required-message-header`](../lint-required-message-header) | Flags messages whose first segment is not `MSH`. |
|
|
47
|
+
| [`@glion/lint-message-version`](../lint-message-version) | Flags `MSH-12` values outside the configured semver range. |
|
|
48
|
+
| [`@glion/lint-no-trailing-empty-field`](../lint-no-trailing-empty-field) | Flags segments that end with one or more empty fields (stray trailing `\|`). |
|
|
70
49
|
|
|
71
|
-
|
|
50
|
+
The companion `@glion/preset-lint-profile-recommended` covers profile-driven, version-specific lint rules; use both together for comprehensive validation.
|
|
72
51
|
|
|
73
|
-
|
|
52
|
+
## Part of Glion
|
|
74
53
|
|
|
75
|
-
|
|
54
|
+
`@glion/preset-lint-recommended` is part of **[Glion]**, the application framework for HL7v2. See the [Glion README] for the full package catalog and architecture.
|
|
76
55
|
|
|
77
|
-
[
|
|
78
|
-
[
|
|
79
|
-
[github-contributing]: https://github.com/rethinkhealth/glion/blob/main/CONTRIBUTING.md
|
|
80
|
-
[github-unified]: https://github.com/unifiedjs/unified
|
|
81
|
-
[github-hl7v2-parser]: https://github.com/rethinkhealth/glion/tree/main/packages/hl7v2-parser
|
|
56
|
+
[Glion]: https://github.com/rethinkhealth/glion#readme
|
|
57
|
+
[Glion README]: https://github.com/rethinkhealth/glion#readme
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@glion/preset-lint-recommended",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.3",
|
|
4
4
|
"description": "hl7v2-lint preset with recommended rules",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"definition",
|
|
@@ -38,26 +38,28 @@
|
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"unified": "11.0.5",
|
|
40
40
|
"unified-lint-rule": "3.0.1",
|
|
41
|
-
"@glion/lint-message-version": "0.15.
|
|
42
|
-
"@glion/lint-
|
|
43
|
-
"@glion/lint-
|
|
44
|
-
"@glion/lint-segment-header-length": "0.15.
|
|
41
|
+
"@glion/lint-message-version": "0.15.3",
|
|
42
|
+
"@glion/lint-required-message-header": "0.15.3",
|
|
43
|
+
"@glion/lint-no-trailing-empty-field": "0.15.3",
|
|
44
|
+
"@glion/lint-segment-header-length": "0.15.3"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@types/node": "^25.5.0",
|
|
48
48
|
"@types/unist": "^3.0.3",
|
|
49
49
|
"@vitest/coverage-v8": "4.1.2",
|
|
50
|
+
"publint": "0.3.18",
|
|
50
51
|
"tsdown": "0.21.7",
|
|
51
52
|
"typescript": "^5.9.3",
|
|
52
53
|
"vfile": "^6.0.3",
|
|
53
54
|
"vfile-reporter": "^8.1.1",
|
|
54
55
|
"vitest": "4.1.2",
|
|
55
|
-
"@glion/
|
|
56
|
-
"@glion/
|
|
57
|
-
"@glion/
|
|
58
|
-
"@glion/
|
|
59
|
-
"@glion/
|
|
60
|
-
"@glion/
|
|
56
|
+
"@glion/builder": "0.15.3",
|
|
57
|
+
"@glion/ast": "0.15.3",
|
|
58
|
+
"@glion/check-readme": "0.15.3",
|
|
59
|
+
"@glion/jsonify": "0.15.3",
|
|
60
|
+
"@glion/parser": "0.15.3",
|
|
61
|
+
"@glion/testing": "0.15.3",
|
|
62
|
+
"@glion/tsconfig": "0.15.3"
|
|
61
63
|
},
|
|
62
64
|
"engines": {
|
|
63
65
|
"node": ">=18"
|
|
@@ -66,8 +68,10 @@
|
|
|
66
68
|
"scripts": {
|
|
67
69
|
"build": "tsdown && tsc --emitDeclarationOnly",
|
|
68
70
|
"check-types": "tsc --noEmit",
|
|
71
|
+
"check:readme": "glion-check-readme",
|
|
69
72
|
"test": "vitest run",
|
|
70
73
|
"test:coverage": "vitest run --coverage",
|
|
71
|
-
"test:watch": "vitest"
|
|
74
|
+
"test:watch": "vitest",
|
|
75
|
+
"publint": "publint --strict"
|
|
72
76
|
}
|
|
73
77
|
}
|