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

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.
@@ -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,EAAW,MAAM,0BAA0B,CAAC;AAK9D;;;;GAIG;AACH,QAAA,MAAM,4BAA4B,qDAkCjC,CAAC;AAEF,eAAe,4BAA4B,CAAC"}
package/dist/index.js CHANGED
@@ -15,7 +15,9 @@ var hl7v2LintSegmentHeaderLength = lintRule(
15
15
  if (node.type !== "segment") {
16
16
  return SKIP;
17
17
  }
18
- const size = node.children?.[0]?.children?.[0]?.children?.[0]?.children?.[0]?.value.length ?? 0;
18
+ const segment = node;
19
+ const headerValue = segment.name;
20
+ const size = headerValue?.length ?? 0;
19
21
  if (size === 3) {
20
22
  return SKIP;
21
23
  }
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 { 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 segment = node as Segment;\n // Prefer the name property if present, otherwise extract from first field\n const headerValue = segment.name;\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\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,UAAU;AAEhB,YAAM,cAAc,QAAQ;AAC5B,YAAM,OAAO,aAAa,UAAU;AAEpC,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":[]}
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.19",
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",
35
- "@rethinkhealth/testing": "0.0.1",
34
+ "@rethinkhealth/hl7v2-ast": "0.2.19",
35
+ "@rethinkhealth/hl7v2-builder": "0.2.19",
36
36
  "@rethinkhealth/tsconfig": "0.0.1",
37
- "@rethinkhealth/hl7v2-jsonify": "0.2.18"
37
+ "@rethinkhealth/testing": "0.0.1"
38
38
  },
39
39
  "repository": "rethinkhealth/hl7v2.git",
40
40
  "homepage": "https://www.rethinkhealth.io/hl7v2/docs",