@glion/lint-profile-extra-fields 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
@@ -76,7 +76,7 @@ PID|1||PATID1234^^^HOSP^MR||DOE^JANE||19800101|F
76
76
  Reported message:
77
77
 
78
78
  ```
79
- Segment `MSH` has 22 fields; it allows at most 21 fields.
79
+ The segment has 22 fields; it allows at most 21 fields.
80
80
  ```
81
81
 
82
82
  The version is taken from the annotated profile context. A segment is reported once, however many fields it has past its last.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAUvC;;;;;;;;;;GAUG;AACH,QAAA,MAAM,oBAAoB,mDAiCzB,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAUvC;;;;;;;;;;GAUG;AACH,QAAA,MAAM,oBAAoB,mDA8BzB,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import { SKIP, visit } from "@glion/util-visit";
2
2
  import pluralize from "pluralize";
3
3
  import { lintRule } from "unified-lint-rule";
4
4
  //#region src/index.ts
5
- const messages = { tooManyFields: (segmentId, count, max) => `Segment \`${segmentId}\` has ${pluralize("field", count, true)}; it allows at most ${pluralize("field", max, true)}.` };
5
+ const messages = { tooManyFields: (count, max) => `The segment has ${pluralize("field", count, true)}; it allows at most ${pluralize("field", max, true)}.` };
6
6
  /**
7
7
  * Lint rule that reports a segment with more fields than its profile
8
8
  * defines.
@@ -26,7 +26,7 @@ const hl7v2LintExtraFields = lintRule({
26
26
  const max = Math.max(0, ...fields.bySequence.keys());
27
27
  const count = segment.children.length;
28
28
  if (count > max) {
29
- const message = file.message(messages.tooManyFields(segment.name, count, max), {
29
+ const message = file.message(messages.tooManyFields(count, max), {
30
30
  ancestors: [...segmentAncestors, segment],
31
31
  place: segment.position
32
32
  });
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["// oxlint-disable-next-line no-unused-vars -- triggers VFile DataMap augmentation\nimport type { ProfileContext } from \"@glion/annotate-profile-context\";\nimport type { Root } from \"@glion/ast\";\nimport { SKIP, visit } from \"@glion/util-visit\";\nimport pluralize from \"pluralize\";\nimport { lintRule } from \"unified-lint-rule\";\n\nconst messages = {\n tooManyFields: (segmentId: string, count: number, max: number) =>\n `Segment \\`${segmentId}\\` has ${pluralize(\"field\", count, true)}; it allows at most ${pluralize(\"field\", max, true)}.`,\n} as const;\n\n/**\n * Lint rule that reports a segment with more fields than its profile\n * defines.\n *\n * Segments without a known profile (e.g., Z-segments) are silently skipped.\n *\n * @example\n * ```typescript\n * unified().use(hl7v2LintExtraFields);\n * ```;\n */\nconst hl7v2LintExtraFields = lintRule<Root>(\n {\n origin: \"hl7v2-lint:extra-fields\",\n url: \"https://github.com/rethinkhealth/glion/tree/main/packages/lint-profile-extra-fields#readme\",\n },\n (tree, file) => {\n const ctx = file.data.profile;\n if (!ctx) {\n return;\n }\n\n visit(tree, \"segment\", (segment, segmentAncestors) => {\n const fields = ctx.fields.get(segment.name);\n if (!fields) {\n return SKIP;\n }\n\n const max = Math.max(0, ...fields.bySequence.keys());\n const count = segment.children.length;\n if (count > max) {\n const message = file.message(\n messages.tooManyFields(segment.name, count, max),\n {\n ancestors: [...segmentAncestors, segment],\n place: segment.position,\n }\n );\n message.actual = String(count);\n }\n\n return SKIP;\n });\n }\n);\n\nexport default hl7v2LintExtraFields;\n"],"mappings":";;;;AAOA,MAAM,WAAW,EACf,gBAAgB,WAAmB,OAAe,QAChD,aAAa,UAAU,SAAS,UAAU,SAAS,OAAO,KAAK,CAAC,sBAAsB,UAAU,SAAS,KAAK,KAAK,CAAC,IACvH;;;;;;;;;;;;AAaD,MAAM,uBAAuB,SAC3B;CACE,QAAQ;CACR,KAAK;CACN,GACA,MAAM,SAAS;CACd,MAAM,MAAM,KAAK,KAAK;AACtB,KAAI,CAAC,IACH;AAGF,OAAM,MAAM,YAAY,SAAS,qBAAqB;EACpD,MAAM,SAAS,IAAI,OAAO,IAAI,QAAQ,KAAK;AAC3C,MAAI,CAAC,OACH,QAAO;EAGT,MAAM,MAAM,KAAK,IAAI,GAAG,GAAG,OAAO,WAAW,MAAM,CAAC;EACpD,MAAM,QAAQ,QAAQ,SAAS;AAC/B,MAAI,QAAQ,KAAK;GACf,MAAM,UAAU,KAAK,QACnB,SAAS,cAAc,QAAQ,MAAM,OAAO,IAAI,EAChD;IACE,WAAW,CAAC,GAAG,kBAAkB,QAAQ;IACzC,OAAO,QAAQ;IAChB,CACF;AACD,WAAQ,SAAS,OAAO,MAAM;;AAGhC,SAAO;GACP;EAEL"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["// oxlint-disable-next-line no-unused-vars -- triggers VFile DataMap augmentation\nimport type { ProfileContext } from \"@glion/annotate-profile-context\";\nimport type { Root } from \"@glion/ast\";\nimport { SKIP, visit } from \"@glion/util-visit\";\nimport pluralize from \"pluralize\";\nimport { lintRule } from \"unified-lint-rule\";\n\nconst messages = {\n tooManyFields: (count: number, max: number) =>\n `The segment has ${pluralize(\"field\", count, true)}; it allows at most ${pluralize(\"field\", max, true)}.`,\n} as const;\n\n/**\n * Lint rule that reports a segment with more fields than its profile\n * defines.\n *\n * Segments without a known profile (e.g., Z-segments) are silently skipped.\n *\n * @example\n * ```typescript\n * unified().use(hl7v2LintExtraFields);\n * ```;\n */\nconst hl7v2LintExtraFields = lintRule<Root>(\n {\n origin: \"hl7v2-lint:extra-fields\",\n url: \"https://github.com/rethinkhealth/glion/tree/main/packages/lint-profile-extra-fields#readme\",\n },\n (tree, file) => {\n const ctx = file.data.profile;\n if (!ctx) {\n return;\n }\n\n visit(tree, \"segment\", (segment, segmentAncestors) => {\n const fields = ctx.fields.get(segment.name);\n if (!fields) {\n return SKIP;\n }\n\n const max = Math.max(0, ...fields.bySequence.keys());\n const count = segment.children.length;\n if (count > max) {\n const message = file.message(messages.tooManyFields(count, max), {\n ancestors: [...segmentAncestors, segment],\n place: segment.position,\n });\n message.actual = String(count);\n }\n\n return SKIP;\n });\n }\n);\n\nexport default hl7v2LintExtraFields;\n"],"mappings":";;;;AAOA,MAAM,WAAW,EACf,gBAAgB,OAAe,QAC7B,mBAAmB,UAAU,SAAS,OAAO,KAAK,CAAC,sBAAsB,UAAU,SAAS,KAAK,KAAK,CAAC,IAC1G;;;;;;;;;;;;AAaD,MAAM,uBAAuB,SAC3B;CACE,QAAQ;CACR,KAAK;CACN,GACA,MAAM,SAAS;CACd,MAAM,MAAM,KAAK,KAAK;AACtB,KAAI,CAAC,IACH;AAGF,OAAM,MAAM,YAAY,SAAS,qBAAqB;EACpD,MAAM,SAAS,IAAI,OAAO,IAAI,QAAQ,KAAK;AAC3C,MAAI,CAAC,OACH,QAAO;EAGT,MAAM,MAAM,KAAK,IAAI,GAAG,GAAG,OAAO,WAAW,MAAM,CAAC;EACpD,MAAM,QAAQ,QAAQ,SAAS;AAC/B,MAAI,QAAQ,KAAK;GACf,MAAM,UAAU,KAAK,QAAQ,SAAS,cAAc,OAAO,IAAI,EAAE;IAC/D,WAAW,CAAC,GAAG,kBAAkB,QAAQ;IACzC,OAAO,QAAQ;IAChB,CAAC;AACF,WAAQ,SAAS,OAAO,MAAM;;AAGhC,SAAO;GACP;EAEL"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glion/lint-profile-extra-fields",
3
- "version": "0.26.0",
3
+ "version": "0.27.0",
4
4
  "description": "Lint rule that warns when a segment contains fields beyond the maximum sequence defined in its profile",
5
5
  "keywords": [
6
6
  "health",
@@ -35,10 +35,12 @@
35
35
  "dependencies": {
36
36
  "pluralize": "8.0.0",
37
37
  "unified-lint-rule": "3.0.1",
38
- "@glion/ast": "0.26.0",
39
- "@glion/util-visit": "0.26.0"
38
+ "@glion/ast": "0.27.0",
39
+ "@glion/util-visit": "0.27.0"
40
40
  },
41
41
  "devDependencies": {
42
+ "@stryker-mutator/core": "10.0.0",
43
+ "@stryker-mutator/vitest-runner": "10.0.0",
42
44
  "@types/node": "25.6.0",
43
45
  "@types/pluralize": "^0.0.33",
44
46
  "@vitest/coverage-v8": "4.1.11",
@@ -48,11 +50,11 @@
48
50
  "unified": "^11.0.5",
49
51
  "vfile": "^6.0.3",
50
52
  "vitest": "4.1.11",
51
- "@glion/annotate-profile-context": "0.26.0",
52
- "@glion/builder": "0.26.0",
53
- "@glion/check-readme": "0.18.0",
53
+ "@glion/annotate-profile-context": "0.27.0",
54
+ "@glion/builder": "0.27.0",
54
55
  "@glion/testing": "0.18.0",
55
- "@glion/tsconfig": "0.18.0"
56
+ "@glion/tsconfig": "0.18.0",
57
+ "@glion/check-readme": "0.18.0"
56
58
  },
57
59
  "engines": {
58
60
  "node": ">=22"
@@ -61,9 +63,10 @@
61
63
  "build": "tsdown && tsc --emitDeclarationOnly",
62
64
  "check-types": "tsc --noEmit && tsc --noEmit -p tests/tsconfig.json",
63
65
  "check:readme": "glion-check-readme",
66
+ "mutate": "stryker run",
67
+ "publint": "publint --strict",
64
68
  "test": "vitest run",
65
69
  "test:coverage": "vitest run --coverage",
66
- "test:watch": "vitest",
67
- "publint": "publint --strict"
70
+ "test:watch": "vitest"
68
71
  }
69
72
  }