@blockml/validator 0.9.4 → 0.9.5
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/blocks/org/blockml/bml/compiler/validator/Library.bml +26 -27
- package/blocks/org/blockml/bml/compiler/validator/README.bml +15 -22
- package/blocks/org/blockml/bml/compiler/validator/ValidatorType.bml +16 -20
- package/blocks/org/blockml/bml/compiler/validator/capability/Validate.bml +23 -23
- package/blocks/org/blockml/bml/compiler/validator/capability/ValidateStyle.bml +20 -22
- package/blocks/org/blockml/bml/compiler/validator/documentation/DesignDecisions.bml +21 -26
- package/blocks/org/blockml/bml/compiler/validator/documentation/Diagnostics.bml +21 -25
- package/blocks/org/blockml/bml/compiler/validator/documentation/Introduction.bml +20 -26
- package/blocks/org/blockml/bml/compiler/validator/documentation/LayerSeparation.bml +18 -23
- package/blocks/org/blockml/bml/compiler/validator/documentation/PackageOwnership.bml +20 -26
- package/blocks/org/blockml/bml/compiler/validator/documentation/PublicApi.bml +18 -23
- package/blocks/org/blockml/bml/compiler/validator/documentation/ScopeExclusions.bml +16 -21
- package/blocks/org/blockml/bml/compiler/validator/documentation/ValidationPipeline.bml +17 -22
- package/blocks/org/blockml/bml/compiler/validator/documentation/ValidityContract.bml +19 -24
- package/blocks/org/blockml/bml/compiler/validator/style/PreferCDataWhenNeedsEscape.bml +14 -18
- package/blocks/org/blockml/bml/compiler/validator/style/PreferEmptyElementSelfClosing.bml +14 -18
- package/blocks/org/blockml/bml/compiler/validator/style/PreferMarkdownStructure.bml +14 -18
- package/blocks/org/blockml/bml/compiler/validator/style/PreferOmitRedundantName.bml +15 -0
- package/blocks/org/blockml/bml/compiler/validator/style/PreferOmitRedundantType.bml +15 -0
- package/blocks/org/blockml/bml/compiler/validator/style/PreferTypeAsTag.bml +15 -0
- package/blocks/org/blockml/bml/compiler/validator/style/StyleCheck.bml +17 -20
- package/blocks/org/blockml/bml/compiler/validator/style/StyleRule.bml +29 -25
- package/blocks/org/blockml/bml/compiler/validator/style/rule/CDataWhenEscaping.bml +15 -21
- package/blocks/org/blockml/bml/compiler/validator/style/rule/EmptyElementSelfClosing.bml +15 -21
- package/blocks/org/blockml/bml/compiler/validator/style/rule/MarkdownStructure.bml +15 -21
- package/blocks/org/blockml/bml/compiler/validator/style/rule/OmitRedundantName.bml +39 -0
- package/blocks/org/blockml/bml/compiler/validator/style/rule/OmitRedundantType.bml +39 -0
- package/blocks/org/blockml/bml/compiler/validator/style/rule/TypeAsTag.bml +38 -0
- package/dist/validate-style.d.ts.map +1 -1
- package/dist/validate-style.js +49 -10
- package/dist/validate-style.js.map +1 -1
- package/package.json +4 -4
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
<!--
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
-->
|
|
5
|
-
<block
|
|
6
|
-
xmlns="http://blockml.org/bml"
|
|
7
|
-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
8
|
-
xsi:schemaLocation="http://blockml.org/bml https://blockml.org/schemas/bml.xsd
|
|
9
|
-
"
|
|
1
|
+
<!--Validator Style Rule — CDataWhenEscaping
|
|
2
|
+
FQN: org.blockml.bml.compiler.validator.style.CDataWhenEscaping-->
|
|
3
|
+
<valstyle:CDataWhenEscaping xmlns="http://blockml.org/bml"
|
|
10
4
|
xmlns:blockml="org.blockml.bml"
|
|
11
5
|
xmlns:bom="org.blockml.bml.bom"
|
|
12
6
|
xmlns:bomcommon="org.blockml.bml.bom.common"
|
|
@@ -16,14 +10,16 @@
|
|
|
16
10
|
xmlns:validator="org.blockml.bml.compiler.validator"
|
|
17
11
|
xmlns:valstyle="org.blockml.bml.compiler.validator.style">
|
|
18
12
|
|
|
19
|
-
<
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
<is>
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
13
|
+
<baseType>
|
|
14
|
+
valstyle:StyleRule
|
|
15
|
+
</baseType>
|
|
16
|
+
<is>
|
|
17
|
+
Recommend CDATA for documentation that needs XML escaping
|
|
18
|
+
</is>
|
|
19
|
+
<documentation>
|
|
20
|
+
Block-level documentation whose text contains markup characters should use CDATA
|
|
21
|
+
instead of entity escaping so humans can read the source.
|
|
22
|
+
</documentation>
|
|
27
23
|
<properties>
|
|
28
24
|
<code override="true">
|
|
29
25
|
<value>BML_STYLE_PREFER_CDATA</value>
|
|
@@ -38,13 +34,11 @@
|
|
|
38
34
|
<value>Use CDATA instead of XML entity escaping in documentation.</value>
|
|
39
35
|
</message>
|
|
40
36
|
</properties>
|
|
41
|
-
|
|
42
37
|
<aggregations>
|
|
43
|
-
<check>
|
|
38
|
+
<check override="true">
|
|
44
39
|
<composition>
|
|
45
40
|
<valstyle:PreferCDataWhenNeedsEscape />
|
|
46
41
|
</composition>
|
|
47
42
|
</check>
|
|
48
43
|
</aggregations>
|
|
49
|
-
|
|
50
|
-
</block>
|
|
44
|
+
</valstyle:CDataWhenEscaping>
|
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
<!--
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
-->
|
|
5
|
-
<block
|
|
6
|
-
xmlns="http://blockml.org/bml"
|
|
7
|
-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
8
|
-
xsi:schemaLocation="http://blockml.org/bml https://blockml.org/schemas/bml.xsd
|
|
9
|
-
"
|
|
1
|
+
<!--Validator Style Rule — EmptyElementSelfClosing
|
|
2
|
+
FQN: org.blockml.bml.compiler.validator.style.EmptyElementSelfClosing-->
|
|
3
|
+
<valstyle:EmptyElementSelfClosing xmlns="http://blockml.org/bml"
|
|
10
4
|
xmlns:blockml="org.blockml.bml"
|
|
11
5
|
xmlns:bom="org.blockml.bml.bom"
|
|
12
6
|
xmlns:bomcommon="org.blockml.bml.bom.common"
|
|
@@ -16,14 +10,16 @@
|
|
|
16
10
|
xmlns:validator="org.blockml.bml.compiler.validator"
|
|
17
11
|
xmlns:valstyle="org.blockml.bml.compiler.validator.style">
|
|
18
12
|
|
|
19
|
-
<
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
<is>
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
13
|
+
<baseType>
|
|
14
|
+
valstyle:StyleRule
|
|
15
|
+
</baseType>
|
|
16
|
+
<is>
|
|
17
|
+
Require self-closing form for empty see references
|
|
18
|
+
</is>
|
|
19
|
+
<documentation>
|
|
20
|
+
Empty see tags should be written as self-closing elements:
|
|
21
|
+
see with attributes and slash, not a paired open-close with no body.
|
|
22
|
+
</documentation>
|
|
27
23
|
<properties>
|
|
28
24
|
<code override="true">
|
|
29
25
|
<value>BML_STYLE_EMPTY_ELEMENT_SELF_CLOSE</value>
|
|
@@ -38,13 +34,11 @@
|
|
|
38
34
|
<value>Write empty elements as self-closing tags.</value>
|
|
39
35
|
</message>
|
|
40
36
|
</properties>
|
|
41
|
-
|
|
42
37
|
<aggregations>
|
|
43
|
-
<check>
|
|
38
|
+
<check override="true">
|
|
44
39
|
<composition>
|
|
45
40
|
<valstyle:PreferEmptyElementSelfClosing />
|
|
46
41
|
</composition>
|
|
47
42
|
</check>
|
|
48
43
|
</aggregations>
|
|
49
|
-
|
|
50
|
-
</block>
|
|
44
|
+
</valstyle:EmptyElementSelfClosing>
|
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
<!--
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
-->
|
|
5
|
-
<block
|
|
6
|
-
xmlns="http://blockml.org/bml"
|
|
7
|
-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
8
|
-
xsi:schemaLocation="http://blockml.org/bml https://blockml.org/schemas/bml.xsd
|
|
9
|
-
"
|
|
1
|
+
<!--Validator Style Rule — MarkdownStructure
|
|
2
|
+
FQN: org.blockml.bml.compiler.validator.style.MarkdownStructure-->
|
|
3
|
+
<valstyle:MarkdownStructure xmlns="http://blockml.org/bml"
|
|
10
4
|
xmlns:blockml="org.blockml.bml"
|
|
11
5
|
xmlns:bom="org.blockml.bml.bom"
|
|
12
6
|
xmlns:bomcommon="org.blockml.bml.bom.common"
|
|
@@ -16,14 +10,16 @@
|
|
|
16
10
|
xmlns:validator="org.blockml.bml.compiler.validator"
|
|
17
11
|
xmlns:valstyle="org.blockml.bml.compiler.validator.style">
|
|
18
12
|
|
|
19
|
-
<
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
<is>
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
13
|
+
<baseType>
|
|
14
|
+
valstyle:StyleRule
|
|
15
|
+
</baseType>
|
|
16
|
+
<is>
|
|
17
|
+
Recommend markdown structure for long unstructured documentation
|
|
18
|
+
</is>
|
|
19
|
+
<documentation>
|
|
20
|
+
Long block-level documentation should use markdown headings, lists, or blank-line
|
|
21
|
+
paragraphs instead of a single run-on text block.
|
|
22
|
+
</documentation>
|
|
27
23
|
<properties>
|
|
28
24
|
<code override="true">
|
|
29
25
|
<value>BML_STYLE_PREFER_MARKDOWN</value>
|
|
@@ -38,13 +34,11 @@
|
|
|
38
34
|
<value>Structure long documentation with markdown (headings, lists, or paragraphs).</value>
|
|
39
35
|
</message>
|
|
40
36
|
</properties>
|
|
41
|
-
|
|
42
37
|
<aggregations>
|
|
43
|
-
<check>
|
|
38
|
+
<check override="true">
|
|
44
39
|
<composition>
|
|
45
40
|
<valstyle:PreferMarkdownStructure />
|
|
46
41
|
</composition>
|
|
47
42
|
</check>
|
|
48
43
|
</aggregations>
|
|
49
|
-
|
|
50
|
-
</block>
|
|
44
|
+
</valstyle:MarkdownStructure>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Validator Style Rule — OmitRedundantName
|
|
3
|
+
FQN: org.blockml.bml.compiler.validator.style.OmitRedundantName
|
|
4
|
+
-->
|
|
5
|
+
<style:OmitRedundantName
|
|
6
|
+
xmlns="http://blockml.org/bml"
|
|
7
|
+
xmlns:style="org.blockml.bml.compiler.validator.style">
|
|
8
|
+
|
|
9
|
+
<baseType>style:StyleRule</baseType>
|
|
10
|
+
<is>Omit child name when the element tag already supplies the name</is>
|
|
11
|
+
|
|
12
|
+
<documentation>On a preferred-form definition the element tag is the name
|
|
13
|
+
(Sub-Block) or lastSegment of the type (root / embed). A child name
|
|
14
|
+
element is redundant (doc:DocumentFormat).</documentation>
|
|
15
|
+
|
|
16
|
+
<properties>
|
|
17
|
+
<code override="true">
|
|
18
|
+
<value>BML_STYLE_REDUNDANT_NAME</value>
|
|
19
|
+
</code>
|
|
20
|
+
<severity override="true">
|
|
21
|
+
<value>warning</value>
|
|
22
|
+
</severity>
|
|
23
|
+
<appliesTo override="true">
|
|
24
|
+
<value>preferred-form definition</value>
|
|
25
|
+
</appliesTo>
|
|
26
|
+
<message override="true">
|
|
27
|
+
<value>Omit child name when the element tag already supplies the name.</value>
|
|
28
|
+
</message>
|
|
29
|
+
</properties>
|
|
30
|
+
|
|
31
|
+
<aggregations>
|
|
32
|
+
<check override="true">
|
|
33
|
+
<composition>
|
|
34
|
+
<style:PreferOmitRedundantName />
|
|
35
|
+
</composition>
|
|
36
|
+
</check>
|
|
37
|
+
</aggregations>
|
|
38
|
+
|
|
39
|
+
</style:OmitRedundantName>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Validator Style Rule — OmitRedundantType
|
|
3
|
+
FQN: org.blockml.bml.compiler.validator.style.OmitRedundantType
|
|
4
|
+
-->
|
|
5
|
+
<style:OmitRedundantType
|
|
6
|
+
xmlns="http://blockml.org/bml"
|
|
7
|
+
xmlns:style="org.blockml.bml.compiler.validator.style">
|
|
8
|
+
|
|
9
|
+
<baseType>style:StyleRule</baseType>
|
|
10
|
+
<is>Omit child type when the element tag already supplies the type</is>
|
|
11
|
+
|
|
12
|
+
<documentation>On a preferred-form definition the element tag is the type
|
|
13
|
+
(root / embed) or the type is derived (Sub-Block). A child type
|
|
14
|
+
element is redundant (doc:DocumentFormat).</documentation>
|
|
15
|
+
|
|
16
|
+
<properties>
|
|
17
|
+
<code override="true">
|
|
18
|
+
<value>BML_STYLE_REDUNDANT_TYPE</value>
|
|
19
|
+
</code>
|
|
20
|
+
<severity override="true">
|
|
21
|
+
<value>warning</value>
|
|
22
|
+
</severity>
|
|
23
|
+
<appliesTo override="true">
|
|
24
|
+
<value>preferred-form definition</value>
|
|
25
|
+
</appliesTo>
|
|
26
|
+
<message override="true">
|
|
27
|
+
<value>Omit child type when the element tag already supplies the type.</value>
|
|
28
|
+
</message>
|
|
29
|
+
</properties>
|
|
30
|
+
|
|
31
|
+
<aggregations>
|
|
32
|
+
<check override="true">
|
|
33
|
+
<composition>
|
|
34
|
+
<style:PreferOmitRedundantType />
|
|
35
|
+
</composition>
|
|
36
|
+
</check>
|
|
37
|
+
</aggregations>
|
|
38
|
+
|
|
39
|
+
</style:OmitRedundantType>
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Validator Style Rule — TypeAsTag
|
|
3
|
+
FQN: org.blockml.bml.compiler.validator.style.TypeAsTag
|
|
4
|
+
-->
|
|
5
|
+
<style:TypeAsTag
|
|
6
|
+
xmlns="http://blockml.org/bml"
|
|
7
|
+
xmlns:style="org.blockml.bml.compiler.validator.style">
|
|
8
|
+
|
|
9
|
+
<baseType>style:StyleRule</baseType>
|
|
10
|
+
<is>Prefer type-or-name tags over the legacy block wrapper</is>
|
|
11
|
+
|
|
12
|
+
<documentation>The legacy block wrapper remains valid. New and edited definitions
|
|
13
|
+
should use the type-or-name tag (doc:DocumentFormat).</documentation>
|
|
14
|
+
|
|
15
|
+
<properties>
|
|
16
|
+
<code override="true">
|
|
17
|
+
<value>BML_STYLE_LEGACY_BLOCK_WRAPPER</value>
|
|
18
|
+
</code>
|
|
19
|
+
<severity override="true">
|
|
20
|
+
<value>warning</value>
|
|
21
|
+
</severity>
|
|
22
|
+
<appliesTo override="true">
|
|
23
|
+
<value>definition wrapper</value>
|
|
24
|
+
</appliesTo>
|
|
25
|
+
<message override="true">
|
|
26
|
+
<value>Prefer a type-or-name tag instead of the legacy block wrapper.</value>
|
|
27
|
+
</message>
|
|
28
|
+
</properties>
|
|
29
|
+
|
|
30
|
+
<aggregations>
|
|
31
|
+
<check override="true">
|
|
32
|
+
<composition>
|
|
33
|
+
<style:PreferTypeAsTag />
|
|
34
|
+
</composition>
|
|
35
|
+
</check>
|
|
36
|
+
</aggregations>
|
|
37
|
+
|
|
38
|
+
</style:TypeAsTag>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-style.d.ts","sourceRoot":"","sources":["../src/validate-style.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAEV,WAAW,EACX,UAAU,EACV,kBAAkB,EAGnB,MAAM,cAAc,CAAC;AAItB,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf;
|
|
1
|
+
{"version":3,"file":"validate-style.d.ts","sourceRoot":"","sources":["../src/validate-style.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAEV,WAAW,EACX,UAAU,EACV,kBAAkB,EAGnB,MAAM,cAAc,CAAC;AAItB,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf;AAiPD,wBAAgB,aAAa,CAAC,QAAQ,EAAE,WAAW,GAAG,UAAU,EAAE,CAmBjE"}
|
package/dist/validate-style.js
CHANGED
|
@@ -24,6 +24,27 @@ const FALLBACK_RULES = [
|
|
|
24
24
|
message: "Write empty elements as self-closing tags.",
|
|
25
25
|
check: "PreferEmptyElementSelfClosing",
|
|
26
26
|
},
|
|
27
|
+
{
|
|
28
|
+
name: "TypeAsTag",
|
|
29
|
+
code: "BML_STYLE_LEGACY_BLOCK_WRAPPER",
|
|
30
|
+
severity: "warning",
|
|
31
|
+
message: "Prefer a type-or-name tag instead of the legacy block wrapper.",
|
|
32
|
+
check: "PreferTypeAsTag",
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: "OmitRedundantType",
|
|
36
|
+
code: "BML_STYLE_REDUNDANT_TYPE",
|
|
37
|
+
severity: "warning",
|
|
38
|
+
message: "Omit child type when the element tag already supplies the type.",
|
|
39
|
+
check: "PreferOmitRedundantType",
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: "OmitRedundantName",
|
|
43
|
+
code: "BML_STYLE_REDUNDANT_NAME",
|
|
44
|
+
severity: "warning",
|
|
45
|
+
message: "Omit child name when the element tag already supplies the name.",
|
|
46
|
+
check: "PreferOmitRedundantName",
|
|
47
|
+
},
|
|
27
48
|
];
|
|
28
49
|
function styleRuleDir() {
|
|
29
50
|
const here = dirname(fileURLToPath(import.meta.url));
|
|
@@ -52,7 +73,7 @@ function loadStyleCatalog() {
|
|
|
52
73
|
continue;
|
|
53
74
|
}
|
|
54
75
|
const text = readFileSync(join(dir, entry), "utf8");
|
|
55
|
-
const name = text.match(/<name>([^<]+)<\/name>/)?.[1]?.trim();
|
|
76
|
+
const name = text.match(/<name>([^<]+)<\/name>/)?.[1]?.trim() ?? entry.replace(/\.bml$/, "");
|
|
56
77
|
const code = propertyValue(text, "code");
|
|
57
78
|
const severity = propertyValue(text, "severity");
|
|
58
79
|
const message = propertyValue(text, "message");
|
|
@@ -84,13 +105,13 @@ function styleDiag(rule, file, source) {
|
|
|
84
105
|
source: loc(file, source),
|
|
85
106
|
};
|
|
86
107
|
}
|
|
87
|
-
function walkBlocks(block, visit) {
|
|
88
|
-
visit(block);
|
|
108
|
+
function walkBlocks(block, role, visit) {
|
|
109
|
+
visit(block, role);
|
|
89
110
|
for (const sub of block.subBlocks) {
|
|
90
|
-
walkBlocks(sub, visit);
|
|
111
|
+
walkBlocks(sub, "subBlock", visit);
|
|
91
112
|
}
|
|
92
113
|
for (const emb of block.embeddedBlocks) {
|
|
93
|
-
walkBlocks(emb, visit);
|
|
114
|
+
walkBlocks(emb, "embedded", visit);
|
|
94
115
|
}
|
|
95
116
|
}
|
|
96
117
|
function collectReferences(block) {
|
|
@@ -100,21 +121,36 @@ function collectReferences(block) {
|
|
|
100
121
|
}
|
|
101
122
|
return refs;
|
|
102
123
|
}
|
|
103
|
-
function
|
|
124
|
+
function runPreferTypeAsTag(rule, block, _role, file, out) {
|
|
125
|
+
if (block.wrapperForm === "block") {
|
|
126
|
+
out.push(styleDiag(rule, file, block.source));
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
function runPreferOmitRedundantType(rule, block, _role, file, out) {
|
|
130
|
+
if (block.wrapperForm === "type" && block.authoredTypeChild) {
|
|
131
|
+
out.push(styleDiag(rule, file, block.typeSource ?? block.source));
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
function runPreferOmitRedundantName(rule, block, _role, file, out) {
|
|
135
|
+
if (block.wrapperForm === "type" && block.authoredNameChild) {
|
|
136
|
+
out.push(styleDiag(rule, file, block.source));
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
function runPreferCData(rule, block, _role, file, out) {
|
|
104
140
|
for (const prose of block.documentations ?? []) {
|
|
105
141
|
if (needsCData(prose.text) && prose.authoredCharacterDataForm !== "cdata") {
|
|
106
142
|
out.push(styleDiag(rule, file, prose.source));
|
|
107
143
|
}
|
|
108
144
|
}
|
|
109
145
|
}
|
|
110
|
-
function runPreferMarkdown(rule, block, file, out) {
|
|
146
|
+
function runPreferMarkdown(rule, block, _role, file, out) {
|
|
111
147
|
for (const prose of block.documentations ?? []) {
|
|
112
148
|
if (prose.text.length > MARKDOWN_MIN_LENGTH && !hasMarkdownStructure(prose.text)) {
|
|
113
149
|
out.push(styleDiag(rule, file, prose.source));
|
|
114
150
|
}
|
|
115
151
|
}
|
|
116
152
|
}
|
|
117
|
-
function runPreferSelfClosing(rule, block, file, out) {
|
|
153
|
+
function runPreferSelfClosing(rule, block, _role, file, out) {
|
|
118
154
|
for (const ref of collectReferences(block)) {
|
|
119
155
|
if (ref.context.trim() === "" && ref.authoredEmptyElementForm === "paired") {
|
|
120
156
|
out.push(styleDiag(rule, file, ref.source));
|
|
@@ -125,6 +161,9 @@ const INTERPRETERS = {
|
|
|
125
161
|
PreferCDataWhenNeedsEscape: runPreferCData,
|
|
126
162
|
PreferMarkdownStructure: runPreferMarkdown,
|
|
127
163
|
PreferEmptyElementSelfClosing: runPreferSelfClosing,
|
|
164
|
+
PreferTypeAsTag: runPreferTypeAsTag,
|
|
165
|
+
PreferOmitRedundantType: runPreferOmitRedundantType,
|
|
166
|
+
PreferOmitRedundantName: runPreferOmitRedundantName,
|
|
128
167
|
};
|
|
129
168
|
export function validateStyle(document) {
|
|
130
169
|
const file = document.source.filePath;
|
|
@@ -140,8 +179,8 @@ export function validateStyle(document) {
|
|
|
140
179
|
});
|
|
141
180
|
continue;
|
|
142
181
|
}
|
|
143
|
-
walkBlocks(document.block, (block) => {
|
|
144
|
-
run(rule, block, file, diagnostics);
|
|
182
|
+
walkBlocks(document.block, "root", (block, role) => {
|
|
183
|
+
run(rule, block, role, file, diagnostics);
|
|
145
184
|
});
|
|
146
185
|
}
|
|
147
186
|
return diagnostics;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-style.js","sourceRoot":"","sources":["../src/validate-style.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAUzC,MAAM,mBAAmB,GAAG,GAAG,CAAC;AAUhC,MAAM,cAAc,GAAsB;IACxC;QACE,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QACrC,IAAI,CAAC,GAAG,EAAE,CAAC;YACT,WAAW,CAAC,IAAI,CAAC;gBACf,QAAQ,EAAE,MAAM;gBAChB,IAAI,EAAE,yBAAyB;gBAC/B,OAAO,EAAE,6BAA6B,IAAI,CAAC,KAAK,EAAE;gBAClD,MAAM,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE;aACrC,CAAC,CAAC;YACH,SAAS;QACX,CAAC;QACD,UAAU,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;YACjD,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC;QAC5C,CAAC,CAAC,CAAC;IACL,CAAC;IACD,OAAO,WAAW,CAAC;AACrB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blockml/validator",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.5",
|
|
4
4
|
"description": "BlockML validator — semantic validation of BOM documents",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
"test": "vitest run packages/validator/test"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@blockml/bom": "^0.9.
|
|
36
|
-
"@blockml/core": "^1.1
|
|
37
|
-
"@blockml/framework": "^0.9.
|
|
35
|
+
"@blockml/bom": "^0.9.5",
|
|
36
|
+
"@blockml/core": "^1.2.1",
|
|
37
|
+
"@blockml/framework": "^0.9.5"
|
|
38
38
|
},
|
|
39
39
|
"engines": {
|
|
40
40
|
"node": ">=20"
|