@glion/lint-profile-field-repetition 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 +1 -1
- package/README.md +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -4
- package/dist/index.js.map +1 -1
- package/package.json +12 -9
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -77,7 +77,7 @@ PID|1||PATID1234^^^HOSP^MR||DOE^JANE||19800101~19800102|F
|
|
|
77
77
|
Reported message:
|
|
78
78
|
|
|
79
79
|
```
|
|
80
|
-
|
|
80
|
+
The field has 2 repetitions; it allows at most 1 repetition.
|
|
81
81
|
```
|
|
82
82
|
|
|
83
83
|
## Part of Glion
|
package/dist/index.d.ts.map
CHANGED
|
@@ -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;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAUvC;;;;;;;;;;;;;;GAcG;AACH,QAAA,MAAM,wBAAwB,mDAsB7B,CAAC;AAEF,eAAe,wBAAwB,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 = { tooManyRepetitions: (
|
|
5
|
+
const messages = { tooManyRepetitions: (count, max) => `The field has ${pluralize("repetition", count, true)}; it allows at most ${pluralize("repetition", max, true)}.` };
|
|
6
6
|
/**
|
|
7
7
|
* Lint rule that reports a field with more repetitions than its RP/# allows.
|
|
8
8
|
*
|
|
@@ -23,11 +23,10 @@ const hl7v2LintFieldRepetition = lintRule({
|
|
|
23
23
|
url: "https://github.com/rethinkhealth/glion/tree/main/packages/lint-profile-field-repetition#readme"
|
|
24
24
|
}, (tree, file) => {
|
|
25
25
|
visit(tree, "field", (field, ancestors) => {
|
|
26
|
-
const id = field.data?.id;
|
|
27
26
|
const limit = field.data?.repetitions;
|
|
28
27
|
const count = field.children.length;
|
|
29
|
-
if (
|
|
30
|
-
const message = file.message(messages.tooManyRepetitions(
|
|
28
|
+
if (typeof limit !== "number" || count <= limit) return SKIP;
|
|
29
|
+
const message = file.message(messages.tooManyRepetitions(count, limit), {
|
|
31
30
|
ancestors: [...ancestors, field],
|
|
32
31
|
place: field.position
|
|
33
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 FieldData augmentation\nimport type { hl7v2AnnotateProfileFields } from \"@glion/annotate-profile-fields\";\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 tooManyRepetitions: (
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["// oxlint-disable-next-line no-unused-vars -- triggers FieldData augmentation\nimport type { hl7v2AnnotateProfileFields } from \"@glion/annotate-profile-fields\";\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 tooManyRepetitions: (count: number, max: number) =>\n `The field has ${pluralize(\"repetition\", count, true)}; it allows at most ${pluralize(\"repetition\", max, true)}.`,\n} as const;\n\n/**\n * Lint rule that reports a field with more repetitions than its RP/# allows.\n *\n * Reads `repetitions` from `field.data`, so `@glion/annotate-profile-fields`\n * MUST run before it. A field whose `repetitions` is `\"unbounded\"` is never\n * reported.\n *\n * @example\n * ```typescript\n * unified()\n * .use(hl7v2AnnotateProfileContext)\n * .use(hl7v2AnnotateProfileFields)\n * .use(hl7v2LintFieldRepetition);\n * ```;\n */\nconst hl7v2LintFieldRepetition = lintRule<Root>(\n {\n origin: \"hl7v2-lint:field-repetition\",\n url: \"https://github.com/rethinkhealth/glion/tree/main/packages/lint-profile-field-repetition#readme\",\n },\n (tree, file) => {\n visit(tree, \"field\", (field, ancestors) => {\n const limit = field.data?.repetitions;\n const count = field.children.length;\n // A limit of \"unbounded\" is never exceeded.\n if (typeof limit !== \"number\" || count <= limit) {\n return SKIP;\n }\n\n const message = file.message(messages.tooManyRepetitions(count, limit), {\n ancestors: [...ancestors, field],\n place: field.position,\n });\n message.actual = String(count);\n return SKIP;\n });\n }\n);\n\nexport default hl7v2LintFieldRepetition;\n"],"mappings":";;;;AAOA,MAAM,WAAW,EACf,qBAAqB,OAAe,QAClC,iBAAiB,UAAU,cAAc,OAAO,KAAK,CAAC,sBAAsB,UAAU,cAAc,KAAK,KAAK,CAAC,IAClH;;;;;;;;;;;;;;;;AAiBD,MAAM,2BAA2B,SAC/B;CACE,QAAQ;CACR,KAAK;CACN,GACA,MAAM,SAAS;AACd,OAAM,MAAM,UAAU,OAAO,cAAc;EACzC,MAAM,QAAQ,MAAM,MAAM;EAC1B,MAAM,QAAQ,MAAM,SAAS;AAE7B,MAAI,OAAO,UAAU,YAAY,SAAS,MACxC,QAAO;EAGT,MAAM,UAAU,KAAK,QAAQ,SAAS,mBAAmB,OAAO,MAAM,EAAE;GACtE,WAAW,CAAC,GAAG,WAAW,MAAM;GAChC,OAAO,MAAM;GACd,CAAC;AACF,UAAQ,SAAS,OAAO,MAAM;AAC9B,SAAO;GACP;EAEL"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@glion/lint-profile-field-repetition",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.27.0",
|
|
4
4
|
"description": "Lint rule that flags non-repeatable fields with multiple repetitions",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"health",
|
|
@@ -35,11 +35,13 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"pluralize": "8.0.0",
|
|
37
37
|
"unified-lint-rule": "3.0.1",
|
|
38
|
-
"@glion/annotate-profile-fields": "0.
|
|
39
|
-
"@glion/ast": "0.
|
|
40
|
-
"@glion/util-visit": "0.
|
|
38
|
+
"@glion/annotate-profile-fields": "0.27.0",
|
|
39
|
+
"@glion/ast": "0.27.0",
|
|
40
|
+
"@glion/util-visit": "0.27.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
+
"@stryker-mutator/core": "10.0.0",
|
|
44
|
+
"@stryker-mutator/vitest-runner": "10.0.0",
|
|
43
45
|
"@types/node": "25.6.0",
|
|
44
46
|
"@types/pluralize": "^0.0.33",
|
|
45
47
|
"@vitest/coverage-v8": "4.1.11",
|
|
@@ -49,10 +51,10 @@
|
|
|
49
51
|
"unified": "^11.0.5",
|
|
50
52
|
"vfile": "^6.0.3",
|
|
51
53
|
"vitest": "4.1.11",
|
|
52
|
-
"@glion/annotate-profile-context": "0.
|
|
53
|
-
"@glion/builder": "0.
|
|
54
|
+
"@glion/annotate-profile-context": "0.27.0",
|
|
55
|
+
"@glion/builder": "0.27.0",
|
|
54
56
|
"@glion/check-readme": "0.18.0",
|
|
55
|
-
"@glion/parser": "0.
|
|
57
|
+
"@glion/parser": "0.27.0",
|
|
56
58
|
"@glion/testing": "0.18.0",
|
|
57
59
|
"@glion/tsconfig": "0.18.0"
|
|
58
60
|
},
|
|
@@ -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
|
}
|