@glion/lint-required-message-header 0.26.0 → 0.27.0

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2023 Rethink Health
3
+ Copyright (c) 2023 Rethink Health, SUARL
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -72,7 +72,7 @@ PID|1||PATID1234^^^HOSP^MR||DOE^JANE||19800101|F
72
72
  Reported message:
73
73
 
74
74
  ```
75
- The first segment is `PID`; a message must start with the message header segment (`MSH`).
75
+ The first segment is not the message header segment; a message must start with the message header segment (`MSH`).
76
76
  ```
77
77
 
78
78
  A segment with an empty Segment ID first, such as an input that starts with the field separator:
@@ -84,7 +84,7 @@ A segment with an empty Segment ID first, such as an input that starts with the
84
84
  Reported message:
85
85
 
86
86
  ```
87
- The first segment has an empty Segment ID; a message must start with the message header segment (`MSH`).
87
+ The first segment is not the message header segment; a message must start with the message header segment (`MSH`).
88
88
  ```
89
89
 
90
90
  An empty input (`""`), which parses to a tree with no segments, is reported as:
package/dist/index.d.ts CHANGED
@@ -5,7 +5,7 @@ import type { Root } from "@glion/ast";
5
5
  *
6
6
  * The first segment is found through any nested groups. Reports at most one
7
7
  * message per tree, with `expected` set to `MSH` and `actual` to the first
8
- * segment's Segment ID when there is one.
8
+ * segment's Segment ID when there is one, which is never in the text.
9
9
  */
10
10
  declare const hl7v2LintSegmentRequiredMessageHeader: import("unified-lint-rule").Plugin<Root, unknown>;
11
11
  export default hl7v2LintSegmentRequiredMessageHeader;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAW,MAAM,YAAY,CAAC;AAahD;;;;;;;GAOG;AACH,QAAA,MAAM,qCAAqC,mDA0C1C,CAAC;AAEF,eAAe,qCAAqC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,IAAI,EAAW,MAAM,YAAY,CAAC;AAWvD;;;;;;;GAOG;AACH,QAAA,MAAM,qCAAqC,mDAiC1C,CAAC;AAEF,eAAe,qCAAqC,CAAC"}
package/dist/index.js CHANGED
@@ -3,8 +3,7 @@ import { EXIT, visitParents } from "unist-util-visit-parents";
3
3
  //#region src/index.ts
4
4
  const messages = {
5
5
  emptyMessage: "The message has no segments; it must start with the message header segment (`MSH`).",
6
- emptySegmentId: "The first segment has an empty Segment ID; a message must start with the message header segment (`MSH`).",
7
- notMessageHeader: (segmentId) => `The first segment is \`${segmentId}\`; a message must start with the message header segment (\`MSH\`).`
6
+ notMessageHeader: "The first segment is not the message header segment; a message must start with the message header segment (`MSH`)."
8
7
  };
9
8
  /**
10
9
  * Lint rule that reports a message whose first segment is not the message
@@ -12,15 +11,18 @@ const messages = {
12
11
  *
13
12
  * The first segment is found through any nested groups. Reports at most one
14
13
  * message per tree, with `expected` set to `MSH` and `actual` to the first
15
- * segment's Segment ID when there is one.
14
+ * segment's Segment ID when there is one, which is never in the text.
16
15
  */
17
16
  const hl7v2LintSegmentRequiredMessageHeader = lintRule({
18
17
  origin: "hl7v2-lint:segment-required-message-header",
19
18
  url: "https://github.com/rethinkhealth/glion/tree/main/packages/lint-required-message-header#readme"
20
19
  }, (tree, file) => {
21
20
  let first;
22
- visitParents(tree, "segment", (node) => {
23
- first = node;
21
+ visitParents(tree, "segment", (segment, parents) => {
22
+ first = {
23
+ ancestors: [...parents, segment],
24
+ segment
25
+ };
24
26
  return EXIT;
25
27
  });
26
28
  if (!first) {
@@ -31,21 +33,13 @@ const hl7v2LintSegmentRequiredMessageHeader = lintRule({
31
33
  message.expected = ["MSH"];
32
34
  return;
33
35
  }
34
- if (first.name === "MSH") return;
35
- if (first.name === "") {
36
- const message = file.message(messages.emptySegmentId, {
37
- ancestors: [first],
38
- place: first.position
39
- });
40
- message.actual = "";
41
- message.expected = ["MSH"];
42
- return;
43
- }
44
- const message = file.message(messages.notMessageHeader(first.name), {
45
- ancestors: [first],
46
- place: first.position
36
+ const { ancestors, segment } = first;
37
+ if (segment.name === "MSH") return;
38
+ const message = file.message(messages.notMessageHeader, {
39
+ ancestors,
40
+ place: segment.position
47
41
  });
48
- message.actual = first.name;
42
+ message.actual = segment.name;
49
43
  message.expected = ["MSH"];
50
44
  });
51
45
  //#endregion
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import type { Root, Segment } from \"@glion/ast\";\nimport { lintRule } from \"unified-lint-rule\";\nimport { EXIT, visitParents } from \"unist-util-visit-parents\";\n\nconst messages = {\n emptyMessage:\n \"The message has no segments; it must start with the message header segment (`MSH`).\",\n emptySegmentId:\n \"The first segment has an empty Segment ID; a message must start with the message header segment (`MSH`).\",\n notMessageHeader: (segmentId: string) =>\n `The first segment is \\`${segmentId}\\`; a message must start with the message header segment (\\`MSH\\`).`,\n} as const;\n\n/**\n * Lint rule that reports a message whose first segment is not the message\n * header (`MSH`), or that has no segments.\n *\n * The first segment is found through any nested groups. Reports at most one\n * message per tree, with `expected` set to `MSH` and `actual` to the first\n * segment's Segment ID when there is one.\n */\nconst hl7v2LintSegmentRequiredMessageHeader = lintRule<Root>(\n {\n origin: \"hl7v2-lint:segment-required-message-header\",\n url: \"https://github.com/rethinkhealth/glion/tree/main/packages/lint-required-message-header#readme\",\n },\n (tree, file) => {\n let first: Segment | undefined;\n visitParents(tree, \"segment\", (node) => {\n first = node;\n return EXIT;\n });\n\n if (!first) {\n const message = file.message(messages.emptyMessage, {\n ancestors: [tree],\n place: tree.position,\n });\n message.expected = [\"MSH\"];\n return;\n }\n\n if (first.name === \"MSH\") {\n return;\n }\n\n if (first.name === \"\") {\n const message = file.message(messages.emptySegmentId, {\n ancestors: [first],\n place: first.position,\n });\n message.actual = \"\";\n message.expected = [\"MSH\"];\n return;\n }\n\n const message = file.message(messages.notMessageHeader(first.name), {\n ancestors: [first],\n place: first.position,\n });\n message.actual = first.name;\n message.expected = [\"MSH\"];\n }\n);\n\nexport default hl7v2LintSegmentRequiredMessageHeader;\n"],"mappings":";;;AAIA,MAAM,WAAW;CACf,cACE;CACF,gBACE;CACF,mBAAmB,cACjB,0BAA0B,UAAU;CACvC;;;;;;;;;AAUD,MAAM,wCAAwC,SAC5C;CACE,QAAQ;CACR,KAAK;CACN,GACA,MAAM,SAAS;CACd,IAAI;AACJ,cAAa,MAAM,YAAY,SAAS;AACtC,UAAQ;AACR,SAAO;GACP;AAEF,KAAI,CAAC,OAAO;EACV,MAAM,UAAU,KAAK,QAAQ,SAAS,cAAc;GAClD,WAAW,CAAC,KAAK;GACjB,OAAO,KAAK;GACb,CAAC;AACF,UAAQ,WAAW,CAAC,MAAM;AAC1B;;AAGF,KAAI,MAAM,SAAS,MACjB;AAGF,KAAI,MAAM,SAAS,IAAI;EACrB,MAAM,UAAU,KAAK,QAAQ,SAAS,gBAAgB;GACpD,WAAW,CAAC,MAAM;GAClB,OAAO,MAAM;GACd,CAAC;AACF,UAAQ,SAAS;AACjB,UAAQ,WAAW,CAAC,MAAM;AAC1B;;CAGF,MAAM,UAAU,KAAK,QAAQ,SAAS,iBAAiB,MAAM,KAAK,EAAE;EAClE,WAAW,CAAC,MAAM;EAClB,OAAO,MAAM;EACd,CAAC;AACF,SAAQ,SAAS,MAAM;AACvB,SAAQ,WAAW,CAAC,MAAM;EAE7B"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import type { Nodes, Root, Segment } from \"@glion/ast\";\nimport { lintRule } from \"unified-lint-rule\";\nimport { EXIT, visitParents } from \"unist-util-visit-parents\";\n\nconst messages = {\n emptyMessage:\n \"The message has no segments; it must start with the message header segment (`MSH`).\",\n notMessageHeader:\n \"The first segment is not the message header segment; a message must start with the message header segment (`MSH`).\",\n} as const;\n\n/**\n * Lint rule that reports a message whose first segment is not the message\n * header (`MSH`), or that has no segments.\n *\n * The first segment is found through any nested groups. Reports at most one\n * message per tree, with `expected` set to `MSH` and `actual` to the first\n * segment's Segment ID when there is one, which is never in the text.\n */\nconst hl7v2LintSegmentRequiredMessageHeader = lintRule<Root>(\n {\n origin: \"hl7v2-lint:segment-required-message-header\",\n url: \"https://github.com/rethinkhealth/glion/tree/main/packages/lint-required-message-header#readme\",\n },\n (tree, file) => {\n let first: { segment: Segment; ancestors: Nodes[] } | undefined;\n visitParents(tree, \"segment\", (segment, parents) => {\n first = { ancestors: [...parents, segment], segment };\n return EXIT;\n });\n\n if (!first) {\n const message = file.message(messages.emptyMessage, {\n ancestors: [tree],\n place: tree.position,\n });\n message.expected = [\"MSH\"];\n return;\n }\n\n const { ancestors, segment } = first;\n if (segment.name === \"MSH\") {\n return;\n }\n\n const message = file.message(messages.notMessageHeader, {\n ancestors,\n place: segment.position,\n });\n message.actual = segment.name;\n message.expected = [\"MSH\"];\n }\n);\n\nexport default hl7v2LintSegmentRequiredMessageHeader;\n"],"mappings":";;;AAIA,MAAM,WAAW;CACf,cACE;CACF,kBACE;CACH;;;;;;;;;AAUD,MAAM,wCAAwC,SAC5C;CACE,QAAQ;CACR,KAAK;CACN,GACA,MAAM,SAAS;CACd,IAAI;AACJ,cAAa,MAAM,YAAY,SAAS,YAAY;AAClD,UAAQ;GAAE,WAAW,CAAC,GAAG,SAAS,QAAQ;GAAE;GAAS;AACrD,SAAO;GACP;AAEF,KAAI,CAAC,OAAO;EACV,MAAM,UAAU,KAAK,QAAQ,SAAS,cAAc;GAClD,WAAW,CAAC,KAAK;GACjB,OAAO,KAAK;GACb,CAAC;AACF,UAAQ,WAAW,CAAC,MAAM;AAC1B;;CAGF,MAAM,EAAE,WAAW,YAAY;AAC/B,KAAI,QAAQ,SAAS,MACnB;CAGF,MAAM,UAAU,KAAK,QAAQ,SAAS,kBAAkB;EACtD;EACA,OAAO,QAAQ;EAChB,CAAC;AACF,SAAQ,SAAS,QAAQ;AACzB,SAAQ,WAAW,CAAC,MAAM;EAE7B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glion/lint-required-message-header",
3
- "version": "0.26.0",
3
+ "version": "0.27.0",
4
4
  "description": "hl7v2-lint rule to warn when message header segment is missing",
5
5
  "keywords": [
6
6
  "definition",
@@ -41,6 +41,8 @@
41
41
  "unist-util-visit-parents": "6.0.2"
42
42
  },
43
43
  "devDependencies": {
44
+ "@stryker-mutator/core": "10.0.0",
45
+ "@stryker-mutator/vitest-runner": "10.0.0",
44
46
  "@types/node": "25.6.0",
45
47
  "@types/unist": "^3.0.3",
46
48
  "@vitest/coverage-v8": "4.1.11",
@@ -50,8 +52,8 @@
50
52
  "vfile": "^6.0.3",
51
53
  "vfile-reporter": "^8.1.1",
52
54
  "vitest": "4.1.11",
53
- "@glion/ast": "0.26.0",
54
- "@glion/builder": "0.26.0",
55
+ "@glion/ast": "0.27.0",
56
+ "@glion/builder": "0.27.0",
55
57
  "@glion/check-readme": "0.18.0",
56
58
  "@glion/testing": "0.18.0",
57
59
  "@glion/tsconfig": "0.18.0"
@@ -63,9 +65,10 @@
63
65
  "build": "tsdown && tsc --emitDeclarationOnly",
64
66
  "check-types": "tsc --noEmit && tsc --noEmit -p tests/tsconfig.json",
65
67
  "check:readme": "glion-check-readme",
68
+ "mutate": "stryker run",
69
+ "publint": "publint --strict",
66
70
  "test": "vitest run",
67
71
  "test:coverage": "vitest run --coverage",
68
- "test:watch": "vitest",
69
- "publint": "publint --strict"
72
+ "test:watch": "vitest"
70
73
  }
71
74
  }