@rethinkhealth/hl7v2-lint-segment-header-length 0.2.18 → 0.2.20

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,9 +1,9 @@
1
- import type { Node } from "@rethinkhealth/hl7v2-ast";
1
+ import type { Root } from "@rethinkhealth/hl7v2-ast";
2
2
  /**
3
3
  * hl7v2-lint rule to warn when segment header length is invalid.
4
4
  *
5
5
  *
6
6
  */
7
- declare const hl7v2LintSegmentHeaderLength: import("unified-lint-rule").Plugin<Node, undefined>;
7
+ declare const hl7v2LintSegmentHeaderLength: import("unified-lint-rule").Plugin<Root, undefined>;
8
8
  export default hl7v2LintSegmentHeaderLength;
9
9
  //# 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,EAAW,MAAM,0BAA0B,CAAC;AAK9D;;;;GAIG;AACH,QAAA,MAAM,4BAA4B,qDAiCjC,CAAC;AAEF,eAAe,4BAA4B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAKrD;;;;GAIG;AACH,QAAA,MAAM,4BAA4B,qDA4BjC,CAAC;AAEF,eAAe,4BAA4B,CAAC"}
package/dist/index.js CHANGED
@@ -1,29 +1,28 @@
1
1
  // src/index.ts
2
2
  import pluralize from "pluralize";
3
3
  import { lintRule } from "unified-lint-rule";
4
- import { CONTINUE, SKIP, visitParents } from "unist-util-visit-parents";
4
+ import { SKIP, visitParents } from "unist-util-visit-parents";
5
5
  var hl7v2LintSegmentHeaderLength = lintRule(
6
6
  {
7
7
  origin: "hl7v2-lint:segment-header-length",
8
8
  url: "https://github.com/rethinkhealth/hl7v2/tree/main/packages/hl7v2-lint-segment-header-length#readme"
9
9
  },
10
10
  (tree, file) => {
11
- visitParents(tree, (node, parents) => {
12
- if (node.type === "root") {
13
- return CONTINUE;
11
+ visitParents(
12
+ tree,
13
+ "segment-header",
14
+ (node, parents) => {
15
+ const headerValue = node.value;
16
+ const size = headerValue?.length ?? 0;
17
+ if (size === 3) {
18
+ return SKIP;
19
+ }
20
+ file.message(
21
+ `Unexpected ${size} header length, expected 3 characters, ${size > 3 ? `remove ${size - 3} ${pluralize("character", size - 3)}` : `add ${3 - (size ?? 0)} ${pluralize("character", 3 - (size ?? 0))}`}`,
22
+ { ancestors: [...parents, node], place: node.position }
23
+ );
14
24
  }
15
- if (node.type !== "segment") {
16
- return SKIP;
17
- }
18
- const size = node.children?.[0]?.children?.[0]?.children?.[0]?.children?.[0]?.value.length ?? 0;
19
- if (size === 3) {
20
- return SKIP;
21
- }
22
- file.message(
23
- `Unexpected ${size} header length, expected 3 characters, ${size > 3 ? `remove ${size - 3} ${pluralize("character", size - 3)}` : `add ${3 - (size ?? 0)} ${pluralize("character", 3 - (size ?? 0))}`}`,
24
- { ancestors: [...parents, node], place: node.position }
25
- );
26
- });
25
+ );
27
26
  }
28
27
  );
29
28
  var src_default = hl7v2LintSegmentHeaderLength;
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { Node, Segment } from \"@rethinkhealth/hl7v2-ast\";\nimport pluralize from \"pluralize\";\nimport { lintRule } from \"unified-lint-rule\";\nimport { CONTINUE, SKIP, visitParents } from \"unist-util-visit-parents\";\n\n/**\n * hl7v2-lint rule to warn when segment header length is invalid.\n *\n *\n */\nconst hl7v2LintSegmentHeaderLength = lintRule<Node, undefined>(\n {\n origin: \"hl7v2-lint:segment-header-length\",\n url: \"https://github.com/rethinkhealth/hl7v2/tree/main/packages/hl7v2-lint-segment-header-length#readme\",\n },\n (tree, file) => {\n visitParents(tree, (node, parents) => {\n if (node.type === \"root\") {\n return CONTINUE;\n }\n\n if (node.type !== \"segment\") {\n return SKIP;\n }\n\n const size =\n (node as Segment).children?.[0]?.children?.[0]?.children?.[0]\n ?.children?.[0]?.value.length ?? 0;\n\n if (size === 3) {\n return SKIP;\n }\n\n file.message(\n `Unexpected ${size} header length, expected 3 characters, ${\n size > 3\n ? `remove ${size - 3} ${pluralize(\"character\", size - 3)}`\n : `add ${3 - (size ?? 0)} ${pluralize(\"character\", 3 - (size ?? 0))}`\n }`,\n { ancestors: [...parents, node], place: node.position }\n );\n });\n }\n);\n\nexport default hl7v2LintSegmentHeaderLength;\n"],"mappings":";AACA,OAAO,eAAe;AACtB,SAAS,gBAAgB;AACzB,SAAS,UAAU,MAAM,oBAAoB;AAO7C,IAAM,+BAA+B;AAAA,EACnC;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,eAAO;AAAA,MACT;AAEA,UAAI,KAAK,SAAS,WAAW;AAC3B,eAAO;AAAA,MACT;AAEA,YAAM,OACH,KAAiB,WAAW,CAAC,GAAG,WAAW,CAAC,GAAG,WAAW,CAAC,GACxD,WAAW,CAAC,GAAG,MAAM,UAAU;AAErC,UAAI,SAAS,GAAG;AACd,eAAO;AAAA,MACT;AAEA,WAAK;AAAA,QACH,cAAc,IAAI,0CAChB,OAAO,IACH,UAAU,OAAO,CAAC,IAAI,UAAU,aAAa,OAAO,CAAC,CAAC,KACtD,OAAO,KAAK,QAAQ,EAAE,IAAI,UAAU,aAAa,KAAK,QAAQ,EAAE,CAAC,EACvE;AAAA,QACA,EAAE,WAAW,CAAC,GAAG,SAAS,IAAI,GAAG,OAAO,KAAK,SAAS;AAAA,MACxD;AAAA,IACF,CAAC;AAAA,EACH;AACF;AAEA,IAAO,cAAQ;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { Root } from \"@rethinkhealth/hl7v2-ast\";\nimport pluralize from \"pluralize\";\nimport { lintRule } from \"unified-lint-rule\";\nimport { SKIP, visitParents } from \"unist-util-visit-parents\";\n\n/**\n * hl7v2-lint rule to warn when segment header length is invalid.\n *\n *\n */\nconst hl7v2LintSegmentHeaderLength = lintRule<Root, undefined>(\n {\n origin: \"hl7v2-lint:segment-header-length\",\n url: \"https://github.com/rethinkhealth/hl7v2/tree/main/packages/hl7v2-lint-segment-header-length#readme\",\n },\n (tree, file) => {\n visitParents<Root, \"segment-header\">(\n tree,\n \"segment-header\",\n (node, parents) => {\n const headerValue = node.value;\n const size = headerValue?.length ?? 0;\n\n if (size === 3) {\n return SKIP;\n }\n\n file.message(\n `Unexpected ${size} header length, expected 3 characters, ${\n size > 3\n ? `remove ${size - 3} ${pluralize(\"character\", size - 3)}`\n : `add ${3 - (size ?? 0)} ${pluralize(\"character\", 3 - (size ?? 0))}`\n }`,\n { ancestors: [...parents, node], place: node.position }\n );\n }\n );\n }\n);\n\nexport default hl7v2LintSegmentHeaderLength;\n"],"mappings":";AACA,OAAO,eAAe;AACtB,SAAS,gBAAgB;AACzB,SAAS,MAAM,oBAAoB;AAOnC,IAAM,+BAA+B;AAAA,EACnC;AAAA,IACE,QAAQ;AAAA,IACR,KAAK;AAAA,EACP;AAAA,EACA,CAAC,MAAM,SAAS;AACd;AAAA,MACE;AAAA,MACA;AAAA,MACA,CAAC,MAAM,YAAY;AACjB,cAAM,cAAc,KAAK;AACzB,cAAM,OAAO,aAAa,UAAU;AAEpC,YAAI,SAAS,GAAG;AACd,iBAAO;AAAA,QACT;AAEA,aAAK;AAAA,UACH,cAAc,IAAI,0CAChB,OAAO,IACH,UAAU,OAAO,CAAC,IAAI,UAAU,aAAa,OAAO,CAAC,CAAC,KACtD,OAAO,KAAK,QAAQ,EAAE,IAAI,UAAU,aAAa,KAAK,QAAQ,EAAE,CAAC,EACvE;AAAA,UACA,EAAE,WAAW,CAAC,GAAG,SAAS,IAAI,GAAG,OAAO,KAAK,SAAS;AAAA,QACxD;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAEA,IAAO,cAAQ;","names":[]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rethinkhealth/hl7v2-lint-segment-header-length",
3
3
  "description": "hl7v2-lint rule to warn when segment header length is invalid",
4
- "version": "0.2.18",
4
+ "version": "0.2.20",
5
5
  "license": "MIT",
6
6
  "author": {
7
7
  "name": "Melek Somai",
@@ -28,13 +28,13 @@
28
28
  "@vitest/coverage-v8": "^3.2.4",
29
29
  "tsup": "8.5.0",
30
30
  "typescript": "^5.8.3",
31
+ "vfile": "^6.0.3",
31
32
  "vfile-reporter": "^8.1.1",
32
33
  "vitest": "^3.2.4",
33
- "@rethinkhealth/hl7v2-parser": "0.2.18",
34
- "@rethinkhealth/hl7v2-ast": "0.2.18",
34
+ "@rethinkhealth/hl7v2-ast": "0.2.20",
35
+ "@rethinkhealth/hl7v2-builder": "0.2.20",
35
36
  "@rethinkhealth/testing": "0.0.1",
36
- "@rethinkhealth/tsconfig": "0.0.1",
37
- "@rethinkhealth/hl7v2-jsonify": "0.2.18"
37
+ "@rethinkhealth/tsconfig": "0.0.1"
38
38
  },
39
39
  "repository": "rethinkhealth/hl7v2.git",
40
40
  "homepage": "https://www.rethinkhealth.io/hl7v2/docs",