@glion/preset-lint-recommended 0.14.1
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/LICENSE +21 -0
- package/README.md +81 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +36 -0
- package/dist/index.js.map +1 -0
- package/package.json +68 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Rethink Health
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# @glion/preset-lint-recommended
|
|
2
|
+
|
|
3
|
+
**Preset of linting rules for HL7v2**, built on top of the [`unified`][github-unified] ecosystem.
|
|
4
|
+
|
|
5
|
+
This preset is meant as a recommended baseline for catching common HL7v2 issues, such as segment structure, field length, and delimiter usage.
|
|
6
|
+
|
|
7
|
+
## What is this?
|
|
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.
|
|
22
|
+
|
|
23
|
+
## Install
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
npm install @glion/preset-lint-recommended
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Use
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
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
|
+
|
|
44
|
+
## Presets
|
|
45
|
+
|
|
46
|
+
This preset bundles a set of **recommended HL7v2 linting rules**.
|
|
47
|
+
Each rule has a default severity and may expose configuration options.
|
|
48
|
+
|
|
49
|
+
| Rule | Options | Default Severity |
|
|
50
|
+
| ------------------------------------------------------------------------- | ------- | ---------------- |
|
|
51
|
+
| [`hl7v2-lint-segment-header-length`](../hl7v2-lint-segment-header-length) | _none_ | `error` |
|
|
52
|
+
|
|
53
|
+
## Security
|
|
54
|
+
|
|
55
|
+
This plugin only transforms AST nodes and does not execute code. Ensure you trust the source of HL7v2 messages before processing.
|
|
56
|
+
|
|
57
|
+
## Contributing
|
|
58
|
+
|
|
59
|
+
We welcome contributions! Please see our [Contributing Guide][github-contributing] for more details.
|
|
60
|
+
|
|
61
|
+
1. Fork the repository
|
|
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
|
|
66
|
+
|
|
67
|
+
## Code of Conduct
|
|
68
|
+
|
|
69
|
+
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.
|
|
70
|
+
|
|
71
|
+
## License
|
|
72
|
+
|
|
73
|
+
Copyright 2025 Rethink Health, SUARL. All rights reserved.
|
|
74
|
+
|
|
75
|
+
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.
|
|
76
|
+
|
|
77
|
+
[github-code-of-conduct]: https://github.com/rethinkhealth/glion/blob/main/CODE_OF_CONDUCT.md
|
|
78
|
+
[github-license]: https://github.com/rethinkhealth/glion/blob/main/LICENSE
|
|
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
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Preset } from "unified";
|
|
2
|
+
/**
|
|
3
|
+
* Preset of hl7v2-lint rules to warn for likely problems.
|
|
4
|
+
*
|
|
5
|
+
* ## What is this?
|
|
6
|
+
*
|
|
7
|
+
* This package is a preset containing `hl7v2-lint` rules.
|
|
8
|
+
* Lint rules check hl7v2 basic rules.
|
|
9
|
+
*
|
|
10
|
+
* ## When should I use this?
|
|
11
|
+
*
|
|
12
|
+
* You can use this package to check that hl7v2 follows some best practices.
|
|
13
|
+
*
|
|
14
|
+
* ## API
|
|
15
|
+
*
|
|
16
|
+
* ### `unified().use(hl7v2PresetLintRecommended)`
|
|
17
|
+
*
|
|
18
|
+
* Check that hl7v2 follows some best practices.
|
|
19
|
+
*
|
|
20
|
+
* You can reconfigure rules in the preset by using them afterwards with
|
|
21
|
+
* different options.
|
|
22
|
+
*/
|
|
23
|
+
declare const hl7v2PresetLintRecommended: Preset;
|
|
24
|
+
export default hl7v2PresetLintRecommended;
|
|
25
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEtC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,QAAA,MAAM,0BAA0B,EAAE,MAQjC,CAAC;AAEF,eAAe,0BAA0B,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import hl7v2LintMessageVersion from "@glion/lint-message-version";
|
|
2
|
+
import hl7v2LintNoTrailingEmptyField from "@glion/lint-no-trailing-empty-field";
|
|
3
|
+
import hl7v2LintRequiredMessageHeader from "@glion/lint-required-message-header";
|
|
4
|
+
import hl7v2LintSegmentHeaderLength from "@glion/lint-segment-header-length";
|
|
5
|
+
//#region src/index.ts
|
|
6
|
+
/**
|
|
7
|
+
* Preset of hl7v2-lint rules to warn for likely problems.
|
|
8
|
+
*
|
|
9
|
+
* ## What is this?
|
|
10
|
+
*
|
|
11
|
+
* This package is a preset containing `hl7v2-lint` rules.
|
|
12
|
+
* Lint rules check hl7v2 basic rules.
|
|
13
|
+
*
|
|
14
|
+
* ## When should I use this?
|
|
15
|
+
*
|
|
16
|
+
* You can use this package to check that hl7v2 follows some best practices.
|
|
17
|
+
*
|
|
18
|
+
* ## API
|
|
19
|
+
*
|
|
20
|
+
* ### `unified().use(hl7v2PresetLintRecommended)`
|
|
21
|
+
*
|
|
22
|
+
* Check that hl7v2 follows some best practices.
|
|
23
|
+
*
|
|
24
|
+
* You can reconfigure rules in the preset by using them afterwards with
|
|
25
|
+
* different options.
|
|
26
|
+
*/
|
|
27
|
+
const hl7v2PresetLintRecommended = { plugins: [
|
|
28
|
+
[hl7v2LintSegmentHeaderLength, ["error"]],
|
|
29
|
+
[hl7v2LintRequiredMessageHeader, ["error"]],
|
|
30
|
+
[hl7v2LintMessageVersion, ["error"]],
|
|
31
|
+
hl7v2LintNoTrailingEmptyField
|
|
32
|
+
] };
|
|
33
|
+
//#endregion
|
|
34
|
+
export { hl7v2PresetLintRecommended as default };
|
|
35
|
+
|
|
36
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import hl7v2LintMessageVersion from \"@glion/lint-message-version\";\nimport hl7v2LintNoTrailingEmptyField from \"@glion/lint-no-trailing-empty-field\";\nimport hl7v2LintRequiredMessageHeader from \"@glion/lint-required-message-header\";\nimport hl7v2LintSegmentHeaderLength from \"@glion/lint-segment-header-length\";\nimport type { Preset } from \"unified\";\n\n/**\n * Preset of hl7v2-lint rules to warn for likely problems.\n *\n * ## What is this?\n *\n * This package is a preset containing `hl7v2-lint` rules.\n * Lint rules check hl7v2 basic rules.\n *\n * ## When should I use this?\n *\n * You can use this package to check that hl7v2 follows some best practices.\n *\n * ## API\n *\n * ### `unified().use(hl7v2PresetLintRecommended)`\n *\n * Check that hl7v2 follows some best practices.\n *\n * You can reconfigure rules in the preset by using them afterwards with\n * different options.\n */\nconst hl7v2PresetLintRecommended: Preset = {\n plugins: [\n // segment linting rules\n [hl7v2LintSegmentHeaderLength, [\"error\"]],\n [hl7v2LintRequiredMessageHeader, [\"error\"]],\n [hl7v2LintMessageVersion, [\"error\"]],\n hl7v2LintNoTrailingEmptyField,\n ],\n};\n\nexport default hl7v2PresetLintRecommended;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,MAAM,6BAAqC,EACzC,SAAS;CAEP,CAAC,8BAA8B,CAAC,QAAQ,CAAC;CACzC,CAAC,gCAAgC,CAAC,QAAQ,CAAC;CAC3C,CAAC,yBAAyB,CAAC,QAAQ,CAAC;CACpC;CACD,EACF"}
|
package/package.json
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@glion/preset-lint-recommended",
|
|
3
|
+
"version": "0.14.1",
|
|
4
|
+
"description": "hl7v2-lint preset with recommended rules",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"definition",
|
|
7
|
+
"hl7",
|
|
8
|
+
"hl7v2",
|
|
9
|
+
"hl7v2-lint",
|
|
10
|
+
"hl7v2-lint-rule",
|
|
11
|
+
"lint",
|
|
12
|
+
"nodejs",
|
|
13
|
+
"rule",
|
|
14
|
+
"typescript"
|
|
15
|
+
],
|
|
16
|
+
"homepage": "https://glion.dev",
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"author": {
|
|
19
|
+
"name": "Melek Somai",
|
|
20
|
+
"email": "melek@rethinkhealth.io"
|
|
21
|
+
},
|
|
22
|
+
"repository": "rethinkhealth/glion.git",
|
|
23
|
+
"files": [
|
|
24
|
+
"dist"
|
|
25
|
+
],
|
|
26
|
+
"type": "module",
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"exports": {
|
|
29
|
+
".": "./dist/index.js"
|
|
30
|
+
},
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"access": "public"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"unified": "11.0.5",
|
|
36
|
+
"unified-lint-rule": "3.0.1",
|
|
37
|
+
"@glion/lint-required-message-header": "0.14.1",
|
|
38
|
+
"@glion/lint-message-version": "0.14.1",
|
|
39
|
+
"@glion/lint-no-trailing-empty-field": "0.14.1",
|
|
40
|
+
"@glion/lint-segment-header-length": "0.14.1"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@types/node": "^25.5.0",
|
|
44
|
+
"@types/unist": "^3.0.3",
|
|
45
|
+
"@vitest/coverage-v8": "4.1.2",
|
|
46
|
+
"tsdown": "0.21.7",
|
|
47
|
+
"typescript": "^5.9.3",
|
|
48
|
+
"vfile": "^6.0.3",
|
|
49
|
+
"vfile-reporter": "^8.1.1",
|
|
50
|
+
"vitest": "4.1.2",
|
|
51
|
+
"@glion/builder": "0.14.1",
|
|
52
|
+
"@glion/ast": "0.14.1",
|
|
53
|
+
"@glion/jsonify": "0.14.1",
|
|
54
|
+
"@glion/testing": "0.0.2",
|
|
55
|
+
"@glion/parser": "0.14.1",
|
|
56
|
+
"@glion/tsconfig": "0.0.1"
|
|
57
|
+
},
|
|
58
|
+
"engines": {
|
|
59
|
+
"node": ">=18"
|
|
60
|
+
},
|
|
61
|
+
"scripts": {
|
|
62
|
+
"build": "tsdown && tsc --emitDeclarationOnly",
|
|
63
|
+
"check-types": "tsc --noEmit",
|
|
64
|
+
"test": "vitest run",
|
|
65
|
+
"test:coverage": "vitest run --coverage",
|
|
66
|
+
"test:watch": "vitest"
|
|
67
|
+
}
|
|
68
|
+
}
|