@rethinkhealth/hl7v2-lint-required-message-header 0.2.21 → 0.2.24

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/dist/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- import type { Node } from "@rethinkhealth/hl7v2-ast";
1
+ import type { Nodes } from "@rethinkhealth/hl7v2-ast";
2
2
  /**
3
3
  * hl7v2-lint rule to warn when message header segment (MSH) is missing.
4
4
  *
5
5
  * This rule is useful for ensuring that all messages start with a message
6
6
  * header segment.
7
7
  */
8
- declare const hl7v2LintSegmentRequiredMessageHeader: import("unified-lint-rule").Plugin<Node, undefined>;
8
+ declare const hl7v2LintSegmentRequiredMessageHeader: import("unified-lint-rule").Plugin<Nodes, undefined>;
9
9
  export default hl7v2LintSegmentRequiredMessageHeader;
10
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAQ,MAAM,0BAA0B,CAAC;AAI3D;;;;;GAKG;AACH,QAAA,MAAM,qCAAqC,qDA0B1C,CAAC;AAEF,eAAe,qCAAqC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAItD;;;;;GAKG;AACH,QAAA,MAAM,qCAAqC,sDAwB1C,CAAC;AACF,eAAe,qCAAqC,CAAC"}
package/dist/index.js CHANGED
@@ -1,30 +1,25 @@
1
1
  // src/index.ts
2
2
  import { lintRule } from "unified-lint-rule";
3
- import { SKIP, visitParents } from "unist-util-visit-parents";
3
+ import { EXIT, visitParents } from "unist-util-visit-parents";
4
4
  var hl7v2LintSegmentRequiredMessageHeader = lintRule(
5
5
  {
6
6
  origin: "hl7v2-lint:segment-required-message-header",
7
7
  url: "https://github.com/rethinkhealth/hl7v2/tree/main/packages/hl7v2-lint-segment-required-message-header#readme"
8
8
  },
9
9
  (tree, file) => {
10
- visitParents(tree, (node, parents) => {
11
- if (node.type === "root") {
12
- const firstSegment = node.children[0];
13
- if (firstSegment?.type === "segment") {
14
- const segment = firstSegment;
15
- const header = segment.children[0].value;
16
- if (header !== "MSH") {
17
- file.message(
18
- `Message header (MSH) segment is required. Received ${header} instead.`,
19
- {
20
- ancestors: [...parents, node, firstSegment],
21
- place: firstSegment.position
22
- }
23
- );
24
- }
10
+ if (tree.type !== "root") {
11
+ return;
12
+ }
13
+ visitParents(tree, (node) => {
14
+ if (node.type === "segment-header") {
15
+ if (node.value === "MSH") {
16
+ return EXIT;
25
17
  }
18
+ file.fail(
19
+ `Message header (MSH) segment is required as the first segment. Received ${node.value} instead.`,
20
+ { ancestors: [node], place: node.position }
21
+ );
26
22
  }
27
- return SKIP;
28
23
  });
29
24
  }
30
25
  );
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { Node, Root } from \"@rethinkhealth/hl7v2-ast\";\nimport { lintRule } from \"unified-lint-rule\";\nimport { SKIP, visitParents } from \"unist-util-visit-parents\";\n\n/**\n * hl7v2-lint rule to warn when message header segment (MSH) is missing.\n *\n * This rule is useful for ensuring that all messages start with a message\n * header segment.\n */\nconst hl7v2LintSegmentRequiredMessageHeader = lintRule<Node, undefined>(\n {\n origin: \"hl7v2-lint:segment-required-message-header\",\n url: \"https://github.com/rethinkhealth/hl7v2/tree/main/packages/hl7v2-lint-segment-required-message-header#readme\",\n },\n (tree, file) => {\n visitParents(tree, (node, parents) => {\n if (node.type === \"root\") {\n const firstSegment = (node as Root).children[0];\n if (firstSegment?.type === \"segment\") {\n const segment = firstSegment;\n const header = segment.children[0].value;\n if (header !== \"MSH\") {\n file.message(\n `Message header (MSH) segment is required. Received ${header} instead.`,\n {\n ancestors: [...parents, node, firstSegment],\n place: firstSegment.position,\n }\n );\n }\n }\n }\n return SKIP;\n });\n }\n);\n\nexport default hl7v2LintSegmentRequiredMessageHeader;\n"],"mappings":";AACA,SAAS,gBAAgB;AACzB,SAAS,MAAM,oBAAoB;AAQnC,IAAM,wCAAwC;AAAA,EAC5C;AAAA,IACE,QAAQ;AAAA,IACR,KAAK;AAAA,EACP;AAAA,EACA,CAAC,MAAM,SAAS;AACd,iBAAa,MAAM,CAAC,MAAM,YAAY;AACpC,UAAI,KAAK,SAAS,QAAQ;AACxB,cAAM,eAAgB,KAAc,SAAS,CAAC;AAC9C,YAAI,cAAc,SAAS,WAAW;AACpC,gBAAM,UAAU;AAChB,gBAAM,SAAS,QAAQ,SAAS,CAAC,EAAE;AACnC,cAAI,WAAW,OAAO;AACpB,iBAAK;AAAA,cACH,sDAAsD,MAAM;AAAA,cAC5D;AAAA,gBACE,WAAW,CAAC,GAAG,SAAS,MAAM,YAAY;AAAA,gBAC1C,OAAO,aAAa;AAAA,cACtB;AAAA,YACF;AAAA,UACF;AAAA,QACF;AAAA,MACF;AACA,aAAO;AAAA,IACT,CAAC;AAAA,EACH;AACF;AAEA,IAAO,cAAQ;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { Nodes } from \"@rethinkhealth/hl7v2-ast\";\nimport { lintRule } from \"unified-lint-rule\";\nimport { EXIT, visitParents } from \"unist-util-visit-parents\";\n\n/**\n * hl7v2-lint rule to warn when message header segment (MSH) is missing.\n *\n * This rule is useful for ensuring that all messages start with a message\n * header segment.\n */\nconst hl7v2LintSegmentRequiredMessageHeader = lintRule<Nodes, undefined>(\n {\n origin: \"hl7v2-lint:segment-required-message-header\",\n url: \"https://github.com/rethinkhealth/hl7v2/tree/main/packages/hl7v2-lint-segment-required-message-header#readme\",\n },\n (tree, file) => {\n if (tree.type !== \"root\") {\n return;\n }\n\n // Get the first segment in the message even if it's in a nested group(s).\n // We must ensure that it is the first segment in the message.\n visitParents(tree, (node) => {\n if (node.type === \"segment-header\") {\n if (node.value === \"MSH\") {\n return EXIT;\n }\n file.fail(\n `Message header (MSH) segment is required as the first segment. Received ${node.value} instead.`,\n { ancestors: [node], place: node.position }\n );\n }\n });\n }\n);\nexport default hl7v2LintSegmentRequiredMessageHeader;\n"],"mappings":";AACA,SAAS,gBAAgB;AACzB,SAAS,MAAM,oBAAoB;AAQnC,IAAM,wCAAwC;AAAA,EAC5C;AAAA,IACE,QAAQ;AAAA,IACR,KAAK;AAAA,EACP;AAAA,EACA,CAAC,MAAM,SAAS;AACd,QAAI,KAAK,SAAS,QAAQ;AACxB;AAAA,IACF;AAIA,iBAAa,MAAM,CAAC,SAAS;AAC3B,UAAI,KAAK,SAAS,kBAAkB;AAClC,YAAI,KAAK,UAAU,OAAO;AACxB,iBAAO;AAAA,QACT;AACA,aAAK;AAAA,UACH,2EAA2E,KAAK,KAAK;AAAA,UACrF,EAAE,WAAW,CAAC,IAAI,GAAG,OAAO,KAAK,SAAS;AAAA,QAC5C;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH;AACF;AACA,IAAO,cAAQ;","names":[]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rethinkhealth/hl7v2-lint-required-message-header",
3
3
  "description": "hl7v2-lint rule to warn when message header segment is missing",
4
- "version": "0.2.21",
4
+ "version": "0.2.24",
5
5
  "license": "MIT",
6
6
  "author": {
7
7
  "name": "Melek Somai",
@@ -18,20 +18,20 @@
18
18
  "dependencies": {
19
19
  "unified": "11.0.5",
20
20
  "unified-lint-rule": "3.0.1",
21
- "unist-util-visit-parents": "6.0.1"
21
+ "unist-util-visit-parents": "6.0.2"
22
22
  },
23
23
  "devDependencies": {
24
- "@types/node": "24.5.2",
24
+ "@types/node": "24.9.2",
25
25
  "@types/unist": "^3.0.3",
26
- "@vitest/coverage-v8": "^3.2.4",
26
+ "@vitest/coverage-v8": "^4.0.5",
27
27
  "tsup": "8.5.0",
28
- "typescript": "^5.8.3",
28
+ "typescript": "^5.9.3",
29
29
  "vfile": "^6.0.3",
30
30
  "vfile-reporter": "^8.1.1",
31
- "vitest": "^3.2.4",
32
- "@rethinkhealth/hl7v2-ast": "0.2.21",
33
- "@rethinkhealth/testing": "0.0.1",
34
- "@rethinkhealth/hl7v2-builder": "0.2.21",
31
+ "vitest": "^4.0.6",
32
+ "@rethinkhealth/hl7v2-ast": "0.2.24",
33
+ "@rethinkhealth/hl7v2-builder": "0.2.24",
34
+ "@rethinkhealth/testing": "0.0.2",
35
35
  "@rethinkhealth/tsconfig": "0.0.1"
36
36
  },
37
37
  "repository": "rethinkhealth/hl7v2.git",
@@ -47,7 +47,6 @@
47
47
  "rule",
48
48
  "typescript"
49
49
  ],
50
- "packageManager": "pnpm@10.14.0",
51
50
  "publishConfig": {
52
51
  "access": "public"
53
52
  },