@driftsys/markspec 0.3.0 → 0.5.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/esm/ast/build.d.ts +70 -0
- package/esm/ast/build.d.ts.map +1 -0
- package/esm/ast/build.js +605 -0
- package/esm/ast/equivalence.d.ts +18 -0
- package/esm/ast/equivalence.d.ts.map +1 -0
- package/esm/ast/equivalence.js +56 -0
- package/esm/ast/nodes.d.ts +221 -0
- package/esm/ast/nodes.d.ts.map +1 -0
- package/esm/ast/nodes.js +12 -0
- package/esm/ast/normalize.d.ts +67 -0
- package/esm/ast/normalize.d.ts.map +1 -0
- package/esm/ast/normalize.js +255 -0
- package/esm/ast/render.d.ts +34 -0
- package/esm/ast/render.d.ts.map +1 -0
- package/esm/ast/render.js +215 -0
- package/esm/compiler/inverses.d.ts +2 -8
- package/esm/compiler/inverses.d.ts.map +1 -1
- package/esm/compiler/inverses.js +50 -14
- package/esm/compiler/manifest.d.ts +59 -0
- package/esm/compiler/manifest.d.ts.map +1 -0
- package/esm/compiler/manifest.js +48 -0
- package/esm/compiler/mod.d.ts +9 -1
- package/esm/compiler/mod.d.ts.map +1 -1
- package/esm/compiler/mod.js +21 -2
- package/esm/compiler/ndjson_writer.d.ts +50 -0
- package/esm/compiler/ndjson_writer.d.ts.map +1 -0
- package/esm/compiler/ndjson_writer.js +73 -0
- package/esm/compiler/schema.d.ts +18 -1
- package/esm/compiler/schema.d.ts.map +1 -1
- package/esm/compiler/schema.js +18 -9
- package/esm/config/mod.d.ts.map +1 -1
- package/esm/config/mod.js +54 -0
- package/esm/formatter/mod.d.ts +56 -6
- package/esm/formatter/mod.d.ts.map +1 -1
- package/esm/formatter/mod.js +372 -41
- package/esm/formatter/synth_ulid.d.ts +21 -0
- package/esm/formatter/synth_ulid.d.ts.map +1 -0
- package/esm/formatter/synth_ulid.js +64 -0
- package/esm/lint/mod.d.ts +10 -0
- package/esm/lint/mod.d.ts.map +1 -0
- package/esm/lint/mod.js +7 -0
- package/esm/lint/rules/lexicon.d.ts +24 -0
- package/esm/lint/rules/lexicon.d.ts.map +1 -0
- package/esm/lint/rules/lexicon.js +236 -0
- package/esm/lint/rules/struct.d.ts +17 -0
- package/esm/lint/rules/struct.d.ts.map +1 -0
- package/esm/lint/rules/struct.js +55 -0
- package/esm/lint/rules/suppression.d.ts +19 -0
- package/esm/lint/rules/suppression.d.ts.map +1 -0
- package/esm/lint/rules/suppression.js +75 -0
- package/esm/lint/runner.d.ts +39 -0
- package/esm/lint/runner.d.ts.map +1 -0
- package/esm/lint/runner.js +112 -0
- package/esm/lint/types.d.ts +19 -0
- package/esm/lint/types.d.ts.map +1 -0
- package/esm/lint/types.js +9 -0
- package/esm/mod.d.ts +21 -8
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +16 -5
- package/esm/model/attributes.d.ts.map +1 -1
- package/esm/model/attributes.js +163 -2
- package/esm/model/discriminating_attr.d.ts +33 -0
- package/esm/model/discriminating_attr.d.ts.map +1 -0
- package/esm/model/discriminating_attr.js +74 -0
- package/esm/model/mod.d.ts +100 -3
- package/esm/model/mod.d.ts.map +1 -1
- package/esm/model/mod.js +58 -2
- package/esm/model/palette.d.ts +18 -0
- package/esm/model/palette.d.ts.map +1 -0
- package/esm/model/palette.js +23 -0
- package/esm/model/profile.d.ts +33 -27
- package/esm/model/profile.d.ts.map +1 -1
- package/esm/model/source_introspection.d.ts +26 -0
- package/esm/model/source_introspection.d.ts.map +1 -0
- package/esm/model/source_introspection.js +77 -0
- package/esm/model/type_hierarchy.d.ts +51 -0
- package/esm/model/type_hierarchy.d.ts.map +1 -0
- package/esm/model/type_hierarchy.js +126 -0
- package/esm/model/uri_scheme_map.d.ts +21 -0
- package/esm/model/uri_scheme_map.d.ts.map +1 -0
- package/esm/model/uri_scheme_map.js +66 -0
- package/esm/parser/attributes.d.ts.map +1 -1
- package/esm/parser/attributes.js +9 -6
- package/esm/parser/entity_refs.d.ts +53 -0
- package/esm/parser/entity_refs.d.ts.map +1 -0
- package/esm/parser/entity_refs.js +151 -0
- package/esm/parser/glossary.d.ts +43 -0
- package/esm/parser/glossary.d.ts.map +1 -0
- package/esm/parser/glossary.js +217 -0
- package/esm/parser/markdown.d.ts +10 -3
- package/esm/parser/markdown.d.ts.map +1 -1
- package/esm/parser/markdown.js +241 -11
- package/esm/parser/mod.d.ts +1 -0
- package/esm/parser/mod.d.ts.map +1 -1
- package/esm/parser/mod.js +4 -3
- package/esm/parser/source.d.ts +20 -0
- package/esm/parser/source.d.ts.map +1 -1
- package/esm/parser/source.js +4 -4
- package/esm/profile/chain.js +3 -13
- package/esm/profile/colors.d.ts +26 -0
- package/esm/profile/colors.d.ts.map +1 -0
- package/esm/profile/colors.js +46 -0
- package/esm/profile/introspect.d.ts +135 -0
- package/esm/profile/introspect.d.ts.map +1 -0
- package/esm/profile/introspect.js +378 -0
- package/esm/profile/load.d.ts.map +1 -1
- package/esm/profile/load.js +67 -0
- package/esm/profile/manifest.d.ts.map +1 -1
- package/esm/profile/manifest.js +278 -104
- package/esm/profile/merge.js +139 -39
- package/esm/profile/mod.d.ts +3 -4
- package/esm/profile/mod.d.ts.map +1 -1
- package/esm/profile/mod.js +6 -2
- package/esm/reporter/mod.js +4 -4
- package/esm/util/fence.d.ts +30 -0
- package/esm/util/fence.d.ts.map +1 -0
- package/esm/util/fence.js +40 -0
- package/esm/validator/attributes.d.ts +3 -3
- package/esm/validator/attributes.d.ts.map +1 -1
- package/esm/validator/attributes.js +1 -18
- package/esm/validator/body_blocks.d.ts +38 -0
- package/esm/validator/body_blocks.d.ts.map +1 -0
- package/esm/validator/body_blocks.js +218 -0
- package/esm/validator/caption_convention.d.ts +29 -0
- package/esm/validator/caption_convention.d.ts.map +1 -0
- package/esm/validator/caption_convention.js +58 -0
- package/esm/validator/captions.d.ts +22 -0
- package/esm/validator/captions.d.ts.map +1 -0
- package/esm/validator/captions.js +137 -0
- package/esm/validator/component_schemes.d.ts +73 -0
- package/esm/validator/component_schemes.d.ts.map +1 -0
- package/esm/validator/component_schemes.js +375 -0
- package/esm/validator/feature_ac.d.ts +28 -0
- package/esm/validator/feature_ac.d.ts.map +1 -0
- package/esm/validator/feature_ac.js +102 -0
- package/esm/validator/listing.d.ts +42 -0
- package/esm/validator/listing.d.ts.map +1 -0
- package/esm/validator/listing.js +295 -0
- package/esm/validator/mod.d.ts +2 -0
- package/esm/validator/mod.d.ts.map +1 -1
- package/esm/validator/mod.js +253 -12
- package/esm/validator/modal_keywords.d.ts +23 -0
- package/esm/validator/modal_keywords.d.ts.map +1 -0
- package/esm/validator/modal_keywords.js +137 -0
- package/esm/validator/per_type_attrs.d.ts +29 -0
- package/esm/validator/per_type_attrs.d.ts.map +1 -0
- package/esm/validator/per_type_attrs.js +75 -0
- package/esm/validator/pipeline.d.ts +7 -2
- package/esm/validator/pipeline.d.ts.map +1 -1
- package/esm/validator/pipeline.js +40 -7
- package/esm/validator/trace_types.d.ts +26 -0
- package/esm/validator/trace_types.d.ts.map +1 -0
- package/esm/validator/trace_types.js +232 -0
- package/esm/validator/traceability.d.ts +3 -4
- package/esm/validator/traceability.d.ts.map +1 -1
- package/esm/validator/traceability.js +5 -10
- package/esm/validator/type_resolution.d.ts +67 -0
- package/esm/validator/type_resolution.d.ts.map +1 -0
- package/esm/validator/type_resolution.js +140 -0
- package/esm/validator/types.d.ts +45 -0
- package/esm/validator/types.d.ts.map +1 -1
- package/esm/validator/types.js +128 -16
- package/esm/validator/value_types.d.ts +8 -0
- package/esm/validator/value_types.d.ts.map +1 -1
- package/esm/validator/value_types.js +8 -1
- package/package.json +1 -1
- package/script/ast/build.d.ts +70 -0
- package/script/ast/build.d.ts.map +1 -0
- package/script/ast/build.js +610 -0
- package/script/ast/equivalence.d.ts +18 -0
- package/script/ast/equivalence.d.ts.map +1 -0
- package/script/ast/equivalence.js +59 -0
- package/script/ast/nodes.d.ts +221 -0
- package/script/ast/nodes.d.ts.map +1 -0
- package/script/ast/nodes.js +13 -0
- package/script/ast/normalize.d.ts +67 -0
- package/script/ast/normalize.d.ts.map +1 -0
- package/script/ast/normalize.js +258 -0
- package/script/ast/render.d.ts +34 -0
- package/script/ast/render.d.ts.map +1 -0
- package/script/ast/render.js +218 -0
- package/script/compiler/inverses.d.ts +2 -8
- package/script/compiler/inverses.d.ts.map +1 -1
- package/script/compiler/inverses.js +50 -14
- package/script/compiler/manifest.d.ts +59 -0
- package/script/compiler/manifest.d.ts.map +1 -0
- package/script/compiler/manifest.js +51 -0
- package/script/compiler/mod.d.ts +9 -1
- package/script/compiler/mod.d.ts.map +1 -1
- package/script/compiler/mod.js +21 -2
- package/script/compiler/ndjson_writer.d.ts +50 -0
- package/script/compiler/ndjson_writer.d.ts.map +1 -0
- package/script/compiler/ndjson_writer.js +78 -0
- package/script/compiler/schema.d.ts +18 -1
- package/script/compiler/schema.d.ts.map +1 -1
- package/script/compiler/schema.js +18 -8
- package/script/config/mod.d.ts.map +1 -1
- package/script/config/mod.js +54 -0
- package/script/formatter/mod.d.ts +56 -6
- package/script/formatter/mod.d.ts.map +1 -1
- package/script/formatter/mod.js +375 -41
- package/script/formatter/synth_ulid.d.ts +21 -0
- package/script/formatter/synth_ulid.d.ts.map +1 -0
- package/script/formatter/synth_ulid.js +67 -0
- package/script/lint/mod.d.ts +10 -0
- package/script/lint/mod.d.ts.map +1 -0
- package/script/lint/mod.js +12 -0
- package/script/lint/rules/lexicon.d.ts +24 -0
- package/script/lint/rules/lexicon.d.ts.map +1 -0
- package/script/lint/rules/lexicon.js +240 -0
- package/script/lint/rules/struct.d.ts +17 -0
- package/script/lint/rules/struct.d.ts.map +1 -0
- package/script/lint/rules/struct.js +59 -0
- package/script/lint/rules/suppression.d.ts +19 -0
- package/script/lint/rules/suppression.d.ts.map +1 -0
- package/script/lint/rules/suppression.js +80 -0
- package/script/lint/runner.d.ts +39 -0
- package/script/lint/runner.d.ts.map +1 -0
- package/script/lint/runner.js +116 -0
- package/script/lint/types.d.ts +19 -0
- package/script/lint/types.d.ts.map +1 -0
- package/script/lint/types.js +10 -0
- package/script/mod.d.ts +21 -8
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +58 -32
- package/script/model/attributes.d.ts.map +1 -1
- package/script/model/attributes.js +163 -2
- package/script/model/discriminating_attr.d.ts +33 -0
- package/script/model/discriminating_attr.d.ts.map +1 -0
- package/script/model/discriminating_attr.js +77 -0
- package/script/model/mod.d.ts +100 -3
- package/script/model/mod.d.ts.map +1 -1
- package/script/model/mod.js +67 -3
- package/script/model/palette.d.ts +18 -0
- package/script/model/palette.d.ts.map +1 -0
- package/script/model/palette.js +26 -0
- package/script/model/profile.d.ts +33 -27
- package/script/model/profile.d.ts.map +1 -1
- package/script/model/source_introspection.d.ts +26 -0
- package/script/model/source_introspection.d.ts.map +1 -0
- package/script/model/source_introspection.js +80 -0
- package/script/model/type_hierarchy.d.ts +51 -0
- package/script/model/type_hierarchy.d.ts.map +1 -0
- package/script/model/type_hierarchy.js +130 -0
- package/script/model/uri_scheme_map.d.ts +21 -0
- package/script/model/uri_scheme_map.d.ts.map +1 -0
- package/script/model/uri_scheme_map.js +69 -0
- package/script/parser/attributes.d.ts.map +1 -1
- package/script/parser/attributes.js +9 -6
- package/script/parser/entity_refs.d.ts +53 -0
- package/script/parser/entity_refs.d.ts.map +1 -0
- package/script/parser/entity_refs.js +155 -0
- package/script/parser/glossary.d.ts +43 -0
- package/script/parser/glossary.d.ts.map +1 -0
- package/script/parser/glossary.js +221 -0
- package/script/parser/markdown.d.ts +10 -3
- package/script/parser/markdown.d.ts.map +1 -1
- package/script/parser/markdown.js +240 -10
- package/script/parser/mod.d.ts +1 -0
- package/script/parser/mod.d.ts.map +1 -1
- package/script/parser/mod.js +8 -4
- package/script/parser/source.d.ts +20 -0
- package/script/parser/source.d.ts.map +1 -1
- package/script/parser/source.js +4 -1
- package/script/profile/chain.js +3 -13
- package/script/profile/colors.d.ts +26 -0
- package/script/profile/colors.d.ts.map +1 -0
- package/script/profile/colors.js +49 -0
- package/script/profile/introspect.d.ts +135 -0
- package/script/profile/introspect.d.ts.map +1 -0
- package/script/profile/introspect.js +381 -0
- package/script/profile/load.d.ts.map +1 -1
- package/script/profile/load.js +67 -0
- package/script/profile/manifest.d.ts.map +1 -1
- package/script/profile/manifest.js +280 -106
- package/script/profile/merge.js +139 -39
- package/script/profile/mod.d.ts +3 -4
- package/script/profile/mod.d.ts.map +1 -1
- package/script/profile/mod.js +9 -6
- package/script/reporter/mod.js +4 -4
- package/script/util/fence.d.ts +30 -0
- package/script/util/fence.d.ts.map +1 -0
- package/script/util/fence.js +44 -0
- package/script/validator/attributes.d.ts +3 -3
- package/script/validator/attributes.d.ts.map +1 -1
- package/script/validator/attributes.js +1 -18
- package/script/validator/body_blocks.d.ts +38 -0
- package/script/validator/body_blocks.d.ts.map +1 -0
- package/script/validator/body_blocks.js +221 -0
- package/script/validator/caption_convention.d.ts +29 -0
- package/script/validator/caption_convention.d.ts.map +1 -0
- package/script/validator/caption_convention.js +61 -0
- package/script/validator/captions.d.ts +22 -0
- package/script/validator/captions.d.ts.map +1 -0
- package/script/validator/captions.js +140 -0
- package/script/validator/component_schemes.d.ts +73 -0
- package/script/validator/component_schemes.d.ts.map +1 -0
- package/script/validator/component_schemes.js +384 -0
- package/script/validator/feature_ac.d.ts +28 -0
- package/script/validator/feature_ac.d.ts.map +1 -0
- package/script/validator/feature_ac.js +105 -0
- package/script/validator/listing.d.ts +42 -0
- package/script/validator/listing.d.ts.map +1 -0
- package/script/validator/listing.js +298 -0
- package/script/validator/mod.d.ts +2 -0
- package/script/validator/mod.d.ts.map +1 -1
- package/script/validator/mod.js +256 -14
- package/script/validator/modal_keywords.d.ts +23 -0
- package/script/validator/modal_keywords.d.ts.map +1 -0
- package/script/validator/modal_keywords.js +140 -0
- package/script/validator/per_type_attrs.d.ts +29 -0
- package/script/validator/per_type_attrs.d.ts.map +1 -0
- package/script/validator/per_type_attrs.js +78 -0
- package/script/validator/pipeline.d.ts +7 -2
- package/script/validator/pipeline.d.ts.map +1 -1
- package/script/validator/pipeline.js +39 -6
- package/script/validator/trace_types.d.ts +26 -0
- package/script/validator/trace_types.d.ts.map +1 -0
- package/script/validator/trace_types.js +235 -0
- package/script/validator/traceability.d.ts +3 -4
- package/script/validator/traceability.d.ts.map +1 -1
- package/script/validator/traceability.js +5 -10
- package/script/validator/type_resolution.d.ts +67 -0
- package/script/validator/type_resolution.d.ts.map +1 -0
- package/script/validator/type_resolution.js +146 -0
- package/script/validator/types.d.ts +45 -0
- package/script/validator/types.d.ts.map +1 -1
- package/script/validator/types.js +131 -16
- package/script/validator/value_types.d.ts +8 -0
- package/script/validator/value_types.d.ts.map +1 -1
- package/script/validator/value_types.js +10 -2
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/lint/rules/lexicon
|
|
3
|
+
*
|
|
4
|
+
* Six INCOSE GtWR lexicon rules for PA-1. All operate by scanning
|
|
5
|
+
* InlineContent.text in prose-bearing AST blocks for canonical
|
|
6
|
+
* word/phrase matches. No sentence segmentation needed.
|
|
7
|
+
*
|
|
8
|
+
* Rules:
|
|
9
|
+
* MSL-Q302 incose-r7-vague-term (warn, score 3)
|
|
10
|
+
* MSL-Q303 incose-r8-escape-clause (warn, score 3)
|
|
11
|
+
* MSL-Q304 incose-r9-open-ended (info, score 1)
|
|
12
|
+
* MSL-Q305 incose-r10-superfluous-inf (info, score 1)
|
|
13
|
+
* MSL-Q310 incose-r26-absolute (info, score 1)
|
|
14
|
+
* MSL-Q313 incose-r16-not (info, score 1)
|
|
15
|
+
*/
|
|
16
|
+
// ---------------------------------------------------------------------------
|
|
17
|
+
// Word/phrase lists (INCOSE GtWR canonical sets)
|
|
18
|
+
// ---------------------------------------------------------------------------
|
|
19
|
+
const Q302_TERMS = [
|
|
20
|
+
"some",
|
|
21
|
+
"several",
|
|
22
|
+
"many",
|
|
23
|
+
"few",
|
|
24
|
+
"a number of",
|
|
25
|
+
"approximate",
|
|
26
|
+
"approximately",
|
|
27
|
+
"adequate",
|
|
28
|
+
"adequately",
|
|
29
|
+
"sufficient",
|
|
30
|
+
"sufficiently",
|
|
31
|
+
"reasonable",
|
|
32
|
+
"reasonably",
|
|
33
|
+
"efficient",
|
|
34
|
+
"efficiently",
|
|
35
|
+
"appropriate",
|
|
36
|
+
"appropriately",
|
|
37
|
+
"effective",
|
|
38
|
+
"effectively",
|
|
39
|
+
"as needed",
|
|
40
|
+
// "as required" belongs exclusively to Q303 (INCOSE R8 escape clause)
|
|
41
|
+
];
|
|
42
|
+
const Q303_TERMS = [
|
|
43
|
+
"as appropriate",
|
|
44
|
+
"as required",
|
|
45
|
+
"where possible",
|
|
46
|
+
"if practicable",
|
|
47
|
+
"if possible",
|
|
48
|
+
"to the extent possible",
|
|
49
|
+
"to the extent necessary",
|
|
50
|
+
"where applicable",
|
|
51
|
+
"to the extent practicable",
|
|
52
|
+
];
|
|
53
|
+
const Q304_TERMS = [
|
|
54
|
+
"including but not limited to",
|
|
55
|
+
"etc.",
|
|
56
|
+
"et cetera",
|
|
57
|
+
"and so on",
|
|
58
|
+
"and/or",
|
|
59
|
+
];
|
|
60
|
+
const Q305_TERMS = [
|
|
61
|
+
"be able to",
|
|
62
|
+
"be capable of",
|
|
63
|
+
"be designed to",
|
|
64
|
+
"be required to",
|
|
65
|
+
"to enable",
|
|
66
|
+
"to allow",
|
|
67
|
+
"in order to",
|
|
68
|
+
];
|
|
69
|
+
const Q310_TERMS = [
|
|
70
|
+
"100%",
|
|
71
|
+
"all of",
|
|
72
|
+
"every",
|
|
73
|
+
"all the",
|
|
74
|
+
"always",
|
|
75
|
+
"never",
|
|
76
|
+
"none",
|
|
77
|
+
"no instance",
|
|
78
|
+
"complete",
|
|
79
|
+
"completely",
|
|
80
|
+
"entire",
|
|
81
|
+
"entirely",
|
|
82
|
+
];
|
|
83
|
+
const LEXICON_RULES = [
|
|
84
|
+
{
|
|
85
|
+
code: "MSL-Q302",
|
|
86
|
+
slug: "incose-r7-vague-term",
|
|
87
|
+
severity: "warning",
|
|
88
|
+
scoreContribution: 3,
|
|
89
|
+
terms: Q302_TERMS,
|
|
90
|
+
wholeWord: false,
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
code: "MSL-Q303",
|
|
94
|
+
slug: "incose-r8-escape-clause",
|
|
95
|
+
severity: "warning",
|
|
96
|
+
scoreContribution: 3,
|
|
97
|
+
terms: Q303_TERMS,
|
|
98
|
+
wholeWord: false,
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
code: "MSL-Q304",
|
|
102
|
+
slug: "incose-r9-open-ended",
|
|
103
|
+
severity: "info",
|
|
104
|
+
scoreContribution: 1,
|
|
105
|
+
terms: Q304_TERMS,
|
|
106
|
+
wholeWord: false,
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
code: "MSL-Q305",
|
|
110
|
+
slug: "incose-r10-superfluous-infinitive",
|
|
111
|
+
severity: "info",
|
|
112
|
+
scoreContribution: 1,
|
|
113
|
+
terms: Q305_TERMS,
|
|
114
|
+
wholeWord: false,
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
code: "MSL-Q310",
|
|
118
|
+
slug: "incose-r26-absolute",
|
|
119
|
+
severity: "info",
|
|
120
|
+
scoreContribution: 1,
|
|
121
|
+
terms: Q310_TERMS,
|
|
122
|
+
wholeWord: false,
|
|
123
|
+
},
|
|
124
|
+
];
|
|
125
|
+
// Q313 uses whole-word boundary matching — "not" must not match "note", "notation"
|
|
126
|
+
const Q313_RULE = {
|
|
127
|
+
code: "MSL-Q313",
|
|
128
|
+
slug: "incose-r16-not",
|
|
129
|
+
severity: "info",
|
|
130
|
+
scoreContribution: 1,
|
|
131
|
+
terms: ["not"],
|
|
132
|
+
wholeWord: true,
|
|
133
|
+
};
|
|
134
|
+
// ---------------------------------------------------------------------------
|
|
135
|
+
// Text extraction from AST blocks
|
|
136
|
+
// ---------------------------------------------------------------------------
|
|
137
|
+
/** Extract all InlineContent.text strings from prose-bearing AST blocks.
|
|
138
|
+
* Walks Paragraph, Note, and List (recursively) per the PA-1 scope.
|
|
139
|
+
* Skips Table, Code, Feature, Math, Blockquote, etc. */
|
|
140
|
+
function extractTexts(blocks) {
|
|
141
|
+
const texts = [];
|
|
142
|
+
for (const block of blocks) {
|
|
143
|
+
if (block.kind === "paragraph") {
|
|
144
|
+
texts.push(block.content.text);
|
|
145
|
+
}
|
|
146
|
+
else if (block.kind === "note") {
|
|
147
|
+
texts.push(block.content.text);
|
|
148
|
+
}
|
|
149
|
+
else if (block.kind === "list") {
|
|
150
|
+
for (const item of block.items) {
|
|
151
|
+
texts.push(...extractTexts(item.blocks));
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
// Table, Blockquote, Code, Feature, Math, Caption, Unknown: skip
|
|
155
|
+
}
|
|
156
|
+
return texts;
|
|
157
|
+
}
|
|
158
|
+
// ---------------------------------------------------------------------------
|
|
159
|
+
// Match helpers
|
|
160
|
+
// ---------------------------------------------------------------------------
|
|
161
|
+
/** Case-insensitive substring scan — returns true if any term found. */
|
|
162
|
+
function containsTerm(text, term) {
|
|
163
|
+
return text.toLowerCase().includes(term.toLowerCase());
|
|
164
|
+
}
|
|
165
|
+
/** Whole-word, case-insensitive match using word boundaries. */
|
|
166
|
+
function containsWholeWord(text, word) {
|
|
167
|
+
// Build a regex with word boundaries around the term.
|
|
168
|
+
// Escape any regex metacharacters in the word (unlikely for "not" but safe).
|
|
169
|
+
const escaped = word.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
170
|
+
const re = new RegExp(`\\b${escaped}\\b`, "i");
|
|
171
|
+
return re.test(text);
|
|
172
|
+
}
|
|
173
|
+
// ---------------------------------------------------------------------------
|
|
174
|
+
// Public API
|
|
175
|
+
// ---------------------------------------------------------------------------
|
|
176
|
+
/** Run all six lexicon rules on an entry's prose AST blocks.
|
|
177
|
+
* Returns one LintDiagnostic per matching term per rule (one per rule
|
|
178
|
+
* per entry — first match only, to avoid flooding). */
|
|
179
|
+
export function runLexiconRules(entry) {
|
|
180
|
+
const blocks = entry.bodyAst ?? [];
|
|
181
|
+
const texts = extractTexts(blocks);
|
|
182
|
+
if (texts.length === 0)
|
|
183
|
+
return [];
|
|
184
|
+
const out = [];
|
|
185
|
+
const location = entry.location;
|
|
186
|
+
for (const rule of LEXICON_RULES) {
|
|
187
|
+
let fired = false;
|
|
188
|
+
for (const text of texts) {
|
|
189
|
+
if (fired)
|
|
190
|
+
break;
|
|
191
|
+
for (const term of rule.terms) {
|
|
192
|
+
if (containsTerm(text, term)) {
|
|
193
|
+
out.push({
|
|
194
|
+
code: rule.code,
|
|
195
|
+
slug: rule.slug,
|
|
196
|
+
severity: rule.severity,
|
|
197
|
+
scoreContribution: rule.scoreContribution,
|
|
198
|
+
group: "incose",
|
|
199
|
+
message: `${rule.slug}: '${term}' found in entry body`,
|
|
200
|
+
location,
|
|
201
|
+
});
|
|
202
|
+
fired = true;
|
|
203
|
+
break;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
// Q313: whole-word "not"
|
|
209
|
+
let q313Fired = false;
|
|
210
|
+
for (const text of texts) {
|
|
211
|
+
if (q313Fired)
|
|
212
|
+
break;
|
|
213
|
+
if (containsWholeWord(text, "not")) {
|
|
214
|
+
out.push({
|
|
215
|
+
code: Q313_RULE.code,
|
|
216
|
+
slug: Q313_RULE.slug,
|
|
217
|
+
severity: Q313_RULE.severity,
|
|
218
|
+
scoreContribution: Q313_RULE.scoreContribution,
|
|
219
|
+
group: "incose",
|
|
220
|
+
message: `${Q313_RULE.slug}: 'not' found in entry body`,
|
|
221
|
+
location,
|
|
222
|
+
});
|
|
223
|
+
q313Fired = true;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
return out;
|
|
227
|
+
}
|
|
228
|
+
/** Exported for test/diagnostic use: the set of rule codes this module emits. */
|
|
229
|
+
export const LEXICON_RULE_CODES = new Set([
|
|
230
|
+
"MSL-Q302",
|
|
231
|
+
"MSL-Q303",
|
|
232
|
+
"MSL-Q304",
|
|
233
|
+
"MSL-Q305",
|
|
234
|
+
"MSL-Q310",
|
|
235
|
+
"MSL-Q313",
|
|
236
|
+
]);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/lint/rules/struct
|
|
3
|
+
*
|
|
4
|
+
* Two structural prose-quality rules for PA-1:
|
|
5
|
+
* MSL-Q400 struct-title-length (info, score 1)
|
|
6
|
+
* MSL-Q401 struct-body-length (info, score 1)
|
|
7
|
+
*
|
|
8
|
+
* Thresholds are hard-coded defaults; profile-level configuration
|
|
9
|
+
* (prose.struct.title.minLength / maxLength, etc.) is wired in PA-2.
|
|
10
|
+
*/
|
|
11
|
+
import type { Entry } from "../../model/mod.js";
|
|
12
|
+
import type { LintDiagnostic } from "../types.js";
|
|
13
|
+
/** Run MSL-Q400 and MSL-Q401 on an entry. */
|
|
14
|
+
export declare function runStructRules(entry: Entry): LintDiagnostic[];
|
|
15
|
+
/** Exported rule codes for suppression validation. */
|
|
16
|
+
export declare const STRUCT_RULE_CODES: ReadonlySet<string>;
|
|
17
|
+
//# sourceMappingURL=struct.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"struct.d.ts","sourceRoot":"","sources":["../../../src/lint/rules/struct.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAkB,MAAM,oBAAoB,CAAC;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAQlD,6CAA6C;AAC7C,wBAAgB,cAAc,CAAC,KAAK,EAAE,KAAK,GAAG,cAAc,EAAE,CAsC7D;AAED,sDAAsD;AACtD,eAAO,MAAM,iBAAiB,EAAE,WAAW,CAAC,MAAM,CAGhD,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/lint/rules/struct
|
|
3
|
+
*
|
|
4
|
+
* Two structural prose-quality rules for PA-1:
|
|
5
|
+
* MSL-Q400 struct-title-length (info, score 1)
|
|
6
|
+
* MSL-Q401 struct-body-length (info, score 1)
|
|
7
|
+
*
|
|
8
|
+
* Thresholds are hard-coded defaults; profile-level configuration
|
|
9
|
+
* (prose.struct.title.minLength / maxLength, etc.) is wired in PA-2.
|
|
10
|
+
*/
|
|
11
|
+
// TODO(PA-2): wire these from prose.struct profile config
|
|
12
|
+
const TITLE_MIN_LENGTH = 3;
|
|
13
|
+
const TITLE_MAX_LENGTH = 120;
|
|
14
|
+
const BODY_MIN_WORDS = 5;
|
|
15
|
+
const BODY_MAX_WORDS = 500;
|
|
16
|
+
/** Run MSL-Q400 and MSL-Q401 on an entry. */
|
|
17
|
+
export function runStructRules(entry) {
|
|
18
|
+
const out = [];
|
|
19
|
+
const location = entry.location;
|
|
20
|
+
// MSL-Q400: title length
|
|
21
|
+
const titleLen = entry.title.length;
|
|
22
|
+
if (titleLen < TITLE_MIN_LENGTH || titleLen > TITLE_MAX_LENGTH) {
|
|
23
|
+
const dir = titleLen < TITLE_MIN_LENGTH ? "too short" : "too long";
|
|
24
|
+
out.push({
|
|
25
|
+
code: "MSL-Q400",
|
|
26
|
+
slug: "struct-title-length",
|
|
27
|
+
severity: "info",
|
|
28
|
+
scoreContribution: 1,
|
|
29
|
+
group: "struct",
|
|
30
|
+
message: `struct-title-length: title is ${dir} (${titleLen} chars; expected ${TITLE_MIN_LENGTH}–${TITLE_MAX_LENGTH})`,
|
|
31
|
+
location,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
// MSL-Q401: body word count — split entry.body on whitespace
|
|
35
|
+
const words = entry.body.split(/\s+/).filter((w) => w.length > 0);
|
|
36
|
+
const wordCount = words.length;
|
|
37
|
+
if (wordCount < BODY_MIN_WORDS || wordCount > BODY_MAX_WORDS) {
|
|
38
|
+
const dir = wordCount < BODY_MIN_WORDS ? "too short" : "too long";
|
|
39
|
+
out.push({
|
|
40
|
+
code: "MSL-Q401",
|
|
41
|
+
slug: "struct-body-length",
|
|
42
|
+
severity: "info",
|
|
43
|
+
scoreContribution: 1,
|
|
44
|
+
group: "struct",
|
|
45
|
+
message: `struct-body-length: body is ${dir} (${wordCount} words; expected ${BODY_MIN_WORDS}–${BODY_MAX_WORDS})`,
|
|
46
|
+
location,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
return out;
|
|
50
|
+
}
|
|
51
|
+
/** Exported rule codes for suppression validation. */
|
|
52
|
+
export const STRUCT_RULE_CODES = new Set([
|
|
53
|
+
"MSL-Q400",
|
|
54
|
+
"MSL-Q401",
|
|
55
|
+
]);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/lint/rules/suppression
|
|
3
|
+
*
|
|
4
|
+
* Two suppression-hygiene rules for PA-1:
|
|
5
|
+
* MSL-Q900 disable-without-rationale (warn, score 3)
|
|
6
|
+
* MSL-Q901 disable-unknown-rule (warn, score 3)
|
|
7
|
+
*
|
|
8
|
+
* These run on every Authored entry (not just in-scope ones) because
|
|
9
|
+
* suppression hygiene applies to any entry that uses Markspec-disable.
|
|
10
|
+
*/
|
|
11
|
+
import type { Entry } from "../../model/mod.js";
|
|
12
|
+
import type { LintDiagnostic } from "../types.js";
|
|
13
|
+
/** All rule codes shipped in PA-1. MSL-Q900/Q901 are self-referential. */
|
|
14
|
+
export declare const PA1_KNOWN_RULE_CODES: ReadonlySet<string>;
|
|
15
|
+
/** Parse the Markspec-disable attribute value into individual rule tokens. */
|
|
16
|
+
export declare function parseDisableValue(value: string): string[];
|
|
17
|
+
/** Run MSL-Q900 and MSL-Q901 on an entry. Safe to call on all Authored entries. */
|
|
18
|
+
export declare function runSuppressionRules(entry: Entry): LintDiagnostic[];
|
|
19
|
+
//# sourceMappingURL=suppression.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"suppression.d.ts","sourceRoot":"","sources":["../../../src/lint/rules/suppression.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAkB,MAAM,oBAAoB,CAAC;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAIlD,0EAA0E;AAC1E,eAAO,MAAM,oBAAoB,EAAE,WAAW,CAAC,MAAM,CAKnD,CAAC;AAEH,8EAA8E;AAC9E,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAEzD;AAkBD,mFAAmF;AACnF,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,KAAK,GAAG,cAAc,EAAE,CAuClE"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/lint/rules/suppression
|
|
3
|
+
*
|
|
4
|
+
* Two suppression-hygiene rules for PA-1:
|
|
5
|
+
* MSL-Q900 disable-without-rationale (warn, score 3)
|
|
6
|
+
* MSL-Q901 disable-unknown-rule (warn, score 3)
|
|
7
|
+
*
|
|
8
|
+
* These run on every Authored entry (not just in-scope ones) because
|
|
9
|
+
* suppression hygiene applies to any entry that uses Markspec-disable.
|
|
10
|
+
*/
|
|
11
|
+
import { LEXICON_RULE_CODES } from "./lexicon.js";
|
|
12
|
+
import { STRUCT_RULE_CODES } from "./struct.js";
|
|
13
|
+
/** All rule codes shipped in PA-1. MSL-Q900/Q901 are self-referential. */
|
|
14
|
+
export const PA1_KNOWN_RULE_CODES = new Set([
|
|
15
|
+
...LEXICON_RULE_CODES,
|
|
16
|
+
...STRUCT_RULE_CODES,
|
|
17
|
+
"MSL-Q900",
|
|
18
|
+
"MSL-Q901",
|
|
19
|
+
]);
|
|
20
|
+
/** Parse the Markspec-disable attribute value into individual rule tokens. */
|
|
21
|
+
export function parseDisableValue(value) {
|
|
22
|
+
return value.split(",").map((t) => t.trim()).filter((t) => t.length > 0);
|
|
23
|
+
}
|
|
24
|
+
/** Return the Markspec-disable attribute value, or undefined. */
|
|
25
|
+
function getDisableValue(entry) {
|
|
26
|
+
for (const attr of entry.rawAttributes) {
|
|
27
|
+
if (attr.key === "Markspec-disable")
|
|
28
|
+
return attr.value;
|
|
29
|
+
}
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
/** Return whether the entry has a non-empty Rationale attribute. */
|
|
33
|
+
function hasRationale(entry) {
|
|
34
|
+
for (const attr of entry.rawAttributes) {
|
|
35
|
+
if (attr.key === "Rationale" && attr.value.trim().length > 0)
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
/** Run MSL-Q900 and MSL-Q901 on an entry. Safe to call on all Authored entries. */
|
|
41
|
+
export function runSuppressionRules(entry) {
|
|
42
|
+
const out = [];
|
|
43
|
+
const location = entry.location;
|
|
44
|
+
const disableValue = getDisableValue(entry);
|
|
45
|
+
if (disableValue === undefined)
|
|
46
|
+
return out;
|
|
47
|
+
// MSL-Q900: disable without rationale
|
|
48
|
+
if (!hasRationale(entry)) {
|
|
49
|
+
out.push({
|
|
50
|
+
code: "MSL-Q900",
|
|
51
|
+
slug: "disable-without-rationale",
|
|
52
|
+
severity: "warning",
|
|
53
|
+
scoreContribution: 3,
|
|
54
|
+
group: "disable",
|
|
55
|
+
message: "disable-without-rationale: 'Markspec-disable' requires a companion 'Rationale' attribute",
|
|
56
|
+
location,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
// MSL-Q901: disable-unknown-rule — check each token in the list
|
|
60
|
+
const tokens = parseDisableValue(disableValue);
|
|
61
|
+
for (const token of tokens) {
|
|
62
|
+
if (!PA1_KNOWN_RULE_CODES.has(token)) {
|
|
63
|
+
out.push({
|
|
64
|
+
code: "MSL-Q901",
|
|
65
|
+
slug: "disable-unknown-rule",
|
|
66
|
+
severity: "warning",
|
|
67
|
+
scoreContribution: 3,
|
|
68
|
+
group: "disable",
|
|
69
|
+
message: `disable-unknown-rule: '${token}' is not a known lint rule code`,
|
|
70
|
+
location,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return out;
|
|
75
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/lint/runner
|
|
3
|
+
*
|
|
4
|
+
* Lint pipeline entry point. Filters entries to in-scope prose targets,
|
|
5
|
+
* runs lexicon and structural rules, runs suppression hygiene on all
|
|
6
|
+
* Authored entries, applies suppression, and returns the final diagnostics.
|
|
7
|
+
*/
|
|
8
|
+
import type { Entry } from "../model/mod.js";
|
|
9
|
+
import type { LintDiagnostic } from "./types.js";
|
|
10
|
+
/**
|
|
11
|
+
* Returns true when prose-analysis rules should run on this entry.
|
|
12
|
+
*
|
|
13
|
+
* In-scope: Authored shape AND resolved core type is Specification or
|
|
14
|
+
* a direct subtype (Requirement, Test, Contract, Record, Risk).
|
|
15
|
+
* Reference-shape entries are always excluded.
|
|
16
|
+
*/
|
|
17
|
+
export declare function isProseScope(entry: Entry): boolean;
|
|
18
|
+
export interface LintOptions {
|
|
19
|
+
readonly entries: readonly Entry[];
|
|
20
|
+
}
|
|
21
|
+
export interface LintResult {
|
|
22
|
+
readonly diagnostics: readonly LintDiagnostic[];
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Run the PA-1 lint pipeline on a set of entries.
|
|
26
|
+
*
|
|
27
|
+
* Pipeline:
|
|
28
|
+
* 1. Filter to in-scope entries (Specification subtypes, Authored shape).
|
|
29
|
+
* 2. Run lexicon rules on each in-scope entry's prose blocks.
|
|
30
|
+
* 3. Run structural rules on each in-scope entry.
|
|
31
|
+
* 4. Run suppression hygiene on ALL Authored entries.
|
|
32
|
+
* 5. Apply suppression: drop in-scope diagnostics where the entry's
|
|
33
|
+
* Markspec-disable list includes the rule's code and the entry
|
|
34
|
+
* has a Rationale. Suppression-hygiene diagnostics (Q900/Q901)
|
|
35
|
+
* are never suppressed.
|
|
36
|
+
* 6. Return remaining diagnostics.
|
|
37
|
+
*/
|
|
38
|
+
export declare function runLint(options: LintOptions): LintResult;
|
|
39
|
+
//# sourceMappingURL=runner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../src/lint/runner.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAG7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAmBjD;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAKlD;AAMD,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,OAAO,EAAE,SAAS,KAAK,EAAE,CAAC;CACpC;AAED,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,WAAW,EAAE,SAAS,cAAc,EAAE,CAAC;CACjD;AA4BD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,WAAW,GAAG,UAAU,CAoCxD"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/lint/runner
|
|
3
|
+
*
|
|
4
|
+
* Lint pipeline entry point. Filters entries to in-scope prose targets,
|
|
5
|
+
* runs lexicon and structural rules, runs suppression hygiene on all
|
|
6
|
+
* Authored entries, applies suppression, and returns the final diagnostics.
|
|
7
|
+
*/
|
|
8
|
+
import { CORE_TYPE_HIERARCHY } from "../model/mod.js";
|
|
9
|
+
import { resolvedCoreType } from "../validator/type_resolution.js";
|
|
10
|
+
import { runLexiconRules } from "./rules/lexicon.js";
|
|
11
|
+
import { runStructRules } from "./rules/struct.js";
|
|
12
|
+
import { parseDisableValue, runSuppressionRules } from "./rules/suppression.js";
|
|
13
|
+
// ---------------------------------------------------------------------------
|
|
14
|
+
// In-scope predicate
|
|
15
|
+
// ---------------------------------------------------------------------------
|
|
16
|
+
/** Walk the CORE_TYPE_HIERARCHY parent chain to check ancestry. */
|
|
17
|
+
function isSpecificationDescendant(typeName) {
|
|
18
|
+
let cursor = typeName;
|
|
19
|
+
while (cursor !== null) {
|
|
20
|
+
if (cursor === "Specification")
|
|
21
|
+
return true;
|
|
22
|
+
cursor = CORE_TYPE_HIERARCHY[cursor]?.parent ?? null;
|
|
23
|
+
}
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Returns true when prose-analysis rules should run on this entry.
|
|
28
|
+
*
|
|
29
|
+
* In-scope: Authored shape AND resolved core type is Specification or
|
|
30
|
+
* a direct subtype (Requirement, Test, Contract, Record, Risk).
|
|
31
|
+
* Reference-shape entries are always excluded.
|
|
32
|
+
*/
|
|
33
|
+
export function isProseScope(entry) {
|
|
34
|
+
if (entry.shape === "Reference")
|
|
35
|
+
return false;
|
|
36
|
+
const coreType = resolvedCoreType(entry);
|
|
37
|
+
if (!coreType)
|
|
38
|
+
return false;
|
|
39
|
+
return isSpecificationDescendant(coreType);
|
|
40
|
+
}
|
|
41
|
+
// ---------------------------------------------------------------------------
|
|
42
|
+
// Suppression application
|
|
43
|
+
// ---------------------------------------------------------------------------
|
|
44
|
+
/** Parse the Markspec-disable list for an entry into a Set of codes/slugs. */
|
|
45
|
+
function disabledCodes(entry) {
|
|
46
|
+
for (const attr of entry.rawAttributes) {
|
|
47
|
+
if (attr.key === "Markspec-disable") {
|
|
48
|
+
return new Set(parseDisableValue(attr.value));
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return new Set();
|
|
52
|
+
}
|
|
53
|
+
/** Return whether the entry has a non-empty Rationale attribute. */
|
|
54
|
+
function hasRationale(entry) {
|
|
55
|
+
for (const attr of entry.rawAttributes) {
|
|
56
|
+
if (attr.key === "Rationale" && attr.value.trim().length > 0)
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
// ---------------------------------------------------------------------------
|
|
62
|
+
// runLint
|
|
63
|
+
// ---------------------------------------------------------------------------
|
|
64
|
+
/**
|
|
65
|
+
* Run the PA-1 lint pipeline on a set of entries.
|
|
66
|
+
*
|
|
67
|
+
* Pipeline:
|
|
68
|
+
* 1. Filter to in-scope entries (Specification subtypes, Authored shape).
|
|
69
|
+
* 2. Run lexicon rules on each in-scope entry's prose blocks.
|
|
70
|
+
* 3. Run structural rules on each in-scope entry.
|
|
71
|
+
* 4. Run suppression hygiene on ALL Authored entries.
|
|
72
|
+
* 5. Apply suppression: drop in-scope diagnostics where the entry's
|
|
73
|
+
* Markspec-disable list includes the rule's code and the entry
|
|
74
|
+
* has a Rationale. Suppression-hygiene diagnostics (Q900/Q901)
|
|
75
|
+
* are never suppressed.
|
|
76
|
+
* 6. Return remaining diagnostics.
|
|
77
|
+
*/
|
|
78
|
+
export function runLint(options) {
|
|
79
|
+
const { entries } = options;
|
|
80
|
+
// Step 1–3: collect diagnostics keyed by entry
|
|
81
|
+
const inScopeDiags = new Map();
|
|
82
|
+
for (const entry of entries) {
|
|
83
|
+
if (!isProseScope(entry))
|
|
84
|
+
continue;
|
|
85
|
+
const diags = [];
|
|
86
|
+
diags.push(...runLexiconRules(entry));
|
|
87
|
+
diags.push(...runStructRules(entry));
|
|
88
|
+
inScopeDiags.set(entry, diags);
|
|
89
|
+
}
|
|
90
|
+
// Step 4: suppression hygiene on all Authored entries
|
|
91
|
+
const hygieneDiags = [];
|
|
92
|
+
for (const entry of entries) {
|
|
93
|
+
if (entry.shape !== "Authored")
|
|
94
|
+
continue;
|
|
95
|
+
hygieneDiags.push(...runSuppressionRules(entry));
|
|
96
|
+
}
|
|
97
|
+
// Step 5: apply suppression to in-scope diagnostics
|
|
98
|
+
const out = [];
|
|
99
|
+
for (const [entry, diags] of inScopeDiags) {
|
|
100
|
+
const disabled = disabledCodes(entry);
|
|
101
|
+
const entryHasRationale = hasRationale(entry);
|
|
102
|
+
for (const diag of diags) {
|
|
103
|
+
// Suppression requires both a matching code AND a Rationale.
|
|
104
|
+
if (entryHasRationale && disabled.has(diag.code))
|
|
105
|
+
continue;
|
|
106
|
+
out.push(diag);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
// Step 6: append hygiene diagnostics (never suppressed)
|
|
110
|
+
out.push(...hygieneDiags);
|
|
111
|
+
return { diagnostics: out };
|
|
112
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/lint/types
|
|
3
|
+
*
|
|
4
|
+
* LintDiagnostic — prose-quality diagnostic type, extending the core
|
|
5
|
+
* Diagnostic interface with slug, group, and score metadata. Kept
|
|
6
|
+
* separate from core Diagnostic to prevent slug/group fields from
|
|
7
|
+
* leaking into validate/compile JSON output, which has a stable schema.
|
|
8
|
+
*/
|
|
9
|
+
import type { Diagnostic } from "../model/mod.js";
|
|
10
|
+
/** A prose-quality diagnostic with slug and group metadata. */
|
|
11
|
+
export interface LintDiagnostic extends Diagnostic {
|
|
12
|
+
/** Human-readable rule slug, e.g. "incose-r7-vague-term". */
|
|
13
|
+
readonly slug: string;
|
|
14
|
+
/** Rule group: "ears" | "modal" | "incose" | "struct" | "xref" | "disable". */
|
|
15
|
+
readonly group: "ears" | "modal" | "incose" | "struct" | "xref" | "disable";
|
|
16
|
+
/** Entry-level score contribution for this firing. */
|
|
17
|
+
readonly scoreContribution: number;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lint/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,+DAA+D;AAC/D,MAAM,WAAW,cAAe,SAAQ,UAAU;IAChD,6DAA6D;IAC7D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,+EAA+E;IAC/E,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,CAAC;IAC5E,sDAAsD;IACtD,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;CACpC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/lint/types
|
|
3
|
+
*
|
|
4
|
+
* LintDiagnostic — prose-quality diagnostic type, extending the core
|
|
5
|
+
* Diagnostic interface with slug, group, and score metadata. Kept
|
|
6
|
+
* separate from core Diagnostic to prevent slug/group fields from
|
|
7
|
+
* leaking into validate/compile JSON output, which has a stable schema.
|
|
8
|
+
*/
|
|
9
|
+
export {};
|
package/esm/mod.d.ts
CHANGED
|
@@ -8,23 +8,36 @@
|
|
|
8
8
|
* from core/mod.ts, never from internal paths.
|
|
9
9
|
*/
|
|
10
10
|
import "./_dnt.polyfills.js";
|
|
11
|
-
export declare const VERSION = "0.0
|
|
12
|
-
export
|
|
13
|
-
export
|
|
11
|
+
export declare const VERSION = "0.5.0";
|
|
12
|
+
export declare const CORE_SCHEMA_VERSION = 1;
|
|
13
|
+
export { ConfigError, DEFAULT_PROJECT_CONFIG, PALETTE_HUES, REFHUB_URL, } from "./model/mod.js";
|
|
14
|
+
export type { Attribute, Caption, CaptionConventions, CaptionPosition, ConfigFieldError, Diagnostic, Directive, DisplayId, EffectiveProfile, EffectiveTypeDef, EntityRef, EntityRefConvention, Entry, EntryShape, EntrySource, InlineRef, LabelConcern, LabelConcernKind, LabelValue, Link, LinkKind, PaletteHue, ProfileChain, ProfileConvention, ProjectConfig, ProvenancedMap, ProvenancedMapEntry, ProvenancedValue, Severity, SourceLocation, Ulid, } from "./model/mod.js";
|
|
15
|
+
export { astEquivalent } from "./ast/equivalence.js";
|
|
16
|
+
export { normalizeBodyAst } from "./ast/normalize.js";
|
|
17
|
+
export { render } from "./ast/render.js";
|
|
18
|
+
export type { AdmonitionKind, BlockquoteNode, BodyBlock, CaptionNode, CodeNode, DefinitionListNode, DefinitionPair, EntityRefMarker, FeatureNode, FigureNode, InlineContent, InlineMarker, ListItemNode, ListNode, MathNode, ModalMarker, ModalMarkerClass, NoteNode, ParagraphNode, SourceRange, TableNode, UnknownNode, } from "./ast/nodes.js";
|
|
14
19
|
export { discoverProjectRoot, loadConfig, parseProjectConfig, } from "./config/mod.js";
|
|
15
20
|
export type { LoadConfigResult, ReadFile } from "./config/mod.js";
|
|
16
|
-
export { MARKSPEC_YAML_FILENAME, parseMarkspecYaml, readMarkspecYaml, } from "./config/markspec.js";
|
|
21
|
+
export { addProfileSpecifier, MARKSPEC_YAML_FILENAME, parseMarkspecYaml, readMarkspecYaml, } from "./config/markspec.js";
|
|
17
22
|
export type { MarkspecYaml, ParseMarkspecYamlResult, } from "./config/markspec.js";
|
|
18
|
-
export { computeCacheKey, computeCacheLocation, defaultAppendFile, defaultRunGit, ensureCacheGitignored, loadChain, loadProfileForCommand, mergeChain, parseManifest, resolveGitSpecifier, resolveLocalSpecifier, } from "./profile/mod.js";
|
|
23
|
+
export { computeCacheKey, computeCacheLocation, defaultAppendFile, defaultRunGit, ensureCacheGitignored, loadChain, loadProfileForCommand, mergeChain, parseManifest, resolveEntryColor, resolveGitSpecifier, resolveLocalSpecifier, } from "./profile/mod.js";
|
|
19
24
|
export type { AppendFile, CacheLocation, GitCacheKeyInput, LoadChainOptions, LoadChainResult, LoadProfileForCommandResult, MergeResult, ParseManifestResult, ResolvedProfileSource, ResolveGitOptions, RunGit, RunGitResult, } from "./profile/mod.js";
|
|
25
|
+
export { buildProfileIntrospection } from "./profile/mod.js";
|
|
26
|
+
export type { AttributeDetail, ConventionDetail, LabelConcernDetail, ProfileElementDetail, ProfileElementKind, ProfileElementRef, ProfileIntrospection, ProfileOverview, ProvenancedDescription, RelationDetail, TypeDetail, } from "./profile/mod.js";
|
|
20
27
|
export { detectCaptions, detectDirectives, detectInlineRefs, isSupportedExtension, loadGrammar, parse, parseFile, parseSource, } from "./parser/mod.js";
|
|
21
28
|
export type { DetectCaptionsOptions, DetectDirectivesOptions, DetectInlineRefsOptions, ParseFileResult, ParseOptions, ParseSourceOptions, ParseSourceResult, } from "./parser/mod.js";
|
|
22
29
|
export { format } from "./formatter/mod.js";
|
|
23
30
|
export type { FormatOptions, FormatResult } from "./formatter/mod.js";
|
|
24
|
-
export { classifyEntriesStage, classifyEntry, compileDisplayIdPattern, effectiveScope, effectiveTraceRules, matchesAnyTarget, normalizeListValues, runPipeline, validate, validateAttributesForEntry, validateTraceabilityForEntry, validateValue, } from "./validator/mod.js";
|
|
25
|
-
export type { ClassifyResult, ClassifyStageResult, EffectiveAttrScope, PipelineResult, ValidateResult, ValueValidator, } from "./validator/mod.js";
|
|
31
|
+
export { classifyEntriesStage, classifyEntry, compileDisplayIdPattern, effectiveScope, effectiveTraceRules, matchesAnyTarget, normalizeListValues, runPipeline, validate, validateAttributesForEntry, validateListingDocuments, validateTraceabilityForEntry, validateValue, } from "./validator/mod.js";
|
|
32
|
+
export type { ClassifyResult, ClassifyStageResult, EffectiveAttrScope, ListingFileContext, ListingKind, PipelineResult, ValidateResult, ValueValidator, } from "./validator/mod.js";
|
|
26
33
|
export { compile, generateInverses, serializeCompileResult, } from "./compiler/mod.js";
|
|
27
|
-
export type { CompileOptions, CompileResult, GenerateInversesResult, SerializedCompileResult, } from "./compiler/mod.js";
|
|
34
|
+
export type { CompileOptions, CompileResult, GenerateInversesResult, SerializedCompileResult, SerializedEntry, } from "./compiler/mod.js";
|
|
35
|
+
export { buildManifest } from "./compiler/manifest.js";
|
|
36
|
+
export type { ManifestEdgesBlock, ManifestEntriesBlock, ManifestJson, } from "./compiler/manifest.js";
|
|
37
|
+
export { buildEdgesNdjson, buildEntriesNdjson, indexToJson, } from "./compiler/ndjson_writer.js";
|
|
38
|
+
export type { EntriesNdjsonResult, EntryOffset, } from "./compiler/ndjson_writer.js";
|
|
28
39
|
export { report } from "./reporter/mod.js";
|
|
29
40
|
export type { ReportFormat, ReportKind, ReportOptions, } from "./reporter/mod.js";
|
|
41
|
+
export { isProseScope, runLint } from "./lint/mod.js";
|
|
42
|
+
export type { LintDiagnostic, LintOptions, LintResult } from "./lint/mod.js";
|
|
30
43
|
//# sourceMappingURL=mod.d.ts.map
|
package/esm/mod.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,qBAAqB,CAAC;AAG7B,eAAO,MAAM,OAAO,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,qBAAqB,CAAC;AAG7B,eAAO,MAAM,OAAO,UAAU,CAAC;AAC/B,eAAO,MAAM,mBAAmB,IAAI,CAAC;AAGrC,OAAO,EACL,WAAW,EACX,sBAAsB,EACtB,YAAY,EACZ,UAAU,GACX,MAAM,gBAAgB,CAAC;AACxB,YAAY,EACV,SAAS,EACT,OAAO,EACP,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EAChB,UAAU,EACV,SAAS,EACT,SAAS,EACT,gBAAgB,EAChB,gBAAgB,EAChB,SAAS,EACT,mBAAmB,EACnB,KAAK,EACL,UAAU,EACV,WAAW,EACX,SAAS,EACT,YAAY,EACZ,gBAAgB,EAChB,UAAU,EACV,IAAI,EACJ,QAAQ,EACR,UAAU,EACV,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACb,cAAc,EACd,mBAAmB,EACnB,gBAAgB,EAChB,QAAQ,EACR,cAAc,EACd,IAAI,GACL,MAAM,gBAAgB,CAAC;AAIxB,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,YAAY,EACV,cAAc,EACd,cAAc,EACd,SAAS,EACT,WAAW,EACX,QAAQ,EACR,kBAAkB,EAClB,cAAc,EACd,eAAe,EACf,WAAW,EACX,UAAU,EACV,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,gBAAgB,EAChB,QAAQ,EACR,aAAa,EACb,WAAW,EACX,SAAS,EACT,WAAW,GACZ,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EACL,mBAAmB,EACnB,UAAU,EACV,kBAAkB,GACnB,MAAM,iBAAiB,CAAC;AACzB,YAAY,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAElE,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EACV,YAAY,EACZ,uBAAuB,GACxB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,iBAAiB,EACjB,aAAa,EACb,qBAAqB,EACrB,SAAS,EACT,qBAAqB,EACrB,UAAU,EACV,aAAa,EACb,iBAAiB,EACjB,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EACV,UAAU,EACV,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,2BAA2B,EAC3B,WAAW,EACX,mBAAmB,EACnB,qBAAqB,EACrB,iBAAiB,EACjB,MAAM,EACN,YAAY,GACb,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAC7D,YAAY,EACV,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAClB,oBAAoB,EACpB,kBAAkB,EAClB,iBAAiB,EACjB,oBAAoB,EACpB,eAAe,EACf,sBAAsB,EACtB,cAAc,EACd,UAAU,GACX,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,oBAAoB,EACpB,WAAW,EACX,KAAK,EACL,SAAS,EACT,WAAW,GACZ,MAAM,iBAAiB,CAAC;AACzB,YAAY,EACV,qBAAqB,EACrB,uBAAuB,EACvB,uBAAuB,EACvB,eAAe,EACf,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGtE,OAAO,EACL,oBAAoB,EACpB,aAAa,EACb,uBAAuB,EACvB,cAAc,EACd,mBAAmB,EACnB,gBAAgB,EAChB,mBAAmB,EACnB,WAAW,EACX,QAAQ,EACR,0BAA0B,EAC1B,wBAAwB,EACxB,4BAA4B,EAC5B,aAAa,GACd,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACV,cAAc,EACd,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,WAAW,EACX,cAAc,EACd,cAAc,EACd,cAAc,GACf,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EACL,OAAO,EACP,gBAAgB,EAChB,sBAAsB,GACvB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EACV,cAAc,EACd,aAAa,EACb,sBAAsB,EACtB,uBAAuB,EACvB,eAAe,GAChB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,YAAY,EACV,kBAAkB,EAClB,oBAAoB,EACpB,YAAY,GACb,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,WAAW,GACZ,MAAM,6BAA6B,CAAC;AACrC,YAAY,EACV,mBAAmB,EACnB,WAAW,GACZ,MAAM,6BAA6B,CAAC;AAGrC,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,YAAY,EACV,YAAY,EACZ,UAAU,EACV,aAAa,GACd,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACtD,YAAY,EAAE,cAAc,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC"}
|