@glion/lint-message-version 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.
Files changed (2) hide show
  1. package/README.md +65 -42
  2. package/package.json +12 -8
package/README.md CHANGED
@@ -1,80 +1,103 @@
1
- ## @glion/lint-message-version
1
+ # @glion/lint-message-version
2
2
 
3
- > Lint rule that checks an HL7v2 message version (MSH-12) satisfies a version expression.
3
+ Lint rule that checks an HL7v2 message's `MSH-12` version satisfies a semver range expression.
4
4
 
5
- ### Installation
5
+ ## What it does
6
+
7
+ Reads `MSH-12.1` from the tree and evaluates it against the configured `expression` using `@glion/util-semver`. Reports a message when `MSH-12` is missing or empty, when the value is not a valid semver-like version, or when it falls outside the allowed range. The default expression (`"<3.0.0 >=2.3"`) accepts HL7v2 versions 2.3 through 2.9 and excludes future v3 values.
8
+
9
+ ## Install
6
10
 
7
11
  ```bash
8
- pnpm add -D @glion/lint-message-version
12
+ npm install @glion/lint-message-version
9
13
  ```
10
14
 
11
- ### Usage
15
+ ## Use
12
16
 
13
- ```typescript
14
- import { unified } from "unified";
17
+ ```ts
15
18
  import { hl7v2Parser } from "@glion/parser";
16
19
  import hl7v2LintMessageVersion from "@glion/lint-message-version";
20
+ import { unified } from "unified";
21
+ import { reporter } from "vfile-reporter";
17
22
 
18
- const message = `MSH|^~\\&|SENDER|FAC|RCVR|FAC|20250101010101||ADT^A01^ADT_A01|MSG00001|P|2.5`;
23
+ const message =
24
+ "MSH|^~\\&|SENDER|FAC|RCVR|FAC|20250101010101||ADT^A01^ADT_A01|MSG00001|P|2.5";
19
25
 
20
- const processor = unified()
26
+ const file = await unified()
21
27
  .use(hl7v2Parser)
22
- // default expression is "<3.0.0 >=2.3"
23
- .use(hl7v2LintMessageVersion, { expression: "<3.0.0 >=2.3" });
28
+ .use(hl7v2LintMessageVersion, { expression: "<3.0.0 >=2.3" })
29
+ .process(message);
24
30
 
25
- await processor.process(message);
31
+ console.error(reporter([file]));
26
32
  ```
27
33
 
28
- ### Options
34
+ ## API
29
35
 
30
- - **expression**: string (optional)
31
- - A semver-like range expression evaluated against `MSH-12`.
32
- - Defaults to `"<3.0.0 >=2.3"`.
36
+ ### `unified().use(hl7v2LintMessageVersion[, options])`
33
37
 
34
- Expressions are parsed and evaluated by `@glion/util-semver`.
38
+ A `unified` lint rule plugin.
35
39
 
36
- ### Examples
40
+ ```ts
41
+ import type { Plugin } from "unified";
42
+ import type { Root } from "@glion/ast";
37
43
 
38
- - **✅ Valid within default range** (default `"<3.0.0 >=2.3"`)
44
+ export interface MessageVersionLintOptions {
45
+ /** Semver range expression to evaluate against `MSH-12.1`. Default: "<3.0.0 >=2.3". */
46
+ expression: string;
47
+ }
39
48
 
49
+ declare const hl7v2LintMessageVersion: Plugin<
50
+ [MessageVersionLintOptions?],
51
+ Root
52
+ >;
53
+ export default hl7v2LintMessageVersion;
40
54
  ```
55
+
56
+ Expressions are parsed and evaluated by `@glion/util-semver`.
57
+
58
+ ## What it checks
59
+
60
+ The value of `MSH-12.1` must be present and must satisfy the configured semver expression.
61
+
62
+ ### Valid
63
+
64
+ `MSH-12` is `2.5`, within the default range `<3.0.0 >=2.3`:
65
+
66
+ ```hl7
41
67
  MSH|^~\&|SENDER|FAC|RCVR|FAC|20250101010101||ADT^A01^ADT_A01|MSG00001|P|2.5
42
68
  ```
43
69
 
44
- - **❌ Invalid: below minimum (2.3)**
70
+ ### Invalid
45
71
 
46
- ```
72
+ `MSH-12` is `2.2`, below the default minimum:
73
+
74
+ ```hl7
47
75
  MSH|^~\&|SENDER|FAC|RCVR|FAC|20250101010101||ADT^A01^ADT_A01|MSG00001|P|2.2
48
76
  ```
49
77
 
50
- - **✅ Custom expression allowing 2.2**
78
+ Reported message:
51
79
 
52
- ```typescript
53
- unified()
54
- .use(hl7v2Parser)
55
- .use(hl7v2LintMessageVersion, { expression: "<3.0.0 >=2.2" });
80
+ ```
81
+ MSH-12 (version) field value '2.2' does not satisfy expression '<3.0.0 >=2.3'
56
82
  ```
57
83
 
58
- ## Contributing
59
-
60
- We welcome contributions! Please see our [Contributing Guide][github-contributing] for more details.
84
+ `MSH-12` is missing:
61
85
 
62
- 1. Fork the repository
63
- 2. Create your feature branch (`git checkout -b feature/amazing-feature`)
64
- 3. Commit your changes (`git commit -m 'Add some amazing feature'`)
65
- 4. Push to the branch (`git push origin feature/amazing-feature`)
66
- 5. Open a Pull Request
86
+ ```
87
+ Required MSH-12 (version) field is missing or empty
88
+ ```
67
89
 
68
- ## Code of Conduct
90
+ `MSH-12` contains a value that cannot be parsed as semver:
69
91
 
70
- To ensure a welcoming and positive environment, we have a [Code of Conduct][github-code-of-conduct] that all contributors and participants are expected to adhere to.
92
+ ```
93
+ MSH-12 (version) field value 'abc' is not valid
94
+ ```
71
95
 
72
- ## License
96
+ Both the offending value and the configured expression are interpolated into the message. The rule reports at most one message per tree and exits as soon as the first problem is detected.
73
97
 
74
- Copyright 2025 Rethink Health, SUARL. All rights reserved.
98
+ ## Part of Glion
75
99
 
76
- This program is licensed to you under the terms of the [MIT License](https://opensource.org/licenses/MIT). This program is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the [LICENSE][github-license] file for details.
100
+ `@glion/lint-message-version` is part of **[Glion]**, the application framework for HL7v2. See the [Glion README] for the full package catalog and architecture.
77
101
 
78
- [github-code-of-conduct]: https://github.com/rethinkhealth/glion/blob/main/CODE_OF_CONDUCT.md
79
- [github-license]: https://github.com/rethinkhealth/glion/blob/main/LICENSE
80
- [github-contributing]: https://github.com/rethinkhealth/glion/blob/main/CONTRIBUTING.md
102
+ [Glion]: https://github.com/rethinkhealth/glion#readme
103
+ [Glion README]: https://github.com/rethinkhealth/glion#readme
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glion/lint-message-version",
3
- "version": "0.15.1",
3
+ "version": "0.15.3",
4
4
  "description": "hl7v2-lint rule to warn when message version is not supported",
5
5
  "keywords": [
6
6
  "definition",
@@ -39,22 +39,24 @@
39
39
  "dependencies": {
40
40
  "ensure-error": "5.0.0",
41
41
  "unified-lint-rule": "3.0.1",
42
- "@glion/util-semver": "0.15.1",
43
- "@glion/util-query": "0.15.1"
42
+ "@glion/util-query": "0.15.3",
43
+ "@glion/util-semver": "0.15.3"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@types/node": "^25.5.0",
47
47
  "@types/unist": "^3.0.3",
48
48
  "@vitest/coverage-v8": "4.1.2",
49
+ "publint": "0.3.18",
49
50
  "tsdown": "0.21.7",
50
51
  "typescript": "^5.9.3",
51
52
  "unified": "^11.0.5",
52
53
  "vfile": "^6.0.3",
53
54
  "vitest": "4.1.2",
54
- "@glion/ast": "0.15.1",
55
- "@glion/builder": "0.15.1",
56
- "@glion/tsconfig": "0.15.1",
57
- "@glion/testing": "0.15.1"
55
+ "@glion/ast": "0.15.3",
56
+ "@glion/builder": "0.15.3",
57
+ "@glion/testing": "0.15.3",
58
+ "@glion/check-readme": "0.15.3",
59
+ "@glion/tsconfig": "0.15.3"
58
60
  },
59
61
  "engines": {
60
62
  "node": ">=18"
@@ -63,8 +65,10 @@
63
65
  "scripts": {
64
66
  "build": "tsdown && tsc --emitDeclarationOnly",
65
67
  "check-types": "tsc --noEmit",
68
+ "check:readme": "glion-check-readme",
66
69
  "test": "vitest run",
67
70
  "test:coverage": "vitest run --coverage",
68
- "test:watch": "vitest"
71
+ "test:watch": "vitest",
72
+ "publint": "publint --strict"
69
73
  }
70
74
  }