@@ -21,38 +21,12 @@ module.exports = [
21
21
} ,
22
22
{
23
23
names : [ "PATTERN-TEMPLATE-RULE-002" ] ,
24
- description : "Standard Headlines" ,
25
- tags : [ "headings" , "headers" , "pattern-template" ] ,
26
- function : ( params , onError ) => {
27
- var allowedHeadlines = "Title|Patlet|Problem|Story|Context|Forces|Solutions|Resulting Context|Known Instances|Status|Author(s)|Acknowledgements" ;
28
- var re = new RegExp ( `^## (${ allowedHeadlines . replace ( / (? = [ \( \) ] ) / g, '\\' ) } )\\s*$` , "m" ) ;
29
- // console.log(re);
30
-
31
- params . tokens . filter ( function filterToken ( token ) {
32
- return token . type === "heading_open" ;
33
- } ) . forEach ( function forToken ( token ) {
34
- if ( token . tag === "h2" ) {
35
- if ( re . test ( token . line ) ) {
36
- return ;
37
- }
38
- // if (/^## ()$/m.test(token.line)) {
39
- // return;
40
- // }
41
-
42
- return onError ( {
43
- lineNumber : token . lineNumber ,
44
- detail : "Allowed types are: " + allowedHeadlines . replace ( / \| / g, ', ' ) ,
45
- context : token . line
46
- } ) ;
47
- }
48
- } ) ;
49
- }
50
- } ,
51
- {
52
- names : [ "PATTERN-TEMPLATE-RULE-003" ] ,
53
24
description : "Mandatory template sections" ,
25
+ information : new URL ( "https://github.com/InnerSourceCommons/InnerSourcePatterns/blob/main/meta/pattern-template.md" ) ,
54
26
tags : [ "headings" , "headers" , "pattern-template" ] ,
55
27
function : ( params , onError ) => {
28
+ // A list of all mandatory headlines.
29
+ // headline name (from template): regexp of all permitted headline spellings
56
30
var mandatoryHeadlines = {
57
31
"Title" : "Title" ,
58
32
"Patlet" : "Patlet" ,
@@ -68,8 +42,8 @@ module.exports = [
68
42
69
43
var collectedHeadlines = ""
70
44
71
- // collect all h2 headlines
72
- // (only the headline text itself , removing markdown sytnax and whitespace)
45
+ // Collect all h2 (##) headlines.
46
+ // Only the headline text, removing markdown and whitespaces.
73
47
params . tokens . filter ( function filterToken ( token ) {
74
48
return token . type === "heading_open" ;
75
49
} ) . forEach ( function forToken ( token ) {
@@ -83,7 +57,7 @@ module.exports = [
83
57
}
84
58
} ) ;
85
59
86
- // confirm if all `mandatoryHeadlines` exist exactly once in the `collectedHeadlines`
60
+ // confirm if all `mandatoryHeadlines` exist and exist exactly once in the `collectedHeadlines`
87
61
var errorsFound = [ ] ;
88
62
89
63
let headline ;
0 commit comments